Skip to content

Readonly has issues with intersection types #21184

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
johnfn opened this issue Jan 15, 2018 · 1 comment
Closed

Readonly has issues with intersection types #21184

johnfn opened this issue Jan 15, 2018 · 1 comment
Labels
Fixed A PR has been merged for this issue

Comments

@johnfn
Copy link

johnfn commented Jan 15, 2018

TypeScript Version: 2.6.2

Code

class Foo<T, U> {
    thing(): Readonly<T> {
        return undefined as T;
    }

    erroringThing(): Readonly<T & U> {
        return undefined as T & U; // Type 'T & U' is not assignable to type 'Readonly<T & U>'.
    }
}

Expected behavior:
Both of these are error free.

Actual behavior:

Type 'T & U' is not assignable to type 'Readonly<T & U>'.

@mhegazy
Copy link
Contributor

mhegazy commented Jan 16, 2018

Should be fixed by #19564. give typescript@next a try.

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jan 16, 2018
@mhegazy mhegazy added this to the TypeScript 2.7 milestone Jan 16, 2018
@mhegazy mhegazy closed this as completed Jan 16, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

2 participants