Skip to content

Commit 9e8ef0e

Browse files
authored
fix [email protected] errors, closes #656, closes #647 (#657)
1 parent 63eea02 commit 9e8ef0e

28 files changed

+11233
-165
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
**Note**: Gaps between patch versions are faulty/broken releases.
1515
**Note**: A feature tagged as Experimental is in a high state of flux, you're at risk of it changing without notice.
1616

17+
# 2.2.18
18+
19+
- **Bug Fix**
20+
- fix `[email protected]` errors, closes #656, closes #647 (@gcanti)
21+
1722
# 2.2.17
1823

1924
- **Bug Fix**

docs/modules/Codec.ts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ Added in v2.2.3
352352
**Signature**
353353

354354
```ts
355-
export declare function literal<A extends readonly [Literal, ...Array<Literal>]>(
355+
export declare function literal<A extends readonly [L, ...ReadonlyArray<L>], L extends S.Literal = S.Literal>(
356356
...values: A
357357
): Codec<unknown, A[number], A[number]>
358358
```

docs/modules/Decoder.ts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ Added in v2.2.8
479479
**Signature**
480480
481481
```ts
482-
export declare const literal: <A extends readonly [S.Literal, ...S.Literal[]]>(
482+
export declare const literal: <A extends readonly [L, ...L[]], L extends S.Literal = S.Literal>(
483483
...values: A
484484
) => Decoder<unknown, A[number]>
485485
```

docs/modules/Guard.ts.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,9 @@ Added in v2.2.0
255255
**Signature**
256256
257257
```ts
258-
export declare const literal: <A extends readonly [Literal, ...Literal[]]>(...values: A) => Guard<unknown, A[number]>
258+
export declare const literal: <A extends readonly [L, ...L[]], L extends S.Literal = S.Literal>(
259+
...values: A
260+
) => Guard<unknown, A[number]>
259261
```
260262
261263
Added in v2.2.0
@@ -267,7 +269,7 @@ Added in v2.2.0
267269
**Signature**
268270
269271
```ts
270-
export declare const Schemable: Schemable1<'io-ts/Guard'>
272+
export declare const Schemable: S.Schemable1<'io-ts/Guard'>
271273
```
272274
273275
Added in v2.2.8
@@ -297,7 +299,7 @@ Added in v2.2.0
297299
**Signature**
298300
299301
```ts
300-
export declare const WithRefine: WithRefine1<'io-ts/Guard'>
302+
export declare const WithRefine: S.WithRefine1<'io-ts/Guard'>
301303
```
302304
303305
Added in v2.2.8
@@ -307,7 +309,7 @@ Added in v2.2.8
307309
**Signature**
308310
309311
```ts
310-
export declare const WithUnion: WithUnion1<'io-ts/Guard'>
312+
export declare const WithUnion: S.WithUnion1<'io-ts/Guard'>
311313
```
312314
313315
Added in v2.2.8
@@ -317,7 +319,7 @@ Added in v2.2.8
317319
**Signature**
318320
319321
```ts
320-
export declare const WithUnknownContainers: WithUnknownContainers1<'io-ts/Guard'>
322+
export declare const WithUnknownContainers: S.WithUnknownContainers1<'io-ts/Guard'>
321323
```
322324
323325
Added in v2.2.8

docs/modules/Kleisli.ts.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,10 @@ Added in v2.2.7
314314
export declare function literal<M extends URIS2, E>(
315315
M: MonadThrow2C<M, E>
316316
): <I>(
317-
onError: (i: I, values: readonly [Literal, ...Array<Literal>]) => E
318-
) => <A extends readonly [Literal, ...Array<Literal>]>(...values: A) => Kleisli<M, I, E, A[number]>
317+
onError: (i: I, values: readonly [S.Literal, ...ReadonlyArray<S.Literal>]) => E
318+
) => <A extends readonly [L, ...ReadonlyArray<L>], L extends S.Literal = S.Literal>(
319+
...values: A
320+
) => Kleisli<M, I, E, A[number]>
319321
```
320322

321323
Added in v2.2.7

docs/modules/Schemable.ts.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ Added in v2.2.0
5656
```ts
5757
export interface Schemable<S> {
5858
readonly URI: S
59-
readonly literal: <A extends readonly [Literal, ...Array<Literal>]>(...values: A) => HKT<S, A[number]>
59+
readonly literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends Literal = Literal>(
60+
...values: A
61+
) => HKT<S, A[number]>
6062
readonly string: HKT<S, string>
6163
readonly number: HKT<S, number>
6264
readonly boolean: HKT<S, boolean>
@@ -86,7 +88,9 @@ Added in v2.2.3
8688
```ts
8789
export interface Schemable1<S extends URIS> {
8890
readonly URI: S
89-
readonly literal: <A extends readonly [Literal, ...Array<Literal>]>(...values: A) => Kind<S, A[number]>
91+
readonly literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends Literal = Literal>(
92+
...values: A
93+
) => Kind<S, A[number]>
9094
readonly string: Kind<S, string>
9195
readonly number: Kind<S, number>
9296
readonly boolean: Kind<S, boolean>
@@ -116,7 +120,9 @@ Added in v2.2.3
116120
```ts
117121
export interface Schemable2C<S extends URIS2, E> {
118122
readonly URI: S
119-
readonly literal: <A extends readonly [Literal, ...Array<Literal>]>(...values: A) => Kind2<S, E, A[number]>
123+
readonly literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends Literal = Literal>(
124+
...values: A
125+
) => Kind2<S, E, A[number]>
120126
readonly string: Kind2<S, E, string>
121127
readonly number: Kind2<S, E, number>
122128
readonly boolean: Kind2<S, E, boolean>

docs/modules/TaskDecoder.ts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ Added in v2.2.8
495495
**Signature**
496496
497497
```ts
498-
export declare const literal: <A extends readonly [S.Literal, ...S.Literal[]]>(
498+
export declare const literal: <A extends readonly [L, ...L[]], L extends S.Literal = S.Literal>(
499499
...values: A
500500
) => TaskDecoder<unknown, A[number]>
501501
```

docs/modules/Type.ts.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ Added in v2.2.3
198198
**Signature**
199199
200200
```ts
201-
export declare const literal: <A extends readonly [S.Literal, ...S.Literal[]]>(...values: A) => Type<A[number]>
201+
export declare const literal: <A extends readonly [L, ...L[]], L extends S.Literal = S.Literal>(
202+
...values: A
203+
) => Type<A[number]>
202204
```
203205
204206
Added in v2.2.3

docs/modules/index.ts.md

+3-27
Original file line numberDiff line numberDiff line change
@@ -650,39 +650,15 @@ Keeps the codec "kind".
650650
```ts
651651
export declare function alias<A, O, P, I>(
652652
codec: PartialType<P, A, O, I>
653-
): <
654-
// tslint:disable-next-line: deprecation
655-
AA extends Exact<A, AA>,
656-
// tslint:disable-next-line: deprecation
657-
OO extends Exact<O, OO> = O,
658-
// tslint:disable-next-line: deprecation
659-
PP extends Exact<P, PP> = P,
660-
II extends I = I
661-
>() => PartialType<PP, AA, OO, II>
653+
): <AA extends A, OO extends O = O, PP extends P = P, II extends I = I>() => PartialType<PP, AA, OO, II>
662654
export declare function alias<A, O, P, I>(
663655
// tslint:disable-next-line: deprecation
664656
codec: StrictType<P, A, O, I>
665-
): <
666-
// tslint:disable-next-line: deprecation
667-
AA extends Exact<A, AA>,
668-
// tslint:disable-next-line: deprecation
669-
OO extends Exact<O, OO> = O,
670-
// tslint:disable-next-line: deprecation
671-
PP extends Exact<P, PP> = P,
672-
II extends I = I
673-
>() => // tslint:disable-next-line: deprecation
657+
): <AA extends A, OO extends O = O, PP extends P = P, II extends I = I>() => // tslint:disable-next-line: deprecation
674658
StrictType<PP, AA, OO, II>
675659
export declare function alias<A, O, P, I>(
676660
codec: InterfaceType<P, A, O, I>
677-
): <
678-
// tslint:disable-next-line: deprecation
679-
AA extends Exact<A, AA>,
680-
// tslint:disable-next-line: deprecation
681-
OO extends Exact<O, OO> = O,
682-
// tslint:disable-next-line: deprecation
683-
PP extends Exact<P, PP> = P,
684-
II extends I = I
685-
>() => InterfaceType<PP, AA, OO, II>
661+
): <AA extends A, OO extends O = O, PP extends P = P, II extends I = I>() => InterfaceType<PP, AA, OO, II>
686662
```
687663
688664
Added in v1.1.0

dtslint/ts3.5/Decoder.ts

+42
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,48 @@ export type TypeOfNumberFromString = _.TypeOf<typeof NumberFromString>
1919
// $ExpectType string
2020
export type InputOfNumberFromString = _.InputOf<typeof NumberFromString>
2121

22+
//
23+
// literal
24+
//
25+
26+
// $ExpectType Decoder<unknown, "A">
27+
_.literal('A')
28+
29+
// $ExpectType Decoder<unknown, "A" | "B">
30+
_.literal('A', 'B')
31+
32+
// $ExpectType Decoder<unknown, "A">
33+
_.union(_.literal('A'))
34+
35+
// $ExpectType Decoder<unknown, "A" | "B">
36+
_.union(_.literal('A'), _.literal('B'))
37+
38+
// $ExpectType Decoder<unknown, { a: "A"; }>
39+
_.struct({
40+
a: _.literal('A')
41+
})
42+
43+
// $ExpectType Decoder<unknown, { a: "A"; } & { b: "B"; }>
44+
pipe(
45+
_.struct({
46+
a: _.literal('A')
47+
}),
48+
_.intersect(
49+
_.struct({
50+
b: _.literal('B')
51+
})
52+
)
53+
)
54+
55+
import * as S from '../../src/Schemable'
56+
declare const literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends S.Literal = S.Literal>(
57+
...values: A
58+
) => _.Decoder<unknown, A[number]>
59+
// $ExpectType Decoder<unknown, { a: "A"; }>
60+
_.struct({
61+
a: literal('A')
62+
})
63+
2264
//
2365
// fromStruct
2466
//

dtslint/ts3.5/Schema.ts

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export type OfTest = TypeOf<typeof OfTest> // $ExpectType { a: string; b: { c: n
2727
make((S) => S.literal())
2828
make((S) => S.literal('a')) // $ExpectType Schema<"a">
2929
make((S) => S.literal('a', 'b', null)) // $ExpectType Schema<"a" | "b" | null>
30+
make((S) => S.literal<['a']>('a')) // $ExpectType Schema<"a">
3031

3132
//
3233
// string
@@ -57,6 +58,7 @@ make((S) => S.nullable(S.string)) // $ExpectType Schema<string | null>
5758
//
5859

5960
make((S) => S.struct({ a: S.string, b: S.struct({ c: S.number }) })) // $ExpectType Schema<{ a: string; b: { c: number; }; }>
61+
make((S) => S.struct({ a: S.literal('a') })) // $ExpectType Schema<{ a: "a"; }>
6062

6163
//
6264
// partial

dtslint/ts3.5/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,8 @@ type AliasTest2 = t.OutputOf<typeof C5>['a'] // $ExpectType string
387387
type AliasTest3 = t.OutputOf<typeof C5>['b'] // $ExpectType string
388388
// $ExpectError
389389
const C6 = t.alias(C1)<C1, C1>()
390-
// $ExpectError
391-
const C7 = t.alias(C1)<C1WithAdditionalProp, C1O>()
390+
// // $ExpectError
391+
// bug fix: 647 const C7 = t.alias(C1)<C1WithAdditionalProp, C1O>()
392392
const C8 = t.alias(C1)<C1, C1O>()
393393
type AliasTest4 = t.TypeOf<typeof C8> // $ExpectType C1
394394
type AliasTest5 = t.OutputOf<typeof C8> // $ExpectType C1O

0 commit comments

Comments
 (0)