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

Typescript: Generating output type from schema is needed. #2

Open
saehun opened this issue May 6, 2020 · 1 comment
Open

Typescript: Generating output type from schema is needed. #2

saehun opened this issue May 6, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@saehun
Copy link
Owner

saehun commented May 6, 2020

No description provided.

@saehun saehun added the enhancement New feature or request label May 6, 2020
@saehun
Copy link
Owner Author

saehun commented May 15, 2020

const fn = <B extends (string | boolean | number), A extends Record<string, { type: B }>>(obj: A): Record<keyof A, B> => {
  const ret: any = {};
  for (const key in obj) {
    ret[key] = obj[key].type;
  }
  return ret;
};

const result = fn({
  "key1": { type: "" },
  "key2": { type: 0 },
  "key3": { type: false },
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant