Skip to content

Commit

Permalink
fix: DeepPartial with any and {[k: string]: any} (#6581)
Browse files Browse the repository at this point in the history
* test: Test DeepPartial with any and {[k: string]: any}

This tests #6580.

* fix: DeepPartial with any and {[k: string]: any}

Fixes #6580.
  • Loading branch information
MatthiasKunnen committed Aug 23, 2020
1 parent 9d2df28 commit 8d90d40
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common/DeepPartial.ts
Expand Up @@ -5,5 +5,5 @@ export type DeepPartial<T> = {
[P in keyof T]?:
T[P] extends Array<infer U> ? Array<DeepPartial<U>> :
T[P] extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> :
DeepPartial<T[P]>
DeepPartial<T[P]> | T[P]
};
4 changes: 4 additions & 0 deletions test/github-issues/6580/entity/Comment.ts
@@ -0,0 +1,4 @@
export class Comment {
any: any;
object: {[k: string]: any};
}
24 changes: 24 additions & 0 deletions test/github-issues/6580/issue-6580.ts
@@ -0,0 +1,24 @@
import {DeepPartial} from "../../../src";
import {Comment} from "./entity/Comment";

describe("github issues > #6580 DeepPartial does not handle `any` and `{[k: string]}`", () => {

function attemptDeepPartial(entityLike: DeepPartial<Comment>): void {
}

it("DeepPartial should correctly handle any", () => {
attemptDeepPartial({
any: {
foo: 'bar',
}
})
});

it("DeepPartial should correctly handle {[k: string]: any}", () => {
attemptDeepPartial({
object: {
foo: 'bar'
},
})
});
});

0 comments on commit 8d90d40

Please sign in to comment.