Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spread operator doesn't remove readonly from object properties #58071

Closed
Perfectoff opened this issue Apr 4, 2024 · 3 comments
Closed

Spread operator doesn't remove readonly from object properties #58071

Perfectoff opened this issue Apr 4, 2024 · 3 comments
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@Perfectoff
Copy link

Perfectoff commented Apr 4, 2024

馃攷 Search Terms

spread remove readonly

馃晽 Version & Regression Information

馃捇 Code

    interface ReadOnlyData {
       readonly value: string;
    }
    let data: ReadOnlyData = { value:'foo' }
    
    let copyOfData = {...data};
    
    copyOfData.value = 'bar';   // Error: Attempt to assign to const or readonly variable

馃檨 Actual behavior

error: Attempt to assign to const or readonly variable

馃檪 Expected behavior

the copy should be writeable

Additional information about the issue

This bug was fixed many years ago ( #15036), but it exists again in current versions of the language.

@Andarist
Copy link
Contributor

Andarist commented Apr 4, 2024

This doesn't error though: TS playground

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Apr 4, 2024
@RyanCavanaugh
Copy link
Member

I'm not seeing the error either

@Perfectoff
Copy link
Author

ok, sorry, it was just a problem with some syntax plugin in my IDE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

3 participants