Category "typescript"

Koa + TypeScript: Property 'body' does not exist on type Request

I wanted to use koa & koa-bodyparser with TypeScript but whenever I access ctx.request.body I get an error that body doesn't exist on type Request import Ko

Why is typescript trying to load the wrong type definitions?

When I try to run typescript on my project I get the following: # ./node_modules/typescript/bin/tsc --project tsconfig.json node_modules/@types/webpack/index.d

emotion use css prop with custom components

In my application I have a component that I want to style with the css prop from outside. function Component({css}:{css?: React.CSSProperties}) { // some stuf

How to test form controls avoiding bracket notation to preserve type checking and maintainability

The Problem My unit tests on a form break when I refactor an object's member because I can only access the formcontrols on a fromgroup by using bracket notation

How do I not allow special characters and space in react hook using yup

Here's the code: { label: "Name", name: "name", placeholder: 'Name', type: "text", rule: yup.string() .required('Name is a r

Dynamic call of chalk with typescript

I am using typescript and want to call the chalk method dynamically, see my code : import chalk from 'chalk'; const color: string = "red"; const message: strin

Dynamically define argument type

I'm writing a library with TypeScript. It's meant to be a super-set of a configuration language, and itself configurable. In a particular context, I want to dec

Is it possible to assign opacity to a SCSS hex color variable, re using that variable?

I have a series of scss variables representing colors re used throughout my app, like so: $first-color: #00755E I also have colors that are the same as this fi

Zod: create a schema using an existing type

I have an endpoint that should get a parameter method which should comply with the axios type Method. How can I create a schema in Zod that validates that the v

Typescript dynamic type depends on value (generic)

Is it possible get dynamic type depended on value of key dataIndex (create dynamic discriminating union type with generic)? type EntityList<EntityType> =

aws cdk 2.0 init app fails to build with prettier issues, which is from jest-snapshot

node: v16.7.0cdk: 2.0.0 (build 4b6ce31) package.json: "devDependencies": { "@types/jest": "^26.0.10", "@types/node": "10.17.27", "aws-cdk": "2.0.0

How to find declaration for my typescript/react module?

I am very (very) new in frontend technologies, specially react and typescript. My issue come when trying to do a simple thing that is to use a react component

How can I use optional chaining with arrays and functions?

I'm trying to use optional chaining with an array instead of an object but not sure how to do that: Here's what I'm trying to do myArray.filter(x => x.testKe

Angular: How to store FileReader content in a variable or an array

I'm so confused about this but is there a way to store FileReader content into a variable or an array as it is, because I need that content into another compone

error TS2322: Type 'Event' is not assignable to type 'string'. [(ngModel)]="todoItem" (keyup) ="addTodo()"

I'm trying to bind my input to be able to display string. But I've this error: Error: list.component.html:3:15 - error TS2322: Type 'Event' is not assignable to

How to type a function that only accepts a Readonly Ref in Vue 3?

In Vue 3, you can create a readonly ref or reactive by simply wrapping it with readonly(myRef). Is there a way to enforce a function is called only with a Reado

Disable button unless checkbox is checked (Angular 7+)?

I want to button to be disabled unless all checkboxes have been checked? How do you implement this in Angular? This is different because it is not a form and

Declare an array in TypeScript

I'm having trouble either declaring or using a boolean array in Typescript, not sure which is wrong. I get an undefined error. Am I supposed to use JavaScript s

Cannot find module 'react-dom/client' from 'node_modules/@testing-library/react/dist/pure.js'

hope someone could help me here. while running npm test got following mistake Cannot find module 'react-dom/client' from 'node_modules/@testing-library/react/di

Update a single property of local JSON file using put call in Angular 8

I want to update my JSON file which I have placed in my assets folder, so If I am updating just one property of my JSON object so it should update that property