Closed
Description
TypeScript Version: 2.1.4
Code
interface Base {
page: number
}
function test<T extends Base>() {
const firstPage:Partial<T> = { page: 1 };
}
Also reproducible here.
Expected behavior:
firstPage
should be accepted as a valid partial instance of T
.
Actual behavior:
error TS2322: Type '{ page: 1; }' is not assignable to type 'Partial<T>'.
Also, the error is not very helpful explaining why the type is not assignable.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
pzavolinsky commentedon Dec 9, 2016
Related to #12731.
I believe this should be considered a bug rather than a suggestion (as the issue above).
Partial<T>
where T is generic #19470mhegazy commentedon Oct 31, 2017
Duplicate of #16356 and #19388
mhegazy commentedon Oct 31, 2017
Use
Partial<Base>
instead.typescript-bot commentedon Nov 16, 2017
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.