Category "typescript"

How to redirect to external url onClick? in React

I'm using react-router which means i'm storing routes in app.tsx file. I have cards components that need to redirect to an external url onClick. So my question

Correctly declare interface or type for functions params

How to correctly declare type for param cardsByStatus inside function addCardsToStatus? It works for cardsByStatus: any, but it doesn't make sense for me. Error

Define an empty object type in TypeScript

I'm looking for ways to define an empty object type that can't hold any values. type EmptyObject = {} const MyObject: EmptyObject = { thisShouldNotWork: {},

How to inject service to validator constraint interface in nestjs using class-validator?

I'm trying to inject my users service into my validator constraint interface but it doesn't seem to work: import { ValidatorConstraintInterface, ValidatorConst

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