Skip to content

Fix issue with ambient property declaration following property assignment in JS #52323

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

Closed
wants to merge 6 commits into from

Conversation

DanielRosenwasser
Copy link
Member

Everyone is trying to fix #51521, so I guess I am too.

This PR tries to fix #51521. It does so by fixing setValueDeclaration to defer to property declarations over "assignment declarations" - even in the case of ambients. In the case of code like in the following .js file:

class C {
  constructor() {
    this.foo = 10;
  }
  declare foo: number;
}

We'll encounter the this.foo = 10 assignment first, then encounter declare foo: number;.

Even though declare foo: number is marked as ambient, it is arguably a better value declaration than the JavaScript one.

Semantic Diagnostics for file '/tests/cases/fourslash/quickInfoAndSemanticsOnJsPropertyWithAmbientDeclaration.ts':


==== /test.js (0 errors) ====
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait. This is wrong.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that the errors don't come up consistently, and that baselining doesn't give the same error results, is very suspicious.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. All tests I've had for this have not been compiler tests.

@DanielRosenwasser DanielRosenwasser changed the title Fix issue with Fix issue with ambient property declaration following property assignment in JS Jan 20, 2023
@Andarist
Copy link
Contributor

Andarist commented Jan 20, 2023

Everyone is trying to fix #51521, so I guess I am too.

And now I have FOMO...

@DanielRosenwasser
Copy link
Member Author

I am sure you can find something that looks broken with our JavaScript support.

@DanielRosenwasser
Copy link
Member Author

Looks like @a-tarasyuk's PR makes a fix in the same place.

@DanielRosenwasser DanielRosenwasser deleted the fixDebugAssert51521 branch January 20, 2023 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using a of property declared after an initializing constructor triggers an assertion failure in JS
3 participants