[X] 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 to index.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.
Bug Report Checklist
main
branch of the repository.Expected
npm run test:solutions
should pass in all projects, includingprojects/classes/the-shape-of-types
.Actual
Impacted Project
the-shape-of-types >
src/index.test.ts
Additional Info
When testing solutions, this happens:
solution.ts
is copied toindex.ts
index.test.ts
is rewritten to:tsc
At the end, the
Horror
class is known by TypeScript to be either the import fromindex
orsolution
. And becauseHorror
has#
privates, the two classes aren't assignable to each other.