镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Should getters still infer the same type from setters over their return expressions? #43414

Description

class C {
    #x = Promise.resolve("")

    set myValue(x: Promise<string> | string) {
        this.#x = Promise.resolve(x);
    }
    get myValue() {
        return this.#x;
    }
}

Should the get type of myValue be Promise<string> or just string | Promise<string>? Right now it is the latter; but technically, the former provides a more specific type.

Changing this technically would be a breaking change.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions