Skip to content

Commit

Permalink
fix(validator): type error
Browse files Browse the repository at this point in the history
Replace declare module '@typp/core' to '@typp/core/base'
  • Loading branch information
NWYLZW committed Oct 15, 2024
1 parent 35e21f1 commit 2944e6b
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion packages/validator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function _useValidator<Shape>(
}
}

declare module '@typp/core' {
declare module '@typp/core/base' {
namespace t {
export interface ErrorArgsMap {
[k: string]: unknown[]
Expand Down
4 changes: 2 additions & 2 deletions packages/validator/src/types/literal.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { t as tn } from '@typp/core'

import { FALSY } from '../base'
import type { SwitchBaseType } from '../base.inner'
import { FALSY } from '../base'
import { preprocess } from '../utils.inner'
import { bigintTransform } from './primitive.bigint'
import { booleanTransform } from './primitive.boolean'
import { numberTransform } from './primitive.number'
import { stringTransform } from './primitive.string'
import { symbolTransform } from './primitive.symbol'

declare module '@typp/core' {
declare module '@typp/core/base' {
namespace t {
export interface ValidateExtendsEntries<T> {
null: [
Expand Down
8 changes: 4 additions & 4 deletions packages/validator/src/types/primitive.bigint.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { IsEqual, IsSubType, IsTrue, IsWhat, Not, OnlySubType, t as tn } from '@typp/core'
import type { IsEqual, IsWhat, Not, OnlySubType, t as tn } from '@typp/core'

import { FALSY } from '../base'
import type { LiteralTypeGuard, SwitchBaseType } from '../base.inner'
import { FALSY } from '../base'
import { parseBigInt } from '../utils'
import { preprocess } from '../utils.inner'

declare module '@typp/core' {
declare module '@typp/core/base' {
namespace t {
export interface ValidateExtendsEntries<T> {
bigint: [IsWhat<T, bigint>, bigint | BigInt]
Expand Down Expand Up @@ -64,7 +64,7 @@ export const bigintTransform: tn.Validator<bigint>['transform'] = function (inpu
} else if (input === -Infinity) {
return 2n ** 1024n * -1n
} else if (Number.isNaN(input)) {
throw new Error('NaN cannot be converted to BigInt')
throw new TypeError('NaN cannot be converted to BigInt')
} else {
if (input > Number.MAX_SAFE_INTEGER || input < Number.MIN_SAFE_INTEGER) {
throw new Error('number must greater than or equal to -2^53 and less than or equal to 2^53')
Expand Down
2 changes: 1 addition & 1 deletion packages/validator/src/types/primitive.boolean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FALSY } from '../base'
import type { LiteralTypeGuard, SwitchBaseType } from '../base.inner'
import { preprocess } from '../utils.inner'

declare module '@typp/core' {
declare module '@typp/core/base' {
namespace t {
export interface ValidateExtendsEntries<T> {
boolean: [
Expand Down
2 changes: 1 addition & 1 deletion packages/validator/src/types/primitive.number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FALSY } from '../base'
import type { LiteralTypeGuard, SwitchBaseType } from '../base.inner'
import { preprocess } from '../utils.inner'

declare module '@typp/core' {
declare module '@typp/core/base' {
namespace t {
export interface ValidateExtendsEntries<T> {
number: [
Expand Down
2 changes: 1 addition & 1 deletion packages/validator/src/types/primitive.string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { IsWhat, OnlySubType, t as tn } from '@typp/core'
import type { LiteralTypeGuard, SwitchBaseType } from '../base.inner'
import { preprocess } from '../utils.inner'

declare module '@typp/core' {
declare module '@typp/core/base' {
namespace t {
export interface ValidateExtendsEntries<T> {
string: [
Expand Down
2 changes: 1 addition & 1 deletion packages/validator/src/types/primitive.symbol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { IsWhat, OnlySubType, t as tn } from '@typp/core'
import type { LiteralTypeGuard } from '../base.inner'
import { preprocess } from '../utils.inner'

declare module '@typp/core' {
declare module '@typp/core/base' {
namespace t {
export interface ValidateExtendsEntries<T> {
symbol: [
Expand Down
2 changes: 1 addition & 1 deletion packages/validator/src/types/structural.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { FALSY } from '../base'
// TODO record
// TODO class/instanceof

declare module '@typp/core' {
declare module '@typp/core/base' {
namespace t {
export interface ErrorArgsMap {
/**
Expand Down

0 comments on commit 2944e6b

Please sign in to comment.