Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exercise 10 event dispatcher type check errors #7

Open
isimmons opened this issue Aug 10, 2023 · 3 comments
Open

exercise 10 event dispatcher type check errors #7

isimmons opened this issue Aug 10, 2023 · 3 comments

Comments

@isimmons
Copy link

Both in the stackblitz in the course and on my local machine with the run exercise command, the tests pass but then type checking has the following error

Checking types...
src/02-globals/10-event-dispatcher.problem.1.ts:34:19 - error TS2322: Type '"LOG_OUT"' is not assignable to type '"LOG_IN"'.

34   dispatchEvent({ type: 'LOG_OUT' });
                     ~~~~

  src/02-globals/10-event-dispatcher.problem.1.ts:22:7
    22       type: K;
             ~~~~
    The expected type comes from property 'type' which is declared here on type '{ type: "LOG_IN"; } 
& { username: string; password: string; }'

I copied the LOG_OUT event over to problem file 1 and this fixed the problem.

But then I renamed problem file 2 to 10.1 and ran npm run exercise 10.1 and it can't find UnionOfDispatchableEvents

So I'm guessing this is because a single file is being type checked in isolation so in file 1 there is no 'LOG_OUT' and in file 2 there is no UnionOfDispatchableEvents. Is that right?

@freiondrej-lokalise
Copy link
Contributor

Hello, I have the same problem 🙏

@boltex
Copy link

boltex commented Nov 24, 2023

@isimmons @freiondrej-lokalise I also got that strange behavior, although I've completed the exercise and verified it's exactly how the solution proposes the fix should be done.

I made sure to also re-save the file '10-event-dispatcher.problem.1' to force a recompile/recheck but it still gives the type error, although the '10-event-dispatcher.problem.2' file is exactly as per the solution given by Matt. But I'm also getting this typing error in the console.

image

@prurph
Copy link

prurph commented Sep 6, 2024

+1. The tests in the solution files do not actually pass. If you replace the problem files with the content of the solution files the tests fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants