Skip to content

Commit

Permalink
switch to definitelytyped/dtslint
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Jun 5, 2023
1 parent 0baeb15 commit 616583d
Show file tree
Hide file tree
Showing 18 changed files with 2,408 additions and 593 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Expand Up @@ -30,6 +30,7 @@
}
],
"@typescript-eslint/prefer-as-const": "off",
"@typescript-eslint/ban-ts-comment": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"deprecation/deprecation": "off",
Expand Down
4 changes: 2 additions & 2 deletions dtslint/ts3.9/Codec.ts → dtslint/Codec.ts
@@ -1,4 +1,4 @@
import * as _ from '../../src/Codec'
import * as _ from '../src/Codec'

declare const NumberFromString: _.Codec<string, string, number>

Expand Down Expand Up @@ -111,5 +111,5 @@ const S2 = _.struct({ _tag: _.literal('B'), b: _.number })

// $ExpectType Codec<unknown, { _tag: "A"; a: string; } | { _tag: "B"; b: number; }, { _tag: "A"; a: string; } | { _tag: "B"; b: number; }>
_.sum('_tag')({ A: S1, B: S2 })
// // $ExpectError
// // @ts-expect-error
// _.sum('_tag')({ A: S1, B: S1 })
11 changes: 6 additions & 5 deletions dtslint/ts3.9/Decoder.ts → dtslint/Decoder.ts
@@ -1,7 +1,9 @@
import { pipe } from 'fp-ts/lib/pipeable'
import * as DE from '../../src/DecodeError'
import * as _ from '../../src/Decoder'
import * as FS from '../../src/FreeSemigroup'

import * as DE from '../src/DecodeError'
import * as _ from '../src/Decoder'
import * as FS from '../src/FreeSemigroup'
import * as S from '../src/Schemable'

declare const NumberFromString: _.Decoder<string, number>

Expand Down Expand Up @@ -52,7 +54,6 @@ pipe(
)
)

import * as S from '../../src/Schemable'
declare const literal: <A extends readonly [L, ...ReadonlyArray<L>], L extends S.Literal = S.Literal>(
...values: A
) => _.Decoder<unknown, A[number]>
Expand Down Expand Up @@ -170,7 +171,7 @@ const S2 = _.struct({ _tag: _.literal('B'), b: _.number })

// $ExpectType Decoder<unknown, { _tag: "A"; a: string; } | { _tag: "B"; b: number; }>
_.sum('_tag')({ A: S1, B: S2 })
// $ExpectError
// @ts-expect-error
_.sum('_tag')({ A: S1, B: S1 })

//
Expand Down
5 changes: 3 additions & 2 deletions dtslint/ts3.9/Encoder.ts → dtslint/Encoder.ts
@@ -1,6 +1,7 @@
import * as E from '../../src/Encoder'
import { pipe } from 'fp-ts/lib/pipeable'

import * as E from '../src/Encoder'

const NumberToString: E.Encoder<string, number> = {
encode: String
}
Expand Down Expand Up @@ -68,7 +69,7 @@ const sum = E.sum('_tag')
// $ExpectType Encoder<{ _tag: "A"; a: string; } | { _tag: "B"; b: number; }, { _tag: "A"; a: number; } | { _tag: "B"; b: boolean; }>
sum({ A: S1, B: S2 })

const S3 = E.struct({ _tag: E.id<'C'>(), c: E.id<string>() })
export const S3 = E.struct({ _tag: E.id<'C'>(), c: E.id<string>() })

//
// lazy
Expand Down
4 changes: 2 additions & 2 deletions dtslint/ts3.9/Eq.ts → dtslint/Eq.ts
@@ -1,4 +1,4 @@
import * as _ from '../../src/Eq'
import * as _ from '../src/Eq'

// $ExpectType Eq<{ a: string; b: { c: number; }; }>
_.struct({
Expand All @@ -25,7 +25,7 @@ const S2 = _.struct({ _tag: _.Schemable.literal('B'), b: _.number })

// $ExpectType Eq<{ _tag: "A"; a: string; } | { _tag: "B"; b: number; }>
_.sum('_tag')({ A: S1, B: S2 })
// // $ExpectError
// // @ts-expect-error
// _.sum('_tag')({ A: S1, B: S1 })

//
Expand Down
4 changes: 2 additions & 2 deletions dtslint/ts3.9/Guard.ts → dtslint/Guard.ts
@@ -1,4 +1,4 @@
import * as _ from '../../src/Guard'
import * as _ from '../src/Guard'

//
// struct
Expand Down Expand Up @@ -40,7 +40,7 @@ const S2 = _.struct({ _tag: _.literal('B'), b: _.number })

// $ExpectType Guard<unknown, { _tag: "A"; a: string; } | { _tag: "B"; b: number; }>
_.sum('_tag')({ A: S1, B: S2 })
// $ExpectError
// @ts-expect-error
_.sum('_tag')({ A: S1, B: S1 })

//
Expand Down
9 changes: 5 additions & 4 deletions dtslint/ts3.9/Schema.ts → dtslint/Schema.ts
@@ -1,7 +1,8 @@
import { Schemable, WithUnknownContainers, memoize, WithRefine, WithUnion } from '../../src/Schemable'
import { HKT } from 'fp-ts/lib/HKT'
import { pipe } from 'fp-ts/lib/pipeable'

import { memoize, Schemable, WithRefine, WithUnion, WithUnknownContainers } from '../src/Schemable'

interface Schema<A> {
<S>(S: Schemable<S> & WithUnknownContainers<S> & WithRefine<S> & WithUnion<S>): HKT<S, A>
}
Expand All @@ -23,7 +24,7 @@ export type OfTest = TypeOf<typeof OfTest> // $ExpectType { a: string; b: { c: n
// literal
//

// $ExpectError
// @ts-expect-error
make((S) => S.literal())
make((S) => S.literal('a')) // $ExpectType Schema<"a">
make((S) => S.literal('a', 'b', null)) // $ExpectType Schema<"a" | "b" | null>
Expand Down Expand Up @@ -102,7 +103,7 @@ const S2 = make((S) => S.struct({ _tag: S.literal('B'), b: S.number }))

// $ExpectType Schema<{ _tag: "A"; a: string; } | { _tag: "B"; b: number; }>
make((S) => S.sum('_tag')({ A: S1(S), B: S2(S) }))
// $ExpectError
// @ts-expect-error
make((S) => S.sum('_tag')({ A: S1(S), B: S1(S) }))

//
Expand Down Expand Up @@ -170,7 +171,7 @@ make((S) =>
// union
//

// $ExpectError
// @ts-expect-error
make((S) => S.union())
make((S) => S.union(S.string)) // $ExpectType Schema<string>
make((S) => S.union(S.string, S.number)) // $ExpectType Schema<string | number>
Expand Down
6 changes: 3 additions & 3 deletions dtslint/ts3.9/TaskDecoder.ts → dtslint/TaskDecoder.ts
@@ -1,4 +1,4 @@
import * as _ from '../../src/TaskDecoder'
import * as _ from '../src/TaskDecoder'

//
// sum
Expand All @@ -9,8 +9,8 @@ const S2 = _.struct({ _tag: _.literal('B'), b: _.number })

// $ExpectType TaskDecoder<unknown, { _tag: "A"; a: string; } | { _tag: "B"; b: number; }>
_.sum('_tag')({ A: S1, B: S2 })
// $ExpectError
_.sum('_tag')({ A: S1, B: S1 })
// // @ts-expect-error
// _.sum('_tag')({ A: S1, B: S1 })

//
// readonly
Expand Down
2 changes: 1 addition & 1 deletion dtslint/ts3.9/Type.ts → dtslint/Type.ts
@@ -1,4 +1,4 @@
import * as _ from '../../src/Type'
import * as _ from '../src/Type'

// $ExpectType Type<{ a: string; b: { c: number; }; }>
_.struct({
Expand Down
2 changes: 1 addition & 1 deletion dtslint/index.d.ts
@@ -1 +1 @@
// TypeScript Version: 3.9
// Minimum TypeScript Version: 3.9

0 comments on commit 616583d

Please sign in to comment.