Skip to content

Commit

Permalink
Merge branch 'main' into inference-of-arrays-of-branded-types
Browse files Browse the repository at this point in the history
  • Loading branch information
pavadeli committed Oct 26, 2023
2 parents 201f839 + 56184f3 commit 43bf244
Show file tree
Hide file tree
Showing 137 changed files with 1,249 additions and 370 deletions.
10 changes: 6 additions & 4 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules
dist
coverage
**/*.js
/node_modules
/build
/dist
/coverage
/*.js
/*.ts
3 changes: 1 addition & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ const config = {
rules: {
'no-fallthrough': 'off', // checked by TS compiler
'object-shorthand': ['error', 'always'],
'sort-imports': ['error', { ignoreDeclarationSort: true }],
'sort-imports': ['off'],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-invalid-void-type': 'off',
'@typescript-eslint/no-throw-literal': 'off',
'import/extensions': ['error', 'ignorePackages'],
},
overrides: [
{
Expand Down
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
dist
node_modules
coverage
*.tsbuildinfo
temp
/dist
/node_modules
/coverage
/temp
/build

*.tsbuildinfo
14 changes: 10 additions & 4 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
.*
node_modules
/*.js
/node_modules
/temp
/build
/markdown
/etc
/api-extractor.json
/tsconfig.*
/coverage

/*.js
/*.ts

tsconfig.*
*.tsbuildinfo
*.tgz
.*
*.test.ts
testutils.ts
2 changes: 1 addition & 1 deletion api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
*/
"mainEntryPointFilePath": "<projectFolder>/dist/esm/index.d.ts",
"mainEntryPointFilePath": "<projectFolder>/dist/index.d.ts",

/**
* A list of NPM package names whose exports should be treated as part of this package.
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.array.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Create a type that checks whether the input is an array and all elements conform
**Signature:**

```typescript
export declare function array<ElementType extends BaseTypeImpl<any>>(
declare function array<ElementType extends BaseTypeImpl<any>>(
...args:
| [name: string, elementType: ElementType, typeConfig?: ArrayTypeConfig]
| [elementType: ElementType, typeConfig?: ArrayTypeConfig]
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.arraytype.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The implementation behind types created with [array()](./types.array.md)<!-- -->
**Signature:**

```typescript
export declare class ArrayType<ElementType extends BaseTypeImpl<Element>, Element, ResultType extends Element[]> extends BaseTypeImpl<ResultType, ArrayTypeConfig>
declare class ArrayType<ElementType extends BaseTypeImpl<Element>, Element, ResultType extends Element[]> extends BaseTypeImpl<ResultType, ArrayTypeConfig>
```
**Extends:** [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;ResultType, [ArrayTypeConfig](./types.arraytypeconfig.md)<!-- -->&gt;
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.arraytypeconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Configuration of additional checks on array types.
**Signature:**

```typescript
export interface ArrayTypeConfig extends LengthChecksConfig
interface ArrayTypeConfig extends LengthChecksConfig
```
**Extends:** [LengthChecksConfig](./types.lengthchecksconfig.md)
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.arrayviolation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The supported additional checks on array types.
**Signature:**

```typescript
export type ArrayViolation = LengthViolation;
type ArrayViolation = LengthViolation;
```

**References:** [LengthViolation](./types.lengthviolation.md)
2 changes: 1 addition & 1 deletion markdown/types.baseobjectliketypeimpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The base implementation for all object-like Types.
**Signature:**

```typescript
export declare abstract class BaseObjectLikeTypeImpl<ResultType, TypeConfig = unknown> extends BaseTypeImpl<ResultType, TypeConfig>
declare abstract class BaseObjectLikeTypeImpl<ResultType, TypeConfig = unknown> extends BaseTypeImpl<ResultType, TypeConfig>
```
**Extends:** [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;ResultType, TypeConfig&gt;
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.basetypeimpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The base-class of all type-implementations.
**Signature:**

```typescript
export declare abstract class BaseTypeImpl<ResultType, TypeConfig = unknown> implements TypeLink<ResultType>
declare abstract class BaseTypeImpl<ResultType, TypeConfig = unknown> implements TypeLink<ResultType>
```
**Implements:** [TypeLink](./types.typelink.md)<!-- -->&lt;ResultType&gt;
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.basictype.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Basic categories of types.
**Signature:**

```typescript
export type BasicType = 'string' | 'number' | 'bigint' | 'boolean' | 'function' | 'object' | 'array' | 'symbol' | 'undefined' | 'null';
type BasicType = 'string' | 'number' | 'bigint' | 'boolean' | 'function' | 'object' | 'array' | 'symbol' | 'undefined' | 'null';
```

## Remarks
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.booleanautocaster.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
**Signature:**

```typescript
export declare function booleanAutoCaster(input: unknown): boolean | typeof autoCastFailure;
declare function booleanAutoCaster(input: unknown): boolean | typeof autoCastFailure;
```

## Parameters
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.branded.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Create a Branded type with a given `BrandName`<!-- -->.
**Signature:**

```typescript
export type Branded<T, BrandName extends string> = T extends WithBrands<infer Base, infer ExistingBrands>
type Branded<T, BrandName extends string> = T extends WithBrands<infer Base, infer ExistingBrands>
? WithBrands<Base, BrandName | ExistingBrands>
: WithBrands<T, BrandName>;
```
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.createtype.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Create a Type from the given type-implementation.
**Signature:**

```typescript
export declare function createType<Impl extends BaseTypeImpl<any, any>>(
declare function createType<Impl extends BaseTypeImpl<any, any>>(
impl: Impl,
override?: Partial<Record<keyof BaseTypeImpl<any, any> | 'typeValidator' | 'typeParser', PropertyDescriptor>>,
): TypeImpl<Impl>;
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.custommessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The type for optional custom messages
**Signature:**

```typescript
export type CustomMessage<T, E = void> = undefined | string | ((got: string, input: T, explanation: E) => string);
type CustomMessage<T, E = void> = undefined | string | ((got: string, input: T, explanation: E) => string);
```

## Remarks
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.deepunbranded.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Unbrand a given type (recursive).
**Signature:**

```typescript
export type DeepUnbranded<T> = T extends ReadonlyArray<unknown>
type DeepUnbranded<T> = T extends ReadonlyArray<unknown>
? {
[P in keyof T & number]: DeepUnbranded<T[P]>;
}
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.failure.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A failed validation result.
**Signature:**

```typescript
export interface Failure
interface Failure
```

## Properties
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.failuredetails.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Individual message with info about the performed validation for error-reporting.
**Signature:**

```typescript
export type FailureDetails = ValidationDetails & MessageDetails;
type FailureDetails = ValidationDetails & MessageDetails;
```

**References:** [ValidationDetails](./types.validationdetails.md)<!-- -->, [MessageDetails](./types.messagedetails.md)
2 changes: 1 addition & 1 deletion markdown/types.fulltype.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
**Signature:**

```typescript
export type FullType<Props extends Properties> = TypeImpl<InterfaceType<Props, TypeOfProperties<Writable<Props>>>>;
type FullType<Props extends Properties> = TypeImpl<InterfaceType<Props, TypeOfProperties<Writable<Props>>>>;
```

**References:** [Properties](./types.properties.md)<!-- -->, [TypeImpl](./types.typeimpl.md)<!-- -->, [InterfaceType](./types.interfacetype.md)<!-- -->, [TypeOfProperties](./types.typeofproperties.md)<!-- -->, [Writable](./types.writable.md)
2 changes: 1 addition & 1 deletion markdown/types.interfacetype.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The implementation behind types created with [object()](./types.object.md) and [
**Signature:**

```typescript
export declare class InterfaceType<Props extends Properties, ResultType> extends BaseObjectLikeTypeImpl<ResultType> implements TypedPropertyInformation<Props>
declare class InterfaceType<Props extends Properties, ResultType> extends BaseObjectLikeTypeImpl<ResultType> implements TypedPropertyInformation<Props>
```
**Extends:** [BaseObjectLikeTypeImpl](./types.baseobjectliketypeimpl.md)<!-- -->&lt;ResultType&gt;
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.interfacetypeoptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Options for [object()](./types.object.md)<!-- -->.
**Signature:**

```typescript
export interface InterfaceTypeOptions
interface InterfaceTypeOptions
```

## Properties
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.intersection.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Intersect the given types.
**Signature:**

```typescript
export declare function intersection<Types extends OneOrMore<BaseObjectLikeTypeImpl<unknown>>>(
declare function intersection<Types extends OneOrMore<BaseObjectLikeTypeImpl<unknown>>>(
...args: [name: string, types: Types] | [types: Types]
): TypeImpl<IntersectionType<Types>>;
```
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.intersectionoftypetuple.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
**Signature:**

```typescript
export type IntersectionOfTypeTuple<Tuple> = Tuple extends [
type IntersectionOfTypeTuple<Tuple> = Tuple extends [
{
readonly [designType]: infer A;
},
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.intersectiontype.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The implementation behind types created with [intersection()](./types.intersecti
**Signature:**

```typescript
export declare class IntersectionType<Types extends OneOrMore<BaseObjectLikeTypeImpl<unknown>>> extends BaseObjectLikeTypeImpl<IntersectionOfTypeTuple<Types>, undefined> implements TypedPropertyInformation<PropertiesOfTypeTuple<Types>>
declare class IntersectionType<Types extends OneOrMore<BaseObjectLikeTypeImpl<unknown>>> extends BaseObjectLikeTypeImpl<IntersectionOfTypeTuple<Types>, undefined> implements TypedPropertyInformation<PropertiesOfTypeTuple<Types>>
```
**Extends:** [BaseObjectLikeTypeImpl](./types.baseobjectliketypeimpl.md)<!-- -->&lt;[IntersectionOfTypeTuple](./types.intersectionoftypetuple.md)<!-- -->&lt;Types&gt;, undefined&gt;
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.istype.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Type-guard that asserts that a given value is a Type.
**Signature:**

```typescript
export declare function isType(value: unknown): value is Type<unknown>;
declare function isType(value: unknown): value is Type<unknown>;
```

## Parameters
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.keyof.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
**Signature:**

```typescript
export declare function keyof<T extends Record<string, unknown>>(...args: [name: string, keys: T] | [keys: T]): TypeImpl<KeyofType<T>>;
declare function keyof<T extends Record<string, unknown>>(...args: [name: string, keys: T] | [keys: T]): TypeImpl<KeyofType<T>>;
```

## Parameters
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.keyoftype.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The implementation behind types created with [keyof()](./types.keyof.md) and [va
**Signature:**

```typescript
export declare class KeyofType<T extends Record<string, unknown>, ResultType extends keyof T = keyof T> extends BaseTypeImpl<ResultType>
declare class KeyofType<T extends Record<string, unknown>, ResultType extends keyof T = keyof T> extends BaseTypeImpl<ResultType>
```
**Extends:** [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;ResultType&gt;
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.lengthchecksconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
**Signature:**

```typescript
export interface LengthChecksConfig
interface LengthChecksConfig
```

## Properties
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.lengthviolation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
**Signature:**

```typescript
export type LengthViolation = 'minLength' | 'maxLength';
type LengthViolation = 'minLength' | 'maxLength';
```
2 changes: 1 addition & 1 deletion markdown/types.literal.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
**Signature:**

```typescript
export declare function literal<const T extends LiteralValue>(value: T): TypeImpl<LiteralType<T>>;
declare function literal<const T extends LiteralValue>(value: T): TypeImpl<LiteralType<T>>;
```

## Parameters
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.literaltype.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The implementation behind types created with [literal()](./types.literal.md) and
**Signature:**

```typescript
export declare class LiteralType<ResultType extends LiteralValue> extends BaseTypeImpl<ResultType>
declare class LiteralType<ResultType extends LiteralValue> extends BaseTypeImpl<ResultType>
```
**Extends:** [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;ResultType&gt;
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.literalvalue.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ The supported types of literals.
**Signature:**

```typescript
export type LiteralValue = string | number | boolean | null | undefined | void;
type LiteralValue = string | number | boolean | null | undefined | void;
```
2 changes: 1 addition & 1 deletion markdown/types.mergeintersection.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Merge an intersection of types into one type, mostly for tooltip-readability in
**Signature:**

```typescript
export type MergeIntersection<T> = T extends Record<PropertyKey, unknown>
type MergeIntersection<T> = T extends Record<PropertyKey, unknown>
? {
[P in keyof T]: T[P];
} & {}
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.messagedetails.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Individual message details with optional info about the performed validation.
**Signature:**

```typescript
export type MessageDetails = Partial<ValidationDetails> & {
type MessageDetails = Partial<ValidationDetails> & {
path?: PropertyKey[];
context?: string;
omitInput?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.numberautocaster.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
**Signature:**

```typescript
export declare function numberAutoCaster(input: unknown): number | typeof autoCastFailure;
declare function numberAutoCaster(input: unknown): number | typeof autoCastFailure;
```

## Parameters
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.numbertypeconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Configuration of additional checks on numeric types.
**Signature:**

```typescript
export type NumberTypeConfig = {
type NumberTypeConfig = {
multipleOf?: number;
customMessage?: CustomMessage<number, NumberViolation[]> | Partial<Record<NumberViolation, CustomMessage<number, NumberViolation>>>;
} & (
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.numberviolation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ The supported additional checks on numeric types.
**Signature:**

```typescript
export type NumberViolation = 'min' | 'max' | 'multipleOf';
type NumberViolation = 'min' | 'max' | 'multipleOf';
```
2 changes: 1 addition & 1 deletion markdown/types.object.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Create a type-validator that validates (or parses) an object structure.
**Signature:**

```typescript
export declare function object<Props extends Properties>(
declare function object<Props extends Properties>(
...args: [props: Props] | [name: string, props: Props] | [options: InterfaceTypeOptions, props: Props]
): FullType<Props>;
```
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.objecttype.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A type-validator/-parser that validates or parses object-like type `ResultType`<
**Signature:**

```typescript
export type ObjectType<ResultType, TypeConfig = unknown> = TypeImpl<BaseObjectLikeTypeImpl<ResultType, TypeConfig>>;
type ObjectType<ResultType, TypeConfig = unknown> = TypeImpl<BaseObjectLikeTypeImpl<ResultType, TypeConfig>>;
```

**References:** [TypeImpl](./types.typeimpl.md)<!-- -->, [BaseObjectLikeTypeImpl](./types.baseobjectliketypeimpl.md)
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.oneormore.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ An Array with at least one element.
**Signature:**

```typescript
export type OneOrMore<T> = [T, ...T[]];
type OneOrMore<T> = [T, ...T[]];
```
2 changes: 1 addition & 1 deletion markdown/types.parseroptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Options that can be passed to [BaseTypeImpl.withParser()](./types.basetypeimpl.w
**Signature:**

```typescript
export interface ParserOptions
interface ParserOptions
```

## Properties
Expand Down
Loading

0 comments on commit 43bf244

Please sign in to comment.