Skip to content

You've Got a Type in Me πŸš€

Compare
Choose a tag to compare
@nicoespeon nicoespeon released this 15 Jun 10:33
· 121 commits to main since this release

Added

  • "Extract Type" can now extract type literals. This is particularly handy when you have such a union type:
type Context =
  | { state: "reading"; value: string }
  | {
      state: "editing";
      value: string;
      draftValue: string;
    };

Put your cursor wherever within { state: "reading"; value: string }, hit Ctrl+Shift+V (⌘ ⇧ V) and there you have it:

type ReadingContext = { state: "reading"; value: string };

type Context =
  | ReadingContext
  | {
      state: "editing";
      value: string;
      draftValue: string;
    };

The ReadingContext name was inferred, it it can be. In any case, you are in "rename mode" right away so you can type whatever is better, press Enter, be done.

In action:

extract.types.mp4