Skip to content

keyof NonNullable<T> cannot be used to index type T #23368

Closed
@ghost

Description

TypeScript Version: 2.9.0-dev.20180412

Code

function assign<T extends object>(to: T, from: T | undefined) {
	for (const p in from!)
		to[p] = from![p];
	return to;
}

Expected behavior:

No error.

Actual behavior:

src/a.ts(3,9): error TS2536: Type 'keyof NonNullable<T>' cannot be used to index type 'T'.

Related issues: #19461

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions