Skip to content

Rename Symbol(F2) failed to rename the value in switch statement when operate on union of string literalΒ #44720

@whzx5byb

Description

@whzx5byb

Bug Report

πŸ”Ž Search Terms

rename symbol string literal union
Similar to #44701

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type State = 'not-ready' | 'ready';
//                            ^
//                          put the cursor here, press F2 and rename `ready` to `ok`.
class A {
    state: State = 'not-ready';

    update() {
        switch (this.state) {
            case 'ready':
        }
    }
}

πŸ™ Actual behavior

type State = 'not-ready' | 'ok';
class A {
    state: State = 'not-ready';

    update() {
        switch (this.state) {
            case 'ready':
            // Type '"ready"' is not comparable to type 'State'.(2678)
        }
    }
}

πŸ™‚ Expected behavior

type State = 'not-ready' | 'ok';
class A {
    state: State = 'not-ready';

    update() {
        switch (this.state) {
            case 'ok':
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions