Skip to content

Commit

Permalink
fix(*): TypeScript 5.x compatibility (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
favna authored Apr 2, 2023
1 parent 40b4628 commit eba2a88
Show file tree
Hide file tree
Showing 19 changed files with 6,962 additions and 6,932 deletions.
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
"format": "prettier --write \"{src,tests}/**/*.ts\"",
"docs": "typedoc-json-parser",
"test": "vitest run",
"test:watch": "vitest",
"update": "yarn upgrade-interactive",
"build": "tsup",
"clean": "node scripts/clean.mjs",
"typecheck": "tsc -p tsconfig.eslint.json",
Expand All @@ -32,6 +30,10 @@
"prepack": "yarn build && pinst --disable",
"postpack": "pinst --enable"
},
"dependencies": {
"fast-deep-equal": "^3.1.3",
"lodash": "^4.17.21"
},
"devDependencies": {
"@commitlint/cli": "^17.5.1",
"@commitlint/config-conventional": "^17.4.4",
Expand Down Expand Up @@ -61,7 +63,7 @@
"tsup": "^6.7.0",
"typedoc": "^0.23.28",
"typedoc-json-parser": "^7.2.0",
"typescript": "^4.9.5",
"typescript": "^5.0.3",
"vite": "^4.2.1",
"vitest": "^0.29.8"
},
Expand Down Expand Up @@ -119,9 +121,5 @@
"ansi-regex": "^5.0.1",
"minimist": "^1.2.8"
},
"packageManager": "yarn@3.5.0",
"dependencies": {
"fast-deep-equal": "^3.1.3",
"lodash": "^4.17.21"
}
"packageManager": "yarn@3.5.0"
}
2 changes: 1 addition & 1 deletion src/constraints/ArrayConstraints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ExpectedConstraintError } from '../lib/errors/ExpectedConstraintError';
import { Result } from '../lib/Result';
import type { IConstraint } from './base/IConstraint';
import { isUnique } from './util/isUnique';
import { Comparator, equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, notEqual } from './util/operators';
import { equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, notEqual, type Comparator } from './util/operators';

export type ArrayConstraintName = `s.array(T).${
| 'unique'
Expand Down
2 changes: 1 addition & 1 deletion src/constraints/BigIntConstraints.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ExpectedConstraintError } from '../lib/errors/ExpectedConstraintError';
import { Result } from '../lib/Result';
import type { IConstraint } from './base/IConstraint';
import { Comparator, equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, notEqual } from './util/operators';
import { equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, notEqual, type Comparator } from './util/operators';

export type BigIntConstraintName = `s.bigint.${
| 'lessThan'
Expand Down
2 changes: 1 addition & 1 deletion src/constraints/DateConstraints.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ExpectedConstraintError } from '../lib/errors/ExpectedConstraintError';
import { Result } from '../lib/Result';
import type { IConstraint } from './base/IConstraint';
import { Comparator, equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, notEqual } from './util/operators';
import { equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, notEqual, type Comparator } from './util/operators';

export type DateConstraintName = `s.date.${
| 'lessThan'
Expand Down
2 changes: 1 addition & 1 deletion src/constraints/NumberConstraints.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ExpectedConstraintError } from '../lib/errors/ExpectedConstraintError';
import { Result } from '../lib/Result';
import type { IConstraint } from './base/IConstraint';
import { Comparator, equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, notEqual } from './util/operators';
import { equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, notEqual, type Comparator } from './util/operators';

export type NumberConstraintName = `s.number.${
| 'lessThan'
Expand Down
2 changes: 1 addition & 1 deletion src/constraints/StringConstraints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Result } from '../lib/Result';
import type { IConstraint } from './base/IConstraint';
import { validateEmail } from './util/emailValidator';
import { isIP, isIPv4, isIPv6 } from './util/net';
import { Comparator, equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, notEqual } from './util/operators';
import { equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, notEqual, type Comparator } from './util/operators';
import { validatePhoneNumber } from './util/phoneValidator';
import { createUrlValidators } from './util/urlValidators';

Expand Down
2 changes: 1 addition & 1 deletion src/constraints/TypedArrayLengthConstraints.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ExpectedConstraintError } from '../lib/errors/ExpectedConstraintError';
import { Result } from '../lib/Result';
import type { IConstraint } from './base/IConstraint';
import { Comparator, equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, notEqual } from './util/operators';
import { equal, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, notEqual, type Comparator } from './util/operators';
import type { TypedArray } from './util/typedArray';

export type TypedArrayConstraintName = `s.typedArray(T).${'byteLength' | 'length'}${
Expand Down
2 changes: 1 addition & 1 deletion src/constraints/util/urlValidators.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MultiplePossibilitiesConstraintError } from '../../lib/errors/MultiplePossibilitiesConstraintError';
import { combinedErrorFn, ErrorFn } from './common/combinedResultFn';
import { combinedErrorFn, type ErrorFn } from './common/combinedResultFn';

export type StringProtocol = `${string}:`;

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Shapes } from './lib/Shapes';

export const s = new Shapes();

export * from './lib/Result';
export * from './lib/configs';
export * from './lib/errors/BaseError';
export * from './lib/errors/CombinedError';
Expand All @@ -13,5 +14,4 @@ export * from './lib/errors/MultiplePossibilitiesConstraintError';
export * from './lib/errors/UnknownEnumValueError';
export * from './lib/errors/UnknownPropertyError';
export * from './lib/errors/ValidationError';
export * from './lib/Result';
export * from './type-exports';
2 changes: 1 addition & 1 deletion src/lib/Shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
UnionValidator
} from '../validators/imports';
import { LazyValidator } from '../validators/LazyValidator';
import { NativeEnumLike, NativeEnumValidator } from '../validators/NativeEnumValidator';
import { NativeEnumValidator, type NativeEnumLike } from '../validators/NativeEnumValidator';
import { TypedArrayValidator } from '../validators/TypedArrayValidator';
import type { Constructor, MappedObjectValidator } from './util-types';

Expand Down
2 changes: 1 addition & 1 deletion src/validators/LazyValidator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Result } from '../lib/Result';
import type { IConstraint, Unwrap } from '../type-exports';
import { BaseValidator, ValidatorError } from './imports';
import { BaseValidator, type ValidatorError } from './imports';

export class LazyValidator<T extends BaseValidator<unknown>, R = Unwrap<T>> extends BaseValidator<R> {
private readonly validator: (value: unknown) => T;
Expand Down
2 changes: 1 addition & 1 deletion src/validators/ObjectValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class ObjectValidator<T extends object, I = UndefinedToOptional<T>> exten
}
}

export const enum ObjectValidatorStrategy {
export enum ObjectValidatorStrategy {
Ignore,
Strict,
Passthrough
Expand Down
2 changes: 1 addition & 1 deletion src/validators/StringValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
stringRegex,
stringUrl,
stringUuid,
StringUuidOptions,
type StringUuidOptions,
type UrlOptions
} from '../constraints/StringConstraints';
import { ValidationError } from '../lib/errors/ValidationError';
Expand Down
2 changes: 1 addition & 1 deletion src/validators/TypedArrayValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
typedArrayLengthRangeInclusive
} from '../constraints/TypedArrayLengthConstraints';
import { aOrAn } from '../constraints/util/common/vowels';
import { TypedArray, TypedArrayName, TypedArrays } from '../constraints/util/typedArray';
import { TypedArrays, type TypedArray, type TypedArrayName } from '../constraints/util/typedArray';
import { ValidationError } from '../lib/errors/ValidationError';
import { Result } from '../lib/Result';
import { BaseValidator } from './imports';
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/configs.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseValidator, s, setGlobalValidationEnabled } from '../../src';
import { s, setGlobalValidationEnabled, type BaseValidator } from '../../src';

describe('Validation enabled and disabled configurations', () => {
const stringPredicate = s.string.lengthGreaterThan(5);
Expand Down
2 changes: 1 addition & 1 deletion tests/validators/array.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ArrayValidator, CombinedPropertyError, ExpectedConstraintError, s, ValidationError } from '../../src';
import { CombinedPropertyError, ExpectedConstraintError, ValidationError, s, type ArrayValidator } from '../../src';
import { expectClonedValidator, expectError } from '../common/macros/comparators';

describe('ArrayValidator', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/validators/lazy.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CombinedPropertyError, ExpectedConstraintError, MissingPropertyError, s, SchemaOf, ValidationError } from '../../src';
import { CombinedPropertyError, ExpectedConstraintError, MissingPropertyError, ValidationError, s, type SchemaOf } from '../../src';
import { expectError } from '../common/macros/comparators';

describe('LazyValidator', () => {
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": false,
"emitDecoratorMetadata": false
"emitDecoratorMetadata": false,
"ignoreDeprecations": "5.0" // To be removed when @sapphire/ts-config is updated to TS 5.x
}
}
Loading

0 comments on commit eba2a88

Please sign in to comment.