Closed
Description
Bug Report Checklist
- I have tried restarting my IDE and the issue persists.
- I have pulled the latest
main
branch of the repository. - I have searched for related issues and found none that matched my issue.
- This is the appropriate issue form for the bug I would like to report.
Expected
npm run test:solutions
should pass in all projects, including projects/classes/the-shape-of-types
.
Actual
Argument of type 'MockHorror' is not assignable to parameter of type 'Horror & Horror'.
Type 'MockHorror' is missing the following properties from type 'Horror': #consumed, #consume, doBattle, getPowerts(2345)
Impacted Project
the-shape-of-types > src/index.test.ts
Additional Info
When testing solutions, this happens:
solution.ts
is copied toindex.ts
- The top of
index.test.ts
is rewritten to:const { Demon, Horror, Sorcerer } = process.env.TEST_SOLUTIONS ? index : // In theory, it would be nice to not have to apply this cast // In practice, TypeScript's structural typing does not play well with # privates // See https://github.com/LearningTypeScript/projects/issues/183 (index as unknown as typeof solution);
tsc
At the end, the Horror
class is known by TypeScript to be either the import from index
or solution
. And because Horror
has #
privates, the two classes aren't assignable to each other.