Category "typescript"

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

Cheerio `this` object in TypeScript make "TS2683: 'this' implicitly has type 'any' because it does not have a type annotation."

I'm using Cheerio in a Typescript project to scrape a HTML page. But I don't understand how to solve the issue : TS2683: 'this' implicitly has type 'any' becaus

Why "he" does not write React.FC on each function?

I learn typescript, and I dont understand why he write in the first Function React.FC and in other function he does not write "React.FC". Why? exp: ... const Lo

Property 'XXX' does not exist on type 'CombinedVueInstance<Vue, {}, {}, {}, Readonly<Record<never, any>>>'

I created a vue component with TypeScript, and I'm getting this error in data() and in methods(): Property 'xxx' does not exist on type 'CombinedVueInstance<

Rerendering component and useReducer initialization

EDIT: below the line is the initial problem where I asked if my whole architecture was fine. I later edited the topic (and title) to go straight to what was my

How can I set a session key from inside a GraphQL resolver in NestJS?

I'm discovering Nest.js and I want to setup a cookie based authentication system with GraphQL. I already installed express-session middleware, here is the conf

How to convert Observable<any> to array[]

I have following method in typescript, I need to bind to angular grid CountryService GetCountries() { return this.http.get(`http://services.groupkt.com/co