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

fix: loosen type checking for satisfy() #53

Merged
merged 1 commit into from
Nov 24, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/satisfy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,9 @@ test('can check parent property', t => {
satisfy(boo, { foo: 'foo' })
t.pass()
})

test('actual of type any should not have type checking error', t => {
let actual: any = { a: 1 }
satisfy(actual, { a: 1 })
t.pass()
})
4 changes: 3 additions & 1 deletion src/satisfy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export type SatisfyExpected<T> = {
*/
export function satisfy<
Actual,
Expected extends Partial<SatisfyExpected<Actual>>>(actual: Actual, expected: Expected) {
// Using `| any` to disable type checking due to:
// https://github.com/Microsoft/TypeScript/issues/20247
Expected extends Partial<SatisfyExpected<Actual>> | any>(actual: Actual, expected: Expected) {
satisfyInternal(actual, expected, '')
}
export class FailedPredicate extends Error {
Expand Down