Assertion Functions cannot assert over private properties - unnecessary/wrong error message? #47778
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Domain: Error Messages
The issue relates to error messaging
Suggestion
An idea for TypeScript
Uh oh!
There was an error while loading. Please reload this page.
Assertion Function "Private identifiers are not allowed outside class bodies."
Bug Report
🔎 Search Terms
assertion function, asserts, #, private members, Private identifiers are not allowed outside class bodies.
🕗 Version & Regression Information
This happens in 4.0.5, 4.4.3, 4.5.4 and the latest nightlies - so probably in all TS versions that support assertion functions and private class members.
⏯ Playground Link
A playground showcasing the problem
💻 Code
🙁 Actual behavior
The code above works 100% as expected (the assertion function also narrows the type of
this.#ready
down totrue
correctly), but TS displays an error message:🙂 Expected behavior
The error message should be removed - this seems to work absolutely fine as it is. The error message seems to be a red herring.
The text was updated successfully, but these errors were encountered: