Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
1 vote
1 answer
32 views

Extract Generic Interface or Type keys as an Array [duplicate]

I want to know if it's possible to get a generic interface or type and get it's properties like an array of objects, like this: interface UserData { email: string } keys = extractKeys<UserData&...
João Pedro's user avatar
-3 votes
1 answer
71 views

How do interfaces in Go work when implementing functions with parameters/return values of a generalised type? [closed]

I'm new to Go and a bit confused in how interfaces work when implemented, especially wrt. functions that have parameters. Say I have an interface with function foo that takes in an interface: type I ...
Namit Deb's user avatar
1 vote
0 answers
37 views

Angular typescript >> Type vs Interface [duplicate]

I encountered an error Type 'PaginationParams' is not assignable to type 'HttpParams | { [param: string]: string | number | boolean | readonly (string | number | boolean)[]; } | undefined'. Type '...
Fu Chang's user avatar
0 votes
0 answers
37 views

How to write generic type for types extraction in Typescript

I am trying to extract types based on input type. My code is: type ArrayElement<T> = T extends Array<infer U> ? U : never; interface Field { key: string; value: number | string; ...
BananaBoy's user avatar
0 votes
0 answers
29 views

How does variance work when implementing interfaces/type aliases in TypeScript?

I have the following types : interface Config { configurable: boolean; cancelable: boolean; isUnique: boolean; } // Config Subtype interface EnvironmentConfig extends Config { runtime:...
Grizzly's user avatar
  • 385
0 votes
0 answers
24 views

Typescript: Declare interface with all optional indices accessible by "indexing into"

I want to create an interface that has all the CSS properties as possible indices but it could have none, and I want to "index into" it. This would be ideal but it is not working: declare ...
HighHopes's user avatar
  • 2,082
0 votes
1 answer
26 views

How to manage multi-options for interface field?

I have an interface: export interface StyledTableProps { $gridTemplateColumns: | Array<{ min: string; max: string; }> | { ...
pro-frontend's user avatar
1 vote
2 answers
53 views

How to say to typescript: "this two keys on that interface must have the same type"?

First, I created it: interface SomeInterface{ param1: unknown callback: (body: unknown)=>void } look basic, right? but I need something a little bit more specific... what I need is a way to ...
Leonardo kop's user avatar
1 vote
0 answers
126 views

Type 'keyof T' cannot be used to index type 'this'

IUser interface: interface IUser { username: string; email: string; crypto: string; } Class User: class User implements IUser { private crypto$: string; constructor(public username: string, ...
Achraf FAWZI's user avatar
0 votes
0 answers
83 views

How can you share Typescript types and JSON schemas between micro-service code repos?

If you have multiple code repositories that rely on shared data types, and you want to ensure each repository stays in sync with each other, what are some of the best options to ensure that you're not ...
LogicMia's user avatar
0 votes
1 answer
82 views

Is there a good way to make number type fit "method.Call" in golang?

Code Go Playground : package main import ( "fmt" "reflect" ) func (s StructWithManyMethods) Func1(a int, b uint, c float64) { fmt.Printf("func:Func1 a:%d b:%d c:%...
kuokongqingyun's user avatar
2 votes
1 answer
241 views

Typescript get properties of Parent interface from Child interface [duplicate]

very simple question.. yet I dont know. I have following example from code interface A { a:string; } interface B extends A{ b:string; } const b:B = { a:'a', b:'b' } const a:A = ...
StykPohlavsson's user avatar
1 vote
0 answers
33 views

Is there a way in TypeScript to have an interface with optional fields that can only be set together? [duplicate]

How can I write a TypeScript interface along the lines of the following: type FavoriteColorDescription = | { color: "Red" | "Blue"; ...
NitzanPap's user avatar
0 votes
2 answers
42 views

Is it necessary to define type again in useState if an interface is already used?

Consider this code: IAppStateProps.ts: import {INoteProps} from "./INoteProps"; export interface IAppStateProps { notesData: INoteProps[]; } then use it here: useAppState.ts: import {...
one-hand-octopus's user avatar
0 votes
0 answers
36 views

How do I enforce a maximum depth and value requirements for a multi-dimensional object containing objects and arrays of primitive (only) values?

Introduction: I have a multi-dimension object in a TypeScript file, that would look something like this: const store = { key_1: "value", key_2: 123, key_3: true, key_4: { key_4_1:...
Malekai's user avatar
  • 4,893

15 30 50 per page
1
2 3 4 5
34