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

Already on GitHub? Sign in to your account

Property not found on index accessed type in a union #21464

Closed
sandersn opened this issue Jan 29, 2018 · 3 comments
Closed

Property not found on index accessed type in a union #21464

sandersn opened this issue Jan 29, 2018 · 3 comments
Labels
Duplicate An existing issue was already created
Milestone

Comments

@sandersn
Copy link
Member

interface I {
    [key: string]: I
    (...args: any[]): I
}

declare let y: string | I
y.toUpperCase() // Error

Expected: No error: both string and I separately allow property access of toUpperCase.

Actual: Error, "Property 'toUpperCase' does not exist on type 'I'.

@ahejlsberg
Copy link
Member

ahejlsberg commented Jan 30, 2018

Less confusing repro:

interface A {
    a: string;
}
interface I {
    [key: string]: number;
}

declare let y: A | I
y.a;  // Got error, expected string | number

@mhegazy mhegazy added the Bug A bug in TypeScript label Jan 30, 2018
@mhegazy mhegazy added this to the TypeScript 2.9 milestone Apr 13, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Jul 2, 2018

Looks like a duplicate of #21141

@mhegazy mhegazy added Duplicate An existing issue was already created and removed Bug A bug in TypeScript labels Jul 2, 2018
@mhegazy mhegazy modified the milestones: TypeScript 3.0, Future Jul 2, 2018
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants