Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to definitelytyped/dtslint #699

Merged
merged 1 commit into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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