Use of #private forces Typescript users to target es2015 or later, use 3.8 or later
sandersn opened this issue · 3 comments
sandersn commented
Found on Definitely Typed, where kap-plugin depends on conf. By default, Definitely Typed tsconfigs use the default target, which is (still) es5. This fails since ES5 doesn't have WeakMap, which #private
emit depends on.
I would not personally use #private
in conf:
- It doesn't have any information it needs to hide from other code, it just needs to prevent mistaken accesses to its internal details.
- The emitted Javascript is super weird, using WeakMaps unless you target ESNext.
- If you do target ESNext, Firefox and Safari don't support
#private
. - Only Typescript 3.8 and above support
#private
at all.
I think Typescript-classic private
is the right choice.
sandersn commented
Another option is to ship multiple d.ts files using downlevel-dts, although I don't think the extra work is justified in this case.
sindresorhus commented
private
is useless in practice as the it's not enforced for non-TS users, which is the majority.- I'm fine with that.
- That doesn't matter.
conf
is for Node.js, not the browser. - I'm fine with that.
fbaldo31 commented
In 7.1.2 the issue is still there