Skip to content

A computed property name in an interface must directly refer to a built-in symbol #13190

Closed
@nbransby

Description

@nbransby

TypeScript Version: 2.1

When will TypeScript be able to type check this:

const location = Symbol("Quick reply location")
const onText = Symbol("Text message responder")
const onLocation = Symbol("Location message responder")
const onImage = Symbol("Image message responder")

interface ResponseHandler {
    [quickReply: string]: () => void
    [location](lat: number, long: number): void
    [onText](text: string): void;
    [onLocation](lat: number, long: number): void;
    [onImage](url: string): void;
}

What I would like it to do is verify the methods defined on an object conforming to this interface have the right parameters based on the property symbol / type (in case of string)

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