Skip to content

Readonly for generic param doesn't work for optional properties #17005

Closed
@dfilatov

Description

@dfilatov

TypeScript Version: 2.3.4 or 2.4.1

Code

interface A {
    params?: { name: string; }
}

class Test<T extends A> {
    attrs: Readonly<T>;

    m() {
        this.attrs.params!.name;                    
    }
}

Expected behavior:
no errors

Actual behavior:
Error: Property 'name' does not exist on type 'T["params"]'.

If I remove Readonly or get rid of generic param T then everything will be ok.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions