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

Questions tagged [typescript]

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

0 votes
1 answer
13 views

How to make React-Email & Resend work with Firebase Cloud Functions

I have a Nextjs app that utilizes both React-Email, Resend & Firebase Cloud Functions. The directory structure looks like this: I want to send an email to a user whenever a doc is created in &...
47 votes
9 answers
70k views

Passing class method as parameter in Typescript

I'm searching for a possibility to pass a class-method to a function which then can execute that function on an instance of that class. Something like that pseudocode: (note that this is an abstract ...
0 votes
1 answer
50 views

After invalid ASP.NET MVC server login, how can I capture the error text in the returned Json response and display in the Angular client?

Angular 9 Client login page I want to display the specific returned error message in the <h4> element, instead of the generic message that displays currently. Note: I have updated the page with ...
0 votes
0 answers
23 views

Distributive on generic types

How does TS perform Omit on generic types? type DistributiveOmit<T, K extends keyof any> = T extends any ? Omit<T, K> : never; type Data = { v: { k: 1 } } function P<T extends Data>(...
0 votes
0 answers
7 views

Issue with Drag and Drop Elements using react-dnd in React

I am using the react-dnd library to implement a drag-and-drop feature for tasks between columns in a React application. I encountered an issue where dragging tasks behaves incorrectly: Problem on the ...
15 votes
2 answers
11k views

Webpack-dev-server "Cannot GET /"

i'm trying to get my webpack-dev-server to run but i face always the error "Cannot Get /" at the browser. I know that there are serveral questions with the same error, but none of them ...
143 votes
2 answers
38k views

What are the differences between the private keyword and private fields in TypeScript?

In TypeScript 3.8+, what are the differences between using the private keyword to mark a member private: class PrivateKeywordClass { private value = 1; } And using the # private fields proposed ...
0 votes
1 answer
19 views

How to write a test against randomly selected values from a collection?

I have a function which selects a random value from an array to be returned: export function selectMovieUnderDuration(options: IStreamRequest, movies: Movie[], prevMovies: Movie[], duration: number): ...
2 votes
1 answer
7k views

Insert data into postgreSQL using nodejs typescript

My code looks like this signup.post('/signup', urlendcodedParser, async(req: Request, res: Response) => { const username = req.body.username; const password = req.body.password; ...
0 votes
1 answer
24 views

How to give every element of an array a ref in Typescript?

I have a component that renders multiple things, one of that is an array of spans. Here is a part of my code: class MyComponent ... { private targetSpan = HTMLElement; componentDidMount() { //...
0 votes
1 answer
12 views

How to build a Vue web component which reflects an internal state as an attribute?

I am building a web component input which looks like this with Vue 3: <my-input value="Search"></my-input> How can I make sure that the value attribute is always equivalent to ...
2 votes
1 answer
45 views

Make TypeScript infer generic argument

I have a base and a descendant type interface IInferredTypeBase { } interface IInferredType extends IInferredTypeBase { myProperty; } In reality, there are many descendants in that hierarchy. Now,...
5 votes
2 answers
1k views

How do you read the version hash of the current PWA in Angular?

I'd like to be able to read the currently active hash of my Angular PWA. However I can't see any mechanism for doing that. The SwUpdate object provides observables that allow you to read the current ...
0 votes
1 answer
46 views

How to include object keys into Generic types

I have this issue with tsx. I'm not sure how to compose the type for generics. In my Options component I have an interface that gets display (display is property name of T, value will be passed as ...
0 votes
1 answer
39 views

Why does Typescript only widen the return type from a Promise.catch() but not from a synchronous catch?

Steps to reproduce: Define a function that returns a promise of string or false. Call and return an async function and return false from the catch method. Problem: Typescript claims it doesn't match ...

15 30 50 per page
1
2 3 4 5
15514