Equivalent of "Package-Protected" for Typescript Testing?

typescript, unit-testing

Solution

Leave them `public` but name them as `_foo` (instead of `foo`).

More

This follows the convention in JavaScript land. TypeScript hasn't created any new concepts here

Problem

When doing testing in Java, I could use the package-protected access level to ensure proper encapsulation without making methods public. However, when testing Typescript, I have encountered several situations where I wish I could do a similar thing, as the method I am looking at seems sufficiently complex and is currently set as `private` or `protected`. What is the best practice for testing these types of functions? Should they just be made public for the purposes of testing, or is there an easier way?

Original source