We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
TypeScript Version: 3.9.0-dev.20200225
Search Terms: uninitialized not initialized class property in operator
Code
Looks like the same code that in JavaScript actually adds a non-static property to an instance, in TypeScript, however, does not.
class Thing { property; } const thing = new Thing(); console.log("property" in thing);
Expected behavior:
true
Actual behavior:
false
Playground Link: https://www.typescriptlang.org/play/?noImplicitAny=false&ts=3.9.0-dev.20200225#code/MYGwhgzhAEAqAWBLAdgc2gbwFAEgAOATgPZ4CmBALgJ4DcWAvllsEchBdBUmtALzTJSAdzjdUACgCUdZqwhEQpAHQgiEgESES5auugpOY6ViA
Related Issues: (none)
The text was updated successfully, but these errors were encountered:
Closed by accident :/
Sorry, something went wrong.
same code that in JavaScript actually adds a non-static property to an instance
Class properties in TS and JS (with class fields proposal) differs (at least at this moment #34787)
If you want to have JS behavior you should set useDefineForClassFields to true.
useDefineForClassFields
Seems like duplicate of #34787. Thanks @IllusionMH!
No branches or pull requests
TypeScript Version: 3.9.0-dev.20200225
Search Terms: uninitialized not initialized class property in operator
Code
Looks like the same code that in JavaScript actually adds a non-static property to an instance, in TypeScript, however, does not.
Expected behavior:
logs
true
Actual behavior:
logs
false
Playground Link: https://www.typescriptlang.org/play/?noImplicitAny=false&ts=3.9.0-dev.20200225#code/MYGwhgzhAEAqAWBLAdgc2gbwFAEgAOATgPZ4CmBALgJ4DcWAvllsEchBdBUmtALzTJSAdzjdUACgCUdZqwhEQpAHQgiEgESES5auugpOY6ViA
Related Issues: (none)
The text was updated successfully, but these errors were encountered: