-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
TypeScript Version: 3.5.1
Search Terms:
Code
File ./index.ts
class MyPrivateClass {}
File ./test.ts
const x = new MyPrivateClass()
File ./tsconfig.json
{
"compilerOptions": {
"target": "es2015",
"module": "commonjs",
"strict": true,
}
}
Command
tsc
Expected behavior:
TypeScript compiler should report an error in ./test.ts
that MyPrivateClass
is not visible.
Actual behavior:
TypeScript doesn't report any error and generates invalid ./test.js
and ./index.js
files. For example, node ./test.js
are failing with this issue:
const x = new MyPrivateClass();
^
ReferenceError: MyPrivateClass is not defined
at Object.<anonymous> (C:\github.com\ts-common\visibility-test\test.js:2:11)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
Playground Link: No playground link because we need two files but here's GitHub repository https://github.com/ts-common/visibility-test/tree/d3c03a1cd4641da1bd1356e751e2cea10ea91025
Related Issues: I couldn't find any.
Note:
TypeScript compiler will give a compilation error only if the class is exporter:
export class MyPrivateClass {}
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code