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

Rename Symbol on variable sourcing a return destructured object leads to compiler error #19173

Closed
mjbvz opened this issue Oct 13, 2017 · 3 comments
Labels
Bug A bug in TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Milestone

Comments

@mjbvz
Copy link
Contributor

mjbvz commented Oct 13, 2017

From @greyepoxy on October 13, 2017 22:33

  • VSCode Version: Code 1.17.1 (1e9d36539b0ae51ac09b9d4673ebea4e447e5353, 2017-10-10T14:24:50.851Z)
  • OS Version: Windows_NT x64 10.0.14393
  • Typescript: 2.5.3

Steps to Reproduce:

  1. I have the following typescript code
interface Result {
    a: number;
}

export function doThing(): Result {
    const a = 5 + 10;

    return {
        a
    };
}
  1. Highlight a at its declaration in const a
  2. Hit F2 and rename the symbol to b

Expected:

  1. A symbol rename to not lead to a compiler error
  2. Something like the following:
export function doThing(): Result {
    const b = 5 + 10;

    return {
        a: b
    };
}

Actual:

export function doThing(): Result {
    const b = 5 + 10;

    return {
        b // <-- this has the error below
    };
}

severity: 'Error'
message: 'Type '{ b: number; }' is not assignable to type 'Result'.
Object literal may only specify known properties, and 'b' does not exist in type 'Result'.'

Reproduces without extensions: Yes

Copied from original issue: microsoft/vscode#36252

@mjbvz
Copy link
Contributor Author

mjbvz commented Oct 13, 2017

Possibly another case of #15787

@mhegazy mhegazy assigned ghost Oct 16, 2017
@mhegazy mhegazy added this to the Future milestone Oct 16, 2017
@mhegazy mhegazy added the Bug A bug in TypeScript label Oct 16, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Oct 16, 2017

Also another case of #14039

@mjbvz
Copy link
Contributor Author

mjbvz commented Jan 28, 2020

The safe rename is now the default (a way to revert to the old, unsafe behavior was added by #29238)

@mjbvz mjbvz closed this as completed Jan 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

2 participants