Category "typescript"

Creating a (.NET 6 based) website project with ASP.NET Core and React (TypeScript) in Visual Studio 2022?

I have been trying to set up an ASP.NET Core + React (TypeScript) web app project in Visual Studio 2022, but couldn't succeed in doing so. There are no proper s

How do i set the active tab in PrimeNG tabMenu?

Where I do declare activeIndex and how to use this variable ? I have html file: <p-tabMenu [model]="tabMenuItems"></p-tabMenu> and typescript f

How to remove the previously selected option from a drop-down menu in a table?

I am making a project on angular 7.It has a table with a column having dropdowns. The dropdown contains various languages. When a language is selected in a part

Manually closing the calendar primereact

I'm using primereact version 6.2.1, While using the calendar from primereact i have enabled the option for showTime. This brings up a datePicker with an overlay

Create dynamic svg icons component in ReactJs

I want to create a React component for my SVG icons but if I use this component several times (with different props) in another component, it always renders the

`as const` alternative to narrow an array literal tuple, to avoid `readonly` modifiers

We use as const to narrow the types: [ {foo: 'foo' }, { bar: 'bar' } ] as const but this also adds readonly modifiers for all props and values. As of const thi

How does this function that takes in a RequestHandler in express work?

I was browsing through some code examples for Express server on GitHub and came across this function used to wrap around REST API controllers and was confused h

how to and array of objects from a subscribe method and store it in another array for use in functions?

I have a service to get data from the backend database and display the array of objects that works fine, the only problem is I can not use it outside of the sub

Cannot find name 'it' in Jest TypeScript

I try to create an intial setup for Jest in React + TypeScript. I have completed the initial setup and try to check whether the test runs. When I run the test u

How can I use async/await in the Vue 3.0 setup() function using Typescript

(This question has been answered for JavaScript, see below, but this question is specific for TypeScript, which behaves differently) I'm trying to use async fun

single glob pattern to target all .test/.spec files TSConfig

I would like to exclude all test files in tsconfig.js. Files that should be excluded *.test.ts *.test.tsx *.test.jsx *.test.js *.spec.ts *.spec.tsx *.spec.jsx *

Why FormData object is empty even after I use append?

I tried the following code: (This is my service file in angular posts.service.ts) updatePost(id: string, title: string, content: string, image: File | string)

How to apply mask behavior in primeng calendar (p-calendar)?

I am new to angular, in p-calendar I'm not able to apply masking behaviour. Example: If user enters 01012012, I want to change it to 01-01-2012. Thanks in advan

Importing SVG as React component not working with Next.js

I created a project with create-react-app using Typescript and latter I was asked to add next.js to it, what happend was that it broked some svgs across the app

Downloading a file using React and Typescript

I am trying to build a single page app using React. I came up with this hacky way to download a local file (residing in the public directory). I have two questi

How to use union type as a generic parameter in a record which in a function

I'm confused about the generic union type in Record. This is my code (TypeScript version: 4.6.3): const fn = <T extends number | string = string>() =&g

Typescript error: An outer value of 'this' is shadowed by this container

I had an error in a Typescript class method declaration, but I don't understand how the error message relates back to the bug. The message seems to be saying

Some component props reset after drop in react-dnd

I'm building a meme generator app. Here is my main component const [inputText, setInputText] = useState<InputText[]>([ { text: "", top: 30, left: 30

How to maintain proper typescript type on Vue component data?

I'm working on a Vue project that I'm updating to Vue 3 with typescript. I've found a strange behavior with the typescript parser/compiler. I have the followin

Testing axios.create() instance with jest

I tried many solution from this task. I want testing axios instance api call without any libralies (jest-axios-mock, moaxios, msw, etc). I hope it's possible, b