Skip to content

Conversation

@hanzhangyu
Copy link
Contributor

Example

var A: {a?: number, b: number} = {b:2}
Reflect.defineProperty(A, 'a', {
  // set(this: any, value: any) { // to fix
  set(value: any) {
    console.log(this.b); // Property 'b' does not exist on type 'PropertyDescriptor'.
  },
  enumerable: true,
  configurable: true
});
A.a = 1;

Fixes

#33542

@RyanCavanaugh
Copy link
Member

This is not a good fix - just setting this to any is basically introducing an implicit any into the snippet.

@RyanCavanaugh
Copy link
Member

Author pointed out that this: any is exactly what we do for Object.defineProperty, so at worse this is simply consistent with that

@sandersn sandersn added the For Backlog Bug PRs that fix a backlog bug label Feb 1, 2020
@sandersn sandersn self-assigned this Mar 10, 2020
@sandersn sandersn requested review from orta and sandersn March 10, 2020 21:06
@typescript-bot typescript-bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug and removed For Backlog Bug PRs that fix a backlog bug labels Mar 3, 2022
@typescript-bot
Copy link
Collaborator

This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@sandersn sandersn merged commit 0a24dee into microsoft:main Mar 3, 2022
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants