Skip to content

Commit

Permalink
undeprecate AnyType, AnyC, any
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Dec 3, 2022
1 parent 471dd00 commit ffc764f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 52 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

- undeprecate `FunctionType`, `FunctionC`, `Function`
- undeprecate `NeverType`, `NeverC`, `never`
- undeprecate `AnyType`, `AnyC`, `any`

# 2.2.19

Expand Down
55 changes: 24 additions & 31 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2038,6 +2038,30 @@ export interface NeverC extends NeverType {}
*/
export const never: NeverC = new NeverType()

/**
* @since 1.0.0
*/
export class AnyType extends Type<any> {
/**
* @since 1.0.0
*/
readonly _tag: 'AnyType' = 'AnyType'
constructor() {
super('any', (_): _ is any => true, success, identity)
}
}

/**
* @since 1.5.3
*/
export interface AnyC extends AnyType {}

/**
* @category primitives
* @since 1.0.0
*/
export const any: AnyC = new AnyType()

// -------------------------------------------------------------------------------------
// deprecated
// -------------------------------------------------------------------------------------
Expand Down Expand Up @@ -2146,37 +2170,6 @@ export const getDefaultContext /* istanbul ignore next */ = (decoder: Decoder<an
{ key: '', type: decoder }
]

/**
* @since 1.0.0
* @deprecated
*/
export class AnyType extends Type<any> {
/**
* @since 1.0.0
*/
readonly _tag: 'AnyType' = 'AnyType'
constructor() {
super('any', (_): _ is any => true, success, identity)
}
}

/**
* @since 1.5.3
* @deprecated
*/
// tslint:disable-next-line: deprecation
export interface AnyC extends AnyType {}

/**
* Use `unknown` instead.
*
* @category primitives
* @since 1.0.0
* @deprecated
*/
// tslint:disable-next-line: deprecation
export const any: AnyC = new AnyType()

/**
* Use `UnknownRecord` instead.
*
Expand Down
18 changes: 0 additions & 18 deletions test/2.1.x/default-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,44 +197,26 @@ describe('Function', () => {

describe('any', () => {
it('should decode any value', () => {
// tslint:disable-next-line: deprecation
assertSuccess(t.any.decode(null))
// tslint:disable-next-line: deprecation
assertSuccess(t.any.decode(undefined))
// tslint:disable-next-line: deprecation
assertSuccess(t.any.decode('foo'))
// tslint:disable-next-line: deprecation
assertSuccess(t.any.decode(1))
// tslint:disable-next-line: deprecation
assertSuccess(t.any.decode(true))
// tslint:disable-next-line: deprecation
assertSuccess(t.any.decode(t.identity))
// tslint:disable-next-line: deprecation
assertSuccess(t.any.decode({}))
// tslint:disable-next-line: deprecation
assertSuccess(t.any.decode([]))
// tslint:disable-next-line: deprecation
assertSuccess(t.any.decode(/a/))
})

it('should accept any value', () => {
// tslint:disable-next-line: deprecation
assert.ok(t.any.is(null))
// tslint:disable-next-line: deprecation
assert.ok(t.any.is(undefined))
// tslint:disable-next-line: deprecation
assert.ok(t.any.is('foo'))
// tslint:disable-next-line: deprecation
assert.ok(t.any.is(1))
// tslint:disable-next-line: deprecation
assert.ok(t.any.is(true))
// tslint:disable-next-line: deprecation
assert.ok(t.any.is(t.identity))
// tslint:disable-next-line: deprecation
assert.ok(t.any.is({}))
// tslint:disable-next-line: deprecation
assert.ok(t.any.is([]))
// tslint:disable-next-line: deprecation
assert.ok(t.any.is(/a/))
})
})
Expand Down
3 changes: 0 additions & 3 deletions test/2.1.x/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ describe('record', () => {
})

it('should accept an array if the codomain is `any`', () => {
// tslint:disable-next-line: deprecation
const T = t.record(t.string, t.any)
assert.strictEqual(T.is([]), true)
})
Expand Down Expand Up @@ -98,7 +97,6 @@ describe('record', () => {
})

it('should decode an array if the codomain is `any`', () => {
// tslint:disable-next-line: deprecation
const T = t.record(t.string, t.any)
assertSuccess(T.decode([1]))
})
Expand Down Expand Up @@ -141,7 +139,6 @@ describe('record', () => {
})

it('should accept an array if the codomain is `any`', () => {
// tslint:disable-next-line: deprecation
const T = t.record(t.string, t.any)
const a = [1]
assert.strictEqual(T.encode(a), a)
Expand Down

0 comments on commit ffc764f

Please sign in to comment.