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

Failed to infer Type when using Union Types #86

Open
wh5938316 opened this issue Mar 23, 2022 · 0 comments
Open

Failed to infer Type when using Union Types #86

wh5938316 opened this issue Mar 23, 2022 · 0 comments

Comments

@wh5938316
Copy link
Contributor

What version of this package are you using?
0.11.0-canary.1
What operating system, Node.js, and npm version?
Macos Node16
What happened?
Failed to infer Type when using Union Types

import createStore from "teaful";

type TypeOne = {
  param1: string;
  param2: string;
};

export const { useStore } = createStore<TypeOne | Pick<TypeOne, "param1">>();

const Test = () => {
  const [test] = useStore({ param1: "hello" });
  // Error: Type Inference Failed
  if (test.param2) {
    return <div>{test.param2}</div>;
  }

  return <div>{test.param1}</div>;
};

export default Test;
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

1 participant