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

Static index signatures do not ensure consistency across index kinds within the same class #44082

Closed
weswigham opened this issue May 14, 2021 · 0 comments · Fixed by #44129
Closed
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@weswigham
Copy link
Member

⏯ Playground Link

Playground link

💻 Code

// non-static equivalent, for reference
class Q {
    readonly [s: string]: number;
    readonly [s: number]: 42 | 233
}

class W extends Q {
    readonly [s: string]: number
}

class EW extends W {
    readonly [s: string]: boolean
    readonly [s: number]: 1 
}

// static example
class B {
    static readonly [s: string]: number;
    static readonly [s: number]: 42 | 233
}

class D extends B {
    static readonly [s: string]: number
}

class ED extends D {
    static readonly [s: string]: boolean
    static readonly [s: number]: 1 // should error, 1 isn't assignable to `boolean`!
}

🙁 Actual behavior

No error.

🙂 Expected behavior

Numeric index type '1' is not assignable to string index type 'boolean'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants