Skip to content

add enforceReadonlyAssignability flag for smoother transition to true readonly modifiers #13002

Closed
@zpdDG4gta8XKpMCd

Description

@zpdDG4gta8XKpMCd

this can be seen in the nightly build as of Dec 17 (as well as at playground)

interface ReadOnlyData {
    readonly value: number;
}

interface WritableData {
    value: number;
}

function erase(data: WritableData): void {
    data.value = 0;
}

const readOnly: ReadOnlyData = { value: 1 };

erase(readOnly); // expected a type error, actual: no problem

this can't be serious, can it?
why is it called readonly?

please note there are no type assertions or any other attempts to trick the type system, it just simply doesn't work

50+ errors left uncaught

UPDATE


constructive discussion starts here: #13002 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions