Skip to content

Failed to infer Type when using Union Types #86

Open
@wh5938316

Description

@wh5938316

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions