Category "typescript"

Pick only two properties from a type in Typescript

I need to pick only two properties whose names are not yet defined from a type, and create a new type from there with one of these properties required and anoth

TypeScript: Extract then Omit from union

Let's say I have a Vehicle union type that looks like that: interface Car { color: string; doors: number; wheels: number; } interface Plane { color: st

Type 'string' cannot be used to index type 'T'

I am wondering what the correct way is to type this? I have tried quite a few ideas and can't make it happy. I have tried <T extends object> (same error)

How can I write an adapter for my React Final Form component with Typescript?

I need to write an adapter for a component, to which I need to pass certain props. For example, I have a component which can receive certain props as "disabled"

How to specify multiple principals in a policy document AWS CDK

I am working on cdk script and I want to specify multiple principals such as "Principal": { "AWS": [ "arn:aws:iam::AWS-account-ID:user/user-name-1",

How to do cartesian product with TypeScript?

Here's the type signature that I'm after: function cartesianProduct<T1, T2, T3, T4, T5, T6, T7, T8>([c1, c2, c3, c4, c5, c6, c7, c8]: [T1[], T2[], T3[], T

Typescript: How can I cast a variable as an element of an array?

Array: const myStrings = ["one", "two", "three"]; const newString = "two"; newString will simply be of type string, but I want the type to be something like e

Base Class extended Incorrectly

Hey I am using Deno and extending EventTarget class but I don't want the end user to be able to get functions which exist on EventTarget class like addEventList

Angular error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays

I'm making a get to an API in my Angular project and I get this JSON: { "data": { "success": true, "historical": true, "date": "2022-01-01", "

TypeScript how to call function with its name

I am new to typescript, when I type: (dialog is imported from a library) ipcMain.handle("openDialog", (event, method, config) => { return dialog[method](wi

Retrieving images from json server and display with relevant question

I am building a trivia app. initially I just implemented plain text Q&A trivia but now I also want to add images with questions. I am getting data from my l

Typescript auto generated JS file: "Uncaught TypeError: Failed to resolve module specifier"

Currently working on a Blazor project where I want advanced mapping functionality, using the Leaflet.js library with typescript bindings. I have added leaflet a

Express + Typescript: How to GET Param and Body request

I route put method to this const createFaceList = (req: Request<{faceListId : string}>, res: Response, next: NextFunction) => { console.log(req.body.n

Cannot add object with composite key to IndexedDB objectStore. Key already exists in the object store. When only one entry is the same

I have an objectStore with the following key: When I add an object with the same productId, but different shopName transaction reports the error: ConstraintErr

use the same key in both render and main process electron?

I am recently learning electron I have encountered a problem that I want to listen ESC in both process, In Main process, menu.append(new MenuItem({ label: "

How to solve: Type error: 'Draggable' cannot be used as a JSX component ? (react-draggable)

I get this error while building this Next.js React project Type error: 'Draggable' cannot be used as a JSX component. Its instance type 'Draggable' is not a

What is a return type of a `use` directive?

After reading svelte tutorial I noticed that clickOutside function returns an object with a destroy method. What would be the correct return type of a custom us

Nextjs getserversideProps renders without changing meta data from query parameter

I am trying to load query parameters using getServerSideProps to insert Head meta tag based on the parameters response from API request. Currently, the below co

Override variable type from external library

I am using a third party library for my react application. There are some incorrect/outdated types. Let's say the library has the following type declarations: d

Why do Ionic Lifecycle hooks (ionViewWillEnter, ionViewWillLeave) not fire when used as HTML Selector?

I am working on an Angular Project, with Ionic 4. When Child Page is called from Parent Page's HTML using HTML Selector, child page's Ionic Lifecycle Hooks do n