gvergnaud / hotscript

A library of composable functions for the type-level! Transform your TypeScript types in any way you want using functions you already know.
3.38k stars 57 forks source link

Objects.Omit and Objects.Pick make all properties required #103

Open leobastiani opened 1 year ago

leobastiani commented 1 year ago

In version 1.0.11, Objects.Omit and Objects.Pick make all properties required. It also ignores readonly and make everything writable

https://codesandbox.io/s/typescript-playground-export-forked-5y6rtd

import { Pipe, Objects, Identity } from "hotscript";

type HasNoOptionals1 = Pipe<
//   ^?
  {
    readonly a: string;
    b: number;
    c?: boolean;
    d?: number;
  },
  [Objects.Omit<"a">]
>;

type HasNoOptionals2 = Pipe<
//   ^?
  {
    readonly a: string;
    b: number;
    c?: boolean;
    d?: number;
  },
  [Objects.Omit<"">]
>;

type HasNoOptionals3 = Pipe<
//   ^?
  {
    readonly a: string;
    b: number;
    c?: boolean;
    d?: number;
  },
  [Objects.Pick<"a" | "c">]
>;

type HasNoOptionals4 = Pipe<
//   ^?
  {
    readonly a: string;
    b: number;
    c?: boolean;
    d?: number;
  },
  [Objects.Pick<"a" | "b" | "c" | "d">]
>;

type WithIdentity = Pipe<
//   ^?
  {
    readonly a: string;
    b: number;
    c?: boolean;
    d?: number;
  },
  [Identity]
>;
Output ```ts export {}; ```
Compiler Options ```json { "compilerOptions": { "strict": true, "noImplicitAny": true, "strictNullChecks": true, "strictFunctionTypes": true, "strictPropertyInitialization": true, "strictBindCallApply": true, "noImplicitThis": true, "noImplicitReturns": true, "alwaysStrict": true, "esModuleInterop": true, "declaration": true, "target": "ES2017", "jsx": "react", "module": "ESNext", "moduleResolution": "node" } } ```

Playground Link: Provided