Home
Blogs
Questions
Jobs
Monetize

Home

About Us

Blogs

Questions

Jobs

Monetize

Post Job

banner

Questions about keyof

Read more about keyof

python (12.9k questions)

javascript (9.2k questions)

reactjs (4.7k questions)

java (4.2k questions)

java (4.2k questions)

c# (3.5k questions)

c# (3.5k questions)

html (3.3k questions)

Questions - keyof

How to change the interface key: value: string to [{ [key: string]: string }

I have interface IUser { name: string; surname: string; cityLocation: string; } the value will be const user: IUser = { "name": "John"; "surname": "Smith&...
test-img

Jackson

string

typescript

interface

signature

keyof

Votes: 0

Answers: 1

Latest Answer

As the error says, Index signature is missing in type 'IUser' so add it: interface IUser { name: string; surname: string; cityLocation: string; [key: string]: string; } Playground link
test-img

Jamiec

Get string literal types from Array of objects

So from: export interface Category{ val: string; icon: string } const categoryArray: Category[] = [ { val: 'business', icon: 'store' }, { val: 'media', icon: 'video' }, {...
test-img

TrySpace

typescript

typeof

union-types

keyof

Votes: 0

Answers: 1

Latest Answer

You can do it if: The values in the array don't change at runtime (since type information is a compile-time-only thing with TypeScript); and You tell TypeScript that they values won't change by usin...
test-img

T.J. Crowder

Posts

Questions

Blogs

Jobs

The ultimate platform for coders and IT specialists

About

  • Company
  • Support

  • Platform

  • Terms & Conditions
  • Privacy statement
  • Cookie policy
  • Cookie option
  • OnlyCoders © 2025  |  All rights reserved