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.

typescript
2 votes
1 answer
14 views

Not getting auto completion for generic type arguments

I have this function function updateProperty<T, K extends keyof T>(obj: T, key: K, value: T[K]): void { obj[key] = value; } And I have this interface and object: interface ExampleObject { a:...
Normal's user avatar
  • 2,940
1 vote
0 answers
14 views

Why does TypeScript not show never type in error when intersecting an object type with a string? [duplicate]

I am trying to understand why TypeScript does not explicitly show a never type in the error messages when intersecting an object type with a string type. Here is my code: type Test1 = { b: number; ...
Ansel's user avatar
  • 11
0 votes
0 answers
7 views

How to conditionally include dependencies in a TypeScript npm package?

I have a custom npm package that includes all my regularly used functions so that I can manage them easily. However, some functions in the package use specific third-party dependencies, but users(just ...
TU J's user avatar
  • 21
1 vote
1 answer
19 views

Why does TypeScript allow instances of classes not listed in a class array to pass type checks? [duplicate]

I’m encountering an issue with TypeScript where I want to restrict a function to accept only instances of specific classes defined in an array. Here’s my setup: class Types { } class T1 extends Types {...
Daniel de Andrade Varela's user avatar
0 votes
1 answer
11 views

Add error to context with nested schemas using Zod validation

I have a Typescript application that is using Zod to validate data. The schema includes several schemas that have slightly different values with nested fields represented by other schemas as they can ...
Rig's user avatar
  • 1,302
0 votes
0 answers
9 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 ...
teplostanski's user avatar
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>(...
lei li's user avatar
  • 1,320
0 votes
0 answers
25 views

When clicking print button print dialog box is not appearing to some users

When i am going to clicking print button print dialog box is working fine with my side, but some users are complaining they are not getting print dailog after clicking print button into production ...
coder rock's user avatar
0 votes
1 answer
15 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 &...
Shihab Shahriyar's user avatar
0 votes
1 answer
25 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() { //...
erniberni's user avatar
  • 389
0 votes
2 answers
20 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
23 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
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 ...
ADJenks's user avatar
  • 3,224
0 votes
0 answers
15 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
21 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,940
2 votes
1 answer
39 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
8 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
1 vote
1 answer
37 views

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

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

Electron window flashes white upon showing despite graceful display

I am trying to display a window with black content inside a BrowserWindow: changeShortcutWindow = new BrowserWindow({ height: 400, width: 600, show: false, // will be displayed upon ready-...
Vojta Böhm's user avatar
0 votes
0 answers
8 views

Non-relative paths are not allowed when 'baseUrl' is not set. Why does nuxt not set baseUrl by default?

When I cloned Nuxt github project I get the mentioned error. This is my tsconfig.json { "extends": "./.nuxt/tsconfig.json", "files": ["global.d.ts"] } ...
Julius Saikauskas's user avatar
0 votes
0 answers
13 views

How to disable drag and drop in Drawflow package in Angular?

I am using the drawflow package to create a workflow. I want to disable drag-and-drop functionality from elements this demo as mentioned in the below image, not in the sidebar. In my demo, I want ...
Jignesh Panchal's user avatar
0 votes
0 answers
5 views

Mapbox: Text of the point/circle behind is visible over the point in front

I want to show the points and to write data inside. Problem is that the data (numbers) are shown for the points behind instead of the ones in front. I would also like for smaller number circles to ...
Luka Ladisic's user avatar
-1 votes
0 answers
14 views

Having issues with a messenger clone

So everything was working fine until I decided to add a header component to my messenger clone.This specific problem has returned null and crashed my application like 5-6 times. Can anyone help why ...
Suj K's user avatar
  • 1
0 votes
0 answers
3 views

How are types generated react-relay re-used in functions and components without a GraphQL query?

I prefer to use as many types generated by react-relay for shared logic and components that do not contain a graphql query. How are these types shared without causing cyclical dependencies and long ...
T. Junghans's user avatar
  • 11.6k
0 votes
0 answers
11 views

react ts inversify doesn't work with class component

https://github.com/Lavshyak/react-ts-component-class-inversify-problem Check render() code: import {useInjection} from "inversify-react"; import {Bar} from "./Bar"; import {...
Lavshyak's user avatar
0 votes
0 answers
10 views

How to resolve TypeScript error: "Property 'EXPO_PUBLIC_BACKEND_URL' does not exist on type 'typeof env'"?

I'm working on a React Native project with Expo and using TypeScript. I'm trying to access an environment variable using process.env.EXPO_PUBLIC_BACKEND_URL. "The code works correctly when I run ...
M. Maiz Nadeem's user avatar
0 votes
0 answers
13 views

How can i generate the arrow function format typeorm migration file?

when ever i am generating migration file i am getting this kind of format public async up(queryRunner: QueryRunner): Promise<void> { await queryRunner.query(`ALTER TABLE "transaction&...
Sriram Alavalapati's user avatar
0 votes
0 answers
15 views

Typescript: Property 'getAll' does not exist on type 'FormData'

I'm getting non of the FormData newer function typings (entries, get, getAll...). my tsconfig is: { "compilerOptions": { ... "lib": ["ESNext", "dom....
Siraj Kakeh's user avatar
-1 votes
1 answer
15 views

Trying to read a log file using typescript

How do I read a log file using typescript -- I've tried using fs - but it says the module is not found. I've tried to use a promise - but then its not resolving. should I place the test file in the ...
The Old County's user avatar
0 votes
0 answers
13 views

Unable to process the type of data structure returned by Supabase database

I am using Edge Functions written in Typescript fetch data from my table in Supabase database. Unable to understand how I am supposed to process the returned request. Coding in VS Code, I have no idea ...
Shlok Jain's user avatar
0 votes
1 answer
28 views

How to extend methods from two classes in Object Oriented (Java)Typescript?

I currently have two classes with the same methods. I would like to have a class that inherits both of them, but in which methods are extended to perform the operations in both methods. Here is an ...
André's user avatar
  • 1,908
0 votes
1 answer
21 views

How to store the new Date().getTime() Method using Zustand and update the timer without re-rendering the component every second?

The stopwatch works perfectly with useState Hook, but I need to store the time using global state management. I'm using Zustand in my application and I have had no problems so far storing and updating ...
Elvys Pons's user avatar
0 votes
0 answers
12 views

@iFrame-resizer/react implementation error - Uncaught SyntaxError: Unexpected token 's', "scroll-to-top" is not valid JSON

I am using the latest version of iframe-resizer/react for automatically adjusting the height and width of the iframe. Whenever I'm reacting the content, I'm getting a runtime error stating - VM2860:1 ...
Soham Dey's user avatar
0 votes
0 answers
12 views

Getting the Editor Content based on the Cursor Position in a Vs Code Extension

1Are there some available ways for getting the entire function based on the current cursor position in the Vs code Editor , For Eg. Refer This Image here my cursor is at a line inside the function , ...
Mohd Sameem Qureshi's user avatar
3 votes
1 answer
30 views

Typescript: Variable inside Express RequestHandler becomes possibly undefined despite being checked in an if statement [duplicate]

I am creating a way to dynamically create routes before the server fully starts (meaning I'm not creating a route via a request lol that would be crazy), and I stumbled upon this interesting quirk. ...
TNTzx's user avatar
  • 527
0 votes
0 answers
4 views

Is there any way i can move my character by mouse click in Cocos Creator

Im new to Cocos. Im trying to make a game where my character (the Twinkle) move to the Circle and get Score. I 've been searching thruough internet, but all i can do is make my charater teleport to ...
Nguyễn Hải Long's user avatar
0 votes
1 answer
49 views

I get the error that there is nothing available

I get the following error in the project I developed using React and Typescript. export 'useTableProps' (reexported as 'useTableProps') was not found in './useTable' (possible exports: useTable) It ...
kontrawolta's user avatar
0 votes
0 answers
13 views

axios - I can't intercept the response

I'm trying to debug why my request isn't sent or is has wrong data, but I'm not able to check the response. I tried 'axios-debug-log' and it shows that request is sent, but no data about response code....
Agata Ciesielska's user avatar
0 votes
1 answer
18 views

how to return generic object that extends class in typescript method?

I am trying to understand how to use generic in typescript. I have the following code foo<T extends X>(a:A,b:B): T{ // some logic const c: C = doSomthing(a,b) if (c!= null){ ...
Dean Taler's user avatar
1 vote
1 answer
33 views

How do you type a function that returns a function with different parameters

I have an outer function that takes a string as an argument that then returns a function that uses that string. The return function takes either a string or an array of strings as an argument. If it ...
john's user avatar
  • 1,344
0 votes
0 answers
7 views

How do I make valibot properly check constructor/function arguments?

Consider the following, note that a negative argument is checked: use strictures; use Moops; use Data::Dx; library MyTypes declares NonNegativeInt { # let's pretend # <http://p3rl.org/...
daxim's user avatar
  • 39.5k
0 votes
1 answer
15 views

TypeScript loses type constraint on keyof through multiple levels of generic types

This is stretching my knowledge of TypeScrip and with an answer, I'd also appreciate a suggestion for a better question title. I have a problem that when I introduce multiple levels of generic types, ...
UltraMaster's user avatar
  • 1,104
-1 votes
0 answers
14 views

Is there a way to import an cdn file that has no npm package to react/vite? [closed]

I would like to install a library for animation winds into react. I already installed leaflet which is not meant for React but this one has an npm package and I kinda did it but this windy.com lib is ...
Stathis Stathopoulos's user avatar

15 30 50 per page