Skip to content

Instantly share code, notes, and snippets.

@pffigueiredo
Last active February 7, 2023 15:23
Show Gist options
  • Select an option

  • Save pffigueiredo/33e920d30e602a4aa94e4c9f5063e766 to your computer and use it in GitHub Desktop.

Select an option

Save pffigueiredo/33e920d30e602a4aa94e4c9f5063e766 to your computer and use it in GitHub Desktop.

Revisions

  1. pffigueiredo revised this gist Feb 7, 2023. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion prettify.ts
    Original file line number Diff line number Diff line change
    @@ -3,4 +3,7 @@ type Prettify<T> = {[K in keyof T]: T[K]} & {};

    // autocomplete that also accepts string
    // so you still have intellisense but it's open to any string
    type AutoComplete<T extends string> = T | (string & {});
    type AutoComplete<T extends string> = T | (string & {});

    // the value of objects
    type ValueOf<T extends object> = T[keyof T];
  2. pffigueiredo revised this gist Feb 7, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions prettify.ts
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,5 @@
    type Prettify<T> = {[K in keyof T]: T[K]} & {};

    // autocomplete that also accepts string
    // so you still have intellisense but it's open to any string
    type AutoComplete<T extends string> = T | (string & {});
  3. pffigueiredo created this gist Feb 7, 2023.
    5 changes: 5 additions & 0 deletions prettify.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    // prettify intersection on types, like `a & b & c`
    type Prettify<T> = {[K in keyof T]: T[K]} & {};

    // autocomplete that also accepts string
    type AutoComplete<T extends string> = T | (string & {});