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

3.6.0 bug #80

Closed
steida opened this issue Apr 28, 2019 · 3 comments
Closed

3.6.0 bug #80

steida opened this issue Apr 28, 2019 · 3 comments
Assignees
Milestone

Comments

@steida
Copy link

steida commented Apr 28, 2019

I just updated and my code is broken. I extracted the problematic part.

interface NextLinkProps2 {
  prefetch?: boolean;
  shallow?: boolean;
  scroll?: boolean;
  replace?: boolean;
  onError?(error: any): void;
  href?: string;
  as?: string;
  passHref?: boolean;
  children: React.ReactElement;
}

type AppHref = {
    pathname: "/";
}

export type LinkProps = Assign<
  Overwrite<
    Omit<NextLinkProps2, 'passHref'>,
    {
      // Allow string etc.
      children: ReactNode;
      // Make href required and typed.
      href: AppHref;
    }
  >,
  {
    accessible?: boolean;
    download?: string;
    // style?: StyleProp<TextStyle>;
    // activeStyle?: StyleProp<TextStyle>;
    // We use it for manual focus.
    nativeID?: string;
  }
>;

const foo: LinkProps = { prefetch: true, href: { pathname: '/' } };
Type '{ prefetch: true; href: { pathname: "/"; }; }' is missing the following properties from type 'Pick<Pick<Pick<Pick<Omit<NextLinkProps2, "passHref">, "prefetch" | "shallow" | "scroll" | "replace" | "onError" | "as"> & Pick<{ children: ReactNode; href: { pathname: "/"; } | { pathname: "/me"; } | { ...; } | { ...; } | ({ ...; } & { ...; }); }, "href" | "children">, "prefetch" |
@piotrwitek
Copy link
Owner

Hey @steida
New Omit is not preserving an optional property modifier.

I'll fall back to my previous implementation to fix the issue.

Now the other problem is that the new Omit is a built-in TypeScript type coming in v3.5 which is apparently broken and I wonder if there is a bug filled for it.

@piotrwitek piotrwitek self-assigned this Apr 28, 2019
@piotrwitek piotrwitek added this to the v3.6.1 milestone Apr 28, 2019
@piotrwitek
Copy link
Owner

@steida Also there is a bug in your code snippet: Property 'children' is missing in type '{ prefetch: true; href: { pathname: "/"; }; }' but required

@piotrwitek
Copy link
Owner

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

2 participants