Skip to content

fix(49546): 'Add missing properties' quick fix incorrectly handles symbol property #49554

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

Merged
merged 1 commit into from
Jun 20, 2022

Conversation

a-tarasyuk
Copy link
Contributor

Fixes #49546

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jun 15, 2022
@RyanCavanaugh
Copy link
Member

@typescript-bot pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 15, 2022

Heya @RyanCavanaugh, I've started to run the tarball bundle task on this PR at 1d34960. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 16, 2022

Hey @RyanCavanaugh, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/128212/artifacts?artifactName=tgz&fileId=D7F4F2303C5D667F727C1A1CA535BDF5BC882B8B64A693C5C252B62AEC164D1702&fileName=/typescript-4.8.0-insiders.20220615.tgz"
    }
}

and then running npm install.


There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/pr-build@4.8.0-pr-49554-2".;

@RyanCavanaugh
Copy link
Member

This is better than the current behavior but still defeatable

const m: unique symbol = Symbol();
interface T {
    [m]: string;
}
function fn(m: any) {
    let p: T = {
    //  ^ fix here tries to reference shadowed 'm'
    };
}

Is it more practical to disable the add missing members fix when the keys aren't literal-named?

@a-tarasyuk
Copy link
Contributor Author

const m: unique symbol = Symbol();
interface T {
   [m]: string;
   a: number;
   b: string;
}
[|let p: T = {};|]

@RyanCavanaugh If the type contains at least one computed property, QF should not be suggested. Am I right?

@RyanCavanaugh
Copy link
Member

I'm sort of on the fence, let me think about it more

@a-tarasyuk
Copy link
Contributor Author

@RyanCavanaugh I'm not sure what is the right way to resolve this edge case with naming collisions. We can skip computed properties and implement only known keys. Or we can try to find all the names in the current scope and try to rename something (not sure which name to rename) / or mark it as "unknown" key. Or completely skip QF. I think it depends on how often this case occurs.

@RyanCavanaugh
Copy link
Member

Eh, this seems unlikely to break in practice. Let's see how it goes.

@RyanCavanaugh RyanCavanaugh merged commit 74d76e9 into microsoft:main Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'Add missing properties' quick fix incorrectly handles symbol property
3 participants