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

TypeScript Error "Not all code paths return a value." #514

Closed
major-mayer opened this issue Sep 28, 2022 · 4 comments
Closed

TypeScript Error "Not all code paths return a value." #514

major-mayer opened this issue Sep 28, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@major-mayer
Copy link

Describe the bug
When running npm run check on my project that uses svelte-material-ui, the following error appears:

/path/to/my/project/node_modules/@smui/common/src/internal/dispatch.ts:1:17
Error: Not all code paths return a value. 
export function dispatch<T extends any = any>(
  element: Element,

To Reproduce
Steps to reproduce the behavior:

  1. Install a component that needs stuff from @smui/common
  2. Run npm run check

Expected behavior
No error should appear.

Screenshots
the error from above appears.

Desktop (please complete the following information):

  • OS: Linux
  • Browser Irrelevant since no error (yet) on runtime
  • Version Irrelavant

Additional context
Add any other context about the problem here.

@major-mayer major-mayer added the bug Something isn't working label Sep 28, 2022
@Cobrand
Copy link

Cobrand commented Oct 1, 2022

You also need compilerOptions.noImplicitReturns to be true in tsconfig.json.

Can be fixed by adding return undefined after line 29 of dispatch.ts, but I'm not sure whether or not this is the right fix.

@major-mayer
Copy link
Author

I created a small PR to fix this. Let's see if it gets accepted

@DetachHead
Copy link
Contributor

while it's probably a good idea to fix this, after some investigating i noticed that this is caused by typesVersions in the @smui/common package incorrectly pointing to the source code.

ideally your code should not be typechecking the function implementations in this package. see #532

@hperrin
Copy link
Owner

hperrin commented Apr 3, 2023

This is now fixed here: c551452#diff-54062c270ea651b890f69db1e1c4243b2c9033075870d648ab407cca159b67b7

@hperrin hperrin closed this as completed Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants