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
7 views

Wait for a response before loading template

I have an angular application that makes a server call on ngOnInit() and returns a result. I then use the result to populate a model in my template. My template is loading before the call is finished, ...
noclist's user avatar
  • 1,765
0 votes
0 answers
15 views

Creating a type from an object's keys and values in TypeScript

I'm trying to create a new type based on the type of a statically defined object in TypeScript. Given the following map: const map = { 'hello': {a: 1, b: false}, 'world': {b: 'hello', c: null} ...
josno's user avatar
  • 96
-1 votes
0 answers
30 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 ...
ADJenks's user avatar
  • 3,212
0 votes
0 answers
10 views

Vue3 Typescript Sum all values of a column in an array

I'm still very new to this programming language and I'm trying to take an array column and sum its values so I can show a total amount on the webpage. Question #1 I was attempting to use a computed ...
Handsome.Paul's user avatar
0 votes
1 answer
18 views

class validator required if

I have this class class A { @IsString() @MaxLength(99) prop1: string @IsBoolean() prop2: boolean } I want it to be: string. required (if prop2 is true). optional if prop2 is false. In ...
Normal's user avatar
  • 2,920
2 votes
1 answer
33 views

Remove the `length` property from a callable type

Assume I have the following type: export type Foo<T> = (() => T) Is it possible to remove the length property from it while keep it callable ? Also, using Omit, Omit<(() => T), 'length'...
Matthieu Riegler's user avatar
0 votes
0 answers
5 views

Setting up Tone.js on button click still fails with : The AudioContext was not allowed to start

I have a angular component that has a button to start an animation and at the same time play some notes each time a number is highlighted I'm setting up tone.js synth when the button is pressed see ...
Mauricio Gracia Gutierrez's user avatar
0 votes
0 answers
18 views

A strange behavior when checking `extends ReadonlyArray<any>`

See code: https://www.typescriptlang.org/play/?#code/...
lei li's user avatar
  • 1,310
0 votes
0 answers
16 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): ...
JSArrakis's user avatar
  • 789
0 votes
0 answers
13 views

Simple sticky scroll effect causes glitch on mobile browsers

I wanted to use a scroll effect (parallax + filters) in a very simple page. It's just a sticky 120vh div with a background image and some text. Everything works fine in the desktop browser and with ...
Moritz Roessler's user avatar
0 votes
0 answers
10 views

Cypress. How to pass the same data to "it" functions within one "describe" function

I am testing 2 products. 1 for users and 1 for employees. The user creates a request and then it is processed by the employee. I generate an object with random test data. Based on this data, I create ...
Norlerion's user avatar
0 votes
1 answer
19 views

export default new TypeScript Expected 1 arguments, but got 0.ts(2554) how to fix?

Doing a QA job with PlayWright and TypeScript Trying to avoid extra imports like defaultPage = new defaultPage(page); in spec files just to reduce lines of code and make tests little more pretty. new ...
Andrei Smirnov's user avatar
0 votes
1 answer
8 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 ...
leonheess's user avatar
  • 19.9k
-1 votes
1 answer
26 views

Generate object access keys from props

I have problems with dynamisation in Typescript. I know that TS works statically. However, there are sometimes situations where I want to access an object dynamically and cannot do this directly via ...
MrFish's user avatar
  • 11
0 votes
0 answers
8 views

error NG8001: 'mytable' is not a known element

When I try to compile the front-end of my project, the following error occurs in the userList.html file. Actually, the error occurs in any HTML file located in the ./page folder, but I will use ...
Gabriela Zanon dos Santos's user avatar

15 30 50 per page
1
2 3 4 5
15516