Questions tagged [typescript]

TypeScript is a typed superset of JavaScript that transpiles to plain JavaScript. It adds optional types, classes, interfaces, and modules to JavaScript. This tag is for questions specific to TypeScript. It is not used for general JavaScript questions.

186,609 questions
0votes
0answers
11views

Typescript should I use void or never on the optional object type property

I have defined a type, T1 and T2. The purpose of this the union type of these two is when you have a in the object, you cannot have b, and when you have b in the object, you cannot have a, like the ...
  • 638
0votes
0answers
7views

Extended TypeScript interface properties are not included in imported module

I have a custom module in which I have an interface for props and it is extending props from a /types/SharedProps.d.ts file. When I import the module into an example project, the component does not ...
0votes
0answers
9views

Typescript interface merging to make an external lib's interface property more specific

I am using a function from an external library that returns an object where there is a particular property that is typed as number, but since it operates on my data, I know it is in fact just an union ...
  • 24.8k
0votes
0answers
24views

Storybook is not loading styles with styled components

I recently added storybook to my React project with Typescript. I have a MUI custom button with styled components in a CustomButtons file: export const ButtonOk = styled(Button)` width: 132px; ...
1vote
0answers
23views

how to set coordinates (x,y) for each id inside the tree

I have this array (of connections from ID to another): const connectionsArr = [ { sourceId: 1, targetId: 2 }, { sourceId: 1, targetId: 9 }, { sourceId: 9, targetId: 3 }, { sourceId: 3, ...
0votes
2answers
21views

Get data from firestore document and use in cloud function

In the user's collection, each user has a document with a customer_id. I would like to retrieve this customer_id and use it to create a setup intent. The following code has worked for me in the past. ...
-1votes
0answers
16views

Challenge Question in writing a program code please answer [closed]

A bank has the following rule: if a customer has more than $1000 dollars in their checking account or more than $1500 dollars in their saving account, then there is no service charge of writing checks....
0votes
1answer
18views

Firebase custom claims returns Object is possibly 'undefined'

I am trying to read the user's custom claims and I would like to return the values of the claims to the client individually. This code has worked for months. However, all of a sudden it returns the ...
0votes
0answers
11views

DiscordAPIError[50035]: Invalid Form Body 0.name[BASE_TYPE_REQUIRED]: This field is required 1.name[BASE_TYPE_REQUIRED]: This field is required

while creating a slash command builder for a help command, it does not gets registered and gives the following error - DiscordAPIError[50035]: Invalid Form Body 0.name[BASE_TYPE_REQUIRED]: This ...
0votes
0answers
10views

Having trouble with Charts.js colors

A friend helped me get Charts.js working and I'm now trying to mentally reverse engineer what he's done that works for displaying the data to make the data display how I'd like. There's typically 8-10 ...
0votes
1answer
15views

Mapped type in TS doesn't return nested type

I have this sort of type : type Schema = { name: { type: string } age: { type: number } } I would like to have a type which flatten it. I expect this: type MyType<Schema> = { ...
  • 1,228
0votes
1answer
20views

I have two ngIf conditions. How I can make them an ngIf else?

I have two <div> with *ngIf. They are kind of large, so I am having trouble implementing an *ngIf else while reading the documentation, because I am unsure where to put so much content. I have ...
0votes
0answers
11views

React app refuses to import from package that was installed from filesystem

I am trying to build a monorepo with a separate shared package (written in typescript) and client package (initially generated using create-react-app --template typescript) In shared I define types ...
0votes
0answers
18views

Angular Form Array - Dynamically Add Value to Nested Form Group

I followed the this video to create a reactive form to input data into an Angular application I am working on. It does what I want for the most part, however, I have added an additional control("...
1vote
2answers
24views

Wildcard return type in Typescript where objects that implement an interface are returned

I have the following interface that I use in an abstract base class: interface MyInterface { field1: string } abstract class BaseClass { abstract serialize(): Array<...

153050per page