Skip to content

Commit

Permalink
feat: support TypeScript up to version 5.1.3 (#73)
Browse files Browse the repository at this point in the history
* feat: support TypeScript up to version 5.1.3

* test for `ValidationError`
  • Loading branch information
pavadeli authored Jun 16, 2023
1 parent 2ed8fa5 commit 8d3f17f
Show file tree
Hide file tree
Showing 266 changed files with 8,169 additions and 18,712 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,13 @@ const config = {
'@typescript-eslint/no-unused-vars': 'off',
'import/extensions': ['error', 'ignorePackages'],
},
overrides: [
{
files: ['*.test.ts'],
rules: {
'@typescript-eslint/no-unsafe-argument': 'off',
},
},
],
};
module.exports = config;
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16.x'
node-version: '18.x'
- run: npm ci
- run: npm run build
- run: npx semantic-release
Expand Down
7 changes: 6 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@
"typescript.enablePromptUseWorkspaceTsdk": true,
"files.associations": { "*.json": "jsonc" },
"javascript.preferences.importModuleSpecifierEnding": "js",
"typescript.preferences.importModuleSpecifierEnding": "js"
"typescript.preferences.importModuleSpecifierEnding": "js",
"files.readonlyInclude": {
"etc/**/*": true,
"markdown/**/*": true,
"node_modules/**/*": true
}
}
7 changes: 4 additions & 3 deletions etc/types.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ export type LiteralValue = string | number | boolean | null | undefined | void;

// @public
export type MergeIntersection<T> = T extends Record<PropertyKey, unknown> ? {
[P in keyof T]: MergeIntersection<T[P]>;
} : T;
[P in keyof T]: T[P];
} & {} : T;

// @public
export type MessageDetails = Partial<ValidationDetails> & {
Expand Down Expand Up @@ -428,7 +428,8 @@ export class RecordType<KeyTypeImpl extends BaseTypeImpl<KeyType>, KeyType exten
}

// @public
export function reportError(root: Failure, level?: number, omitInput?: boolean): string;
function reportError_2(root: Failure, level?: number, omitInput?: boolean): string;
export { reportError_2 as reportError }

// @public
export type Result<T> = Success<T> | Failure;
Expand Down
6 changes: 4 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
const config = {
preset: 'ts-jest',
testEnvironment: 'node',
setupFilesAfterEnv: ['jest-extended'],
globals: { 'ts-jest': { tsconfig: '<rootDir>/tsconfig.test.json' } },
setupFilesAfterEnv: ['jest-extended/all'],
transform: {
'^.+\\.tsx?$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.test.json' }],
},
collectCoverage: true,
collectCoverageFrom: ['src/**/*.ts', '!src/index.ts', '!src/testutils.ts'],
restoreMocks: true,
Expand Down
4 changes: 2 additions & 2 deletions markdown/types.array.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Create a type that checks whether the input is an array and all elements conform to the given `elementType`<!-- -->.

<b>Signature:</b>
**Signature:**

```typescript
export declare function array<Element>(
Expand All @@ -22,6 +22,6 @@ export declare function array<Element>(
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------ |
| args | \[name: string, elementType: [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;Element&gt;, typeConfig?: [ArrayTypeConfig](./types.arraytypeconfig.md)<!-- -->\] \| \[elementType: [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;Element&gt;, typeConfig?: [ArrayTypeConfig](./types.arraytypeconfig.md)<!-- -->\] | optional name and element-type |

<b>Returns:</b>
**Returns:**

[TypeImpl](./types.typeimpl.md)<!-- -->&lt;[ArrayType](./types.arraytype.md)<!-- -->&lt;[BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;Element&gt;, Element, Element\[\]&gt;&gt;
12 changes: 6 additions & 6 deletions markdown/types.arraytype._constructor_.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

Constructs a new instance of the `ArrayType` class

<b>Signature:</b>
**Signature:**

```typescript
constructor(elementType: ElementType, typeConfig: ArrayTypeConfig, name?: string);
```

## Parameters

| Parameter | Type | Description |
| ----------- | --------------------------------------------- | ----------- |
| elementType | ElementType | |
| typeConfig | [ArrayTypeConfig](./types.arraytypeconfig.md) | |
| name | string | |
| Parameter | Type | Description |
| ----------- | --------------------------------------------- | ------------ |
| elementType | ElementType | |
| typeConfig | [ArrayTypeConfig](./types.arraytypeconfig.md) | |
| name | string | _(Optional)_ |
4 changes: 2 additions & 2 deletions markdown/types.arraytype.accept.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## ArrayType.accept() method

<b>Signature:</b>
**Signature:**

```typescript
accept<R>(visitor: Visitor<R>): R;
Expand All @@ -16,6 +16,6 @@ accept<R>(visitor: Visitor<R>): R;
| --------- | ---------------------------------------------- | ----------- |
| visitor | [Visitor](./types.visitor.md)<!-- -->&lt;R&gt; | |

<b>Returns:</b>
**Returns:**

R
2 changes: 1 addition & 1 deletion markdown/types.arraytype.basictype.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## ArrayType.basicType property

<b>Signature:</b>
**Signature:**

```typescript
readonly basicType: 'array';
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.arraytype.elementtype.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## ArrayType.elementType property

<b>Signature:</b>
**Signature:**

```typescript
readonly elementType: ElementType;
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.arraytype.isdefaultname.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## ArrayType.isDefaultName property

<b>Signature:</b>
**Signature:**

```typescript
readonly isDefaultName: boolean;
Expand Down
26 changes: 13 additions & 13 deletions markdown/types.arraytype.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

The implementation behind types created with [array()](./types.array.md)<!-- -->.

<b>Signature:</b>
**Signature:**

```typescript
export declare class ArrayType<ElementType extends BaseTypeImpl<Element>, Element, ResultType extends Element[]> extends BaseTypeImpl<ResultType, ArrayTypeConfig>
```
<b>Extends:</b> [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;ResultType, [ArrayTypeConfig](./types.arraytypeconfig.md)<!-- -->&gt;
**Extends:** [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;ResultType, [ArrayTypeConfig](./types.arraytypeconfig.md)<!-- -->&gt;
## Constructors
Expand All @@ -22,17 +22,17 @@ export declare class ArrayType<ElementType extends BaseTypeImpl<Element>, Elemen
## Properties
| Property | Modifiers | Type | Description |
| --------------------------------------------------- | --------- | --------------------------------------------- | ----------- |
| [basicType](./types.arraytype.basictype.md) | | 'array' | |
| [elementType](./types.arraytype.elementtype.md) | | ElementType | |
| [isDefaultName](./types.arraytype.isdefaultname.md) | | boolean | |
| [name](./types.arraytype.name.md) | | string | |
| [typeConfig](./types.arraytype.typeconfig.md) | | [ArrayTypeConfig](./types.arraytypeconfig.md) | |
| Property | Modifiers | Type | Description |
| --------------------------------------------------- | --------------------- | --------------------------------------------- | ----------- |
| [basicType](./types.arraytype.basictype.md) | <code>readonly</code> | 'array' | |
| [elementType](./types.arraytype.elementtype.md) | <code>readonly</code> | ElementType | |
| [isDefaultName](./types.arraytype.isdefaultname.md) | <code>readonly</code> | boolean | |
| [name](./types.arraytype.name.md) | <code>readonly</code> | string | |
| [typeConfig](./types.arraytype.typeconfig.md) | <code>readonly</code> | [ArrayTypeConfig](./types.arraytypeconfig.md) | |
## Methods
| Method | Modifiers | Description |
| ------------------------------------------------------------------- | --------- | ----------- |
| [accept(visitor)](./types.arraytype.accept.md) | | |
| [typeValidator(input, options)](./types.arraytype.typevalidator.md) | | |
| Method | Modifiers | Description |
| ------------------------------------------------------------------- | ---------------------- | ----------- |
| [accept(visitor)](./types.arraytype.accept.md) | | |
| [typeValidator(input, options)](./types.arraytype.typevalidator.md) | <code>protected</code> | |
2 changes: 1 addition & 1 deletion markdown/types.arraytype.name.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## ArrayType.name property

<b>Signature:</b>
**Signature:**

```typescript
readonly name: string;
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.arraytype.typeconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## ArrayType.typeConfig property

<b>Signature:</b>
**Signature:**

```typescript
readonly typeConfig: ArrayTypeConfig;
Expand Down
4 changes: 2 additions & 2 deletions markdown/types.arraytype.typevalidator.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## ArrayType.typeValidator() method

<b>Signature:</b>
**Signature:**

```typescript
protected typeValidator(input: unknown, options: ValidationOptions): Result<ResultType>;
Expand All @@ -17,6 +17,6 @@ protected typeValidator(input: unknown, options: ValidationOptions): Result<Resu
| input | unknown | |
| options | [ValidationOptions](./types.validationoptions.md) | |

<b>Returns:</b>
**Returns:**

[Result](./types.result.md)<!-- -->&lt;ResultType&gt;
2 changes: 1 addition & 1 deletion markdown/types.arraytypeconfig.custommessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## ArrayTypeConfig.customMessage property

<b>Signature:</b>
**Signature:**

```typescript
customMessage?: CustomMessage<unknown[], ArrayViolation[]>;
Expand Down
10 changes: 5 additions & 5 deletions markdown/types.arraytypeconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

Configuration of additional checks on array types.

<b>Signature:</b>
**Signature:**

```typescript
export interface ArrayTypeConfig extends LengthChecksConfig
```
<b>Extends:</b> [LengthChecksConfig](./types.lengthchecksconfig.md)
**Extends:** [LengthChecksConfig](./types.lengthchecksconfig.md)
## Properties
| Property | Type | Description |
| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----------------- |
| [customMessage?](./types.arraytypeconfig.custommessage.md) | [CustomMessage](./types.custommessage.md)<!-- -->&lt;unknown\[\], [ArrayViolation](./types.arrayviolation.md)<!-- -->\[\]&gt; | <i>(Optional)</i> |
| Property | Modifiers | Type | Description |
| ---------------------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------- | ------------ |
| [customMessage?](./types.arraytypeconfig.custommessage.md) | | [CustomMessage](./types.custommessage.md)<!-- -->&lt;unknown\[\], [ArrayViolation](./types.arrayviolation.md)<!-- -->\[\]&gt; | _(Optional)_ |
6 changes: 3 additions & 3 deletions markdown/types.arrayviolation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

The supported additional checks on array types.

<b>Signature:</b>
**Signature:**

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

<b>References:</b> [LengthViolation](./types.lengthviolation.md)
**References:** [LengthViolation](./types.lengthviolation.md)
4 changes: 2 additions & 2 deletions markdown/types.baseobjectliketypeimpl.and.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Intersect this Type with another Type.

<b>Signature:</b>
**Signature:**

```typescript
and<Other extends BaseObjectLikeTypeImpl<any, any>>(_other: Other): ObjectType<MergeIntersection<ResultType & Other[typeof designType]>> & TypedPropertyInformation<this['props'] & Other['props']>;
Expand All @@ -18,7 +18,7 @@ and<Other extends BaseObjectLikeTypeImpl<any, any>>(_other: Other): ObjectType<M
| --------- | ----- | ----------- |
| \_other | Other | |
<b>Returns:</b>
**Returns:**
[ObjectType](./types.objecttype.md)<!-- -->&lt;[MergeIntersection](./types.mergeintersection.md)<!-- -->&lt;ResultType &amp; Other\[typeof designType\]&gt;&gt; &amp; [TypedPropertyInformation](./types.typedpropertyinformation.md)<!-- -->&lt;this\['props'\] &amp; Other\['props'\]&gt;
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.baseobjectliketypeimpl.isdefaultname.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## BaseObjectLikeTypeImpl.isDefaultName property

<b>Signature:</b>
**Signature:**

```typescript
abstract readonly isDefaultName: boolean;
Expand Down
16 changes: 8 additions & 8 deletions markdown/types.baseobjectliketypeimpl.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@

The base implementation for all object-like Types.

<b>Signature:</b>
**Signature:**

```typescript
export declare abstract class BaseObjectLikeTypeImpl<ResultType, TypeConfig = unknown> extends BaseTypeImpl<ResultType, TypeConfig>
```
<b>Extends:</b> [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;ResultType, TypeConfig&gt;
**Extends:** [BaseTypeImpl](./types.basetypeimpl.md)<!-- -->&lt;ResultType, TypeConfig&gt;
## Remarks
Object-like types need to provide more information to be able to correctly compose arbitrary object-like types.
## Properties
| Property | Modifiers | Type | Description |
| ---------------------------------------------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------- | ----------- |
| [isDefaultName](./types.baseobjectliketypeimpl.isdefaultname.md) | | boolean | |
| [possibleDiscriminators](./types.baseobjectliketypeimpl.possiblediscriminators.md) | | Array&lt;{ path: string\[\]; values: [LiteralValue](./types.literalvalue.md)<!-- -->\[\]; }&gt; | |
| [props](./types.baseobjectliketypeimpl.props.md) | | [Properties](./types.properties.md) | |
| [propsInfo](./types.baseobjectliketypeimpl.propsinfo.md) | | [PropertiesInfo](./types.propertiesinfo.md) | |
| Property | Modifiers | Type | Description |
| ---------------------------------------------------------------------------------- | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------- |
| [isDefaultName](./types.baseobjectliketypeimpl.isdefaultname.md) | <p><code>abstract</code></p><p><code>readonly</code></p> | boolean | |
| [possibleDiscriminators](./types.baseobjectliketypeimpl.possiblediscriminators.md) | <p><code>abstract</code></p><p><code>readonly</code></p> | Array&lt;{ path: string\[\]; values: [LiteralValue](./types.literalvalue.md)<!-- -->\[\]; }&gt; | |
| [props](./types.baseobjectliketypeimpl.props.md) | <p><code>abstract</code></p><p><code>readonly</code></p> | [Properties](./types.properties.md) | |
| [propsInfo](./types.baseobjectliketypeimpl.propsinfo.md) | <p><code>abstract</code></p><p><code>readonly</code></p> | [PropertiesInfo](./types.propertiesinfo.md) | |
## Methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## BaseObjectLikeTypeImpl.possibleDiscriminators property

<b>Signature:</b>
**Signature:**

```typescript
abstract readonly possibleDiscriminators: Array<{
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.baseobjectliketypeimpl.props.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## BaseObjectLikeTypeImpl.props property

<b>Signature:</b>
**Signature:**

```typescript
abstract readonly props: Properties;
Expand Down
2 changes: 1 addition & 1 deletion markdown/types.baseobjectliketypeimpl.propsinfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## BaseObjectLikeTypeImpl.propsInfo property

<b>Signature:</b>
**Signature:**

```typescript
abstract readonly propsInfo: PropertiesInfo;
Expand Down
4 changes: 2 additions & 2 deletions markdown/types.basetypeimpl.accept.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

Accept a visitor (visitor pattern).

<b>Signature:</b>
**Signature:**

```typescript
abstract accept<R>(visitor: Visitor<R>): R;
Expand All @@ -18,7 +18,7 @@ abstract accept<R>(visitor: Visitor<R>): R;
| --------- | ---------------------------------------------- | --------------------- |
| visitor | [Visitor](./types.visitor.md)<!-- -->&lt;R&gt; | the visitor to accept |

<b>Returns:</b>
**Returns:**

R

Expand Down
Loading

0 comments on commit 8d3f17f

Please sign in to comment.