Category "typescript"

Typescript: validate type after using type assertion

Is there a way to allow strict type checking on a value after having used a type assertion? For example, sometimes I need to construct a function type that has

Why doesn't the exports field of npm work in typescript?

Our library @ltonetwork/lto, is written in typescript. We use tsc to compile to javascript in the lib folder. The package contains several sub-packages, which a

Angular 12 Getting Id of Selected Product

I want to get the id value of the selected product in my Angular 12 project, I used NgModule for this, but unfortunately it does not work. What is the reason fo

How to correctly declare static refs in Composition API using Typescript?

I am using the Composition API (with <script setup lang='ts'>) to create a ref, used in my template: const searchRef = ref(null) onMounted(() => { sear

Array<Type> VS Type[] in Typescript

As far as I know a property's type can be defined in two ways when it's an Array. property_name: type where type can be either Array<string>, Array<

How do I pass data to Angular routed components?

In one of my Angular 2 routes's templates (FirstComponent) I have a button first.component.html <div class="button" click="routeWithData()">Pass data an

How to add custom arrow buttons to Alice-Carousel?

I am making a carousel component with alice-carousel (https://github.com/maxmarinich/react-alice-carousel/blob/master/README.md) but having trouble customising

How to extend anonymous type in Typescript

When chaining functionality in typescript with anonymous types for example like this: let array = [{ seed: 2 }, { seed: 3 }]; array .map(i => ({ see

The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type

1 interface Dimensions { 2 width: Number, 3 height: Number 4 } 5 6 function findArea(dimensions: Dimensions): Number { 7 retur

Missing "Go to Definition" from VSCode menu

I am working on Typescript/Javascript project using VSCODE. I use to hover mouse on the method and can see the function definition, cmd + click go the definitio

TypeORM column type dependant on database

I have simple entity @Entity() export class File { @PrimaryGeneratedColumn() id: number; @Column({type: "mediumblob"}) data: Buffer; } Which

Is there something like Lombok for TypeScript?

I'm looking for a way to reduce the boilerplate code of my NodeJS backend. In Lombok there is e.g. the possibility to inject constructors and getter/setter by a

What is the type of the webpack config function when it comes to TypeScript?

I cannot figure out the type of the webpack configuring function when the config is written in TypeScript. Currently I export an object whose type is Configurat

Typescript error (2345) when pushing element to array of elements(React js)

I'm pretty new to Typescript and I was trying to migrate a component I had on Reactjs to typescript. This component is supposed to receive a number from 0-10 as

Typedoc / Typescript Compiler throws error on an imported type

Summary I am attempting to build documentation for a TypeScript project using Typedoc. Unfortunately, Typedoc is yielding errors on an import statement I use in

ESLint: 8.0.0 Failed to load plugin '@typescript-eslint'

Could you help me, I've got this error when I try building a project? Oops! Something went wrong! :( ESLint: 8.0.0 TypeError: Failed to load plugin '@types

Synchronously iterate through firestore collection

I have a firebase callable function that does some batch processing on documents in a collection. The steps are Copy document to a separate collection, arch

Could not find a declaration file for module 'vue-xxx'

Any 3rd party Vue.js library that I try to add to my project, throws the following error: Could not find a declaration file for module 'vue-xxx' I have tried

React: How to solve 'Spread types may only be created from object'?

I am trying to create a handler method in React, but I'm getting a typescript error with spread operator. Could someone help with this error please? I did follo

Angular 5 - Copy to clipboard

I am trying to implement an icon that when clicked will save a variable to the user's clipboard. I have currently tried several libraries and none of them have