Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

210
Views
How do I convert a type but replacing every value in the type

Just a new developer entering the typescript world. This may kinda seem not that all hard but I can't seem to find any solutions about this issue from google nor stack overflow itsself.

How do I convert/cast typescript type from

type UsersSelect = {
    id: boolean
    created_at: boolean
    username: boolean
    discriminator: boolean
    activityMessage: boolean
    activityStatus: boolean
    userid: boolean
    lastseen: boolean
    themeId: boolean
    badges: boolean
    bannerColor: boolean
    friends: boolean
  }

to

type UsersSelect = {
  id: {
    public: true,
    private: true,
  },
  created_at: {
    public: true,
    private: true,
  },
  username: {
    public: true,
    private: true,
  },
  discriminator: {
    public: true,
    private: true,
  },
  activityMessage: {
    public: true,
    private: true,
  },
  userid: {
    public: false,
    private: true,
  },
  activityStatus: {
    public: true,
    private: true,
  },
  badges: {
    public: true,
    private: true,
  },
  bannerColor: {
    public: true,
    private: true,
  },
  friends: {
    public: false,
    private: true,
  },
  lastseen: {
    public: true,
    private: true,
  },
  themeId: {
    public: false,
    private: true,
  },
};

I tried few possible solutions but all didn't seem to work.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Here's how you do that. You take all the keys of the first type and create a Record type with a new value type ({public: true, private: true}).

type UsersSelectConverted = Record<keyof UsersSelect, {public: true, private: true}>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!