Unexpected TS4094 with the build parameter `declaration: true`

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:56
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
emartinpicommented, Nov 6, 2018

Anyone knows if there has been any progress with this?

5reactions
matthewadamscommented, Aug 19, 2019

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript allows to use proper multiple inheritance with ...
My question is: Why does TypeScript allow me to build this, but then fails to create declaration files for this? export function TaggedMixin< ......
Read more >
TypeScript errors and how to fix them
When you are importing a module with built-in TypeScript declarations and TypeScript tells you that this module does not have a default export, ......
Read more >
Documentation - TypeScript 3.9
The function's types declare that it takes two string s so that other TypeScript users can get type-checking errors, but it also does...
Read more >
msw: Versions - Openbase
setupWorker: resolve the TS4094 error (#1477) ... handleRequest: bypass request only if "x-msw-bypass" header equals "true" (#1110) (1a7bc36) ...
Read more >
Errors and warnings for quick-lint-js
E0001: variable assigned before its declaration · E0002: assignment to const global ... E0158: unexpected '=>'; expected parameter for arrow function, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found