TypeScript: Unexpected TS4094 with the build parameter `declaration: true`
TypeScript Version: 2.4.1
Code
var Foo = class Foo {
private _message = "Hi";
hi() { return this._message; }
}
tsc test.ts -t es2017 -d
Expected behavior: -d
should not cause this message: test.ts(1,5): error TS4094: Property '_message' of exported class expression may not be private or protected.
Actual behavior: It does.
There should at least be a suppression parameter to ignore this error.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 60
- Comments: 16 (4 by maintainers)
Commits related to this issue
- fix(tsc): add a temporary hack to ensure `tsc -d` works Bug reported https://github.com/Microsoft/TypeScript/issues/17293 — committed to tusharmath/ts-scheduler by tusharmath 5 years ago
- workaround https://github.com/Microsoft/TypeScript/issues/17293 — committed to matthewadams/typetrait by matthewadams 5 years ago
- Removes all protected due to bug in TS, fixes eslint issue [ Unexpected TS4094 with the build parameter declaration: true #17293 ](https://github.com/Microsoft/TypeScript/issues/17293) — committed to apparts-js/apparts-model by phuhl a year ago
Anyone knows if there has been any progress with this?
@weswigham Well, until it’s addressed, my workaround is to devolve back to using
_
(underscore) prefixes to indicate that a method is not public, which seems just dumb given TypeScript’s access modifiers. Further, traits/mixins are, IMHO, the best (read: most practical) way to achieve composability and avoid brittle inheritance hierarchies, which is why I feel that it would do all of us good to have this fixed sooner rather than later.Hmm, honestly we need a proposal for class expression type nodes. You could also argue that inline type aliases with expanded modifiers in anonymous types would also do the trick. We’ve talked about the first before, informally, but not actually tossed together a proposal yet, since the only two issues that seem to require that level of expressivity and precision are, well, patterns like this and other similar mixin-type patterns. It’s in the back of my mind, at least, if not a direct priority.