Questions tagged [typescript2.0]

Tag for questions specific to new features in TypeScript 2.x. For general TypeScript questions, the correct tag is TypeScript.

Filter by
Sorted by
Tagged with
0 votes
0 answers
37 views

TypeScript tree typization

Below is a short example of a tree interface TemplateRoot extends Template {} class Template { #root: TemplateRoot | undefined get root (): TemplateRoot { return this.#root ?? this } ...
  • 368
-1 votes
1 answer
23 views

Failed to implement Typescript function overload

Following the last question: Typescript: omit undefined/null properties from type Using TS, I was trying to implmenet an overload for a function named request which can accept payload or not, by the ...
0 votes
1 answer
45 views

Extend/Omit interface in typescript

I have list of props under interface type. And want to extend interface type with modification as below, Change of Prop types addition of new fields interface Request { Id: NullProp<number>...
  • 1,345
1 vote
1 answer
39 views

TS2322: Type '{ headers: HttpHeaders; body: Stock[]; } | null' is not assignable to type 'Stock[]'

I am getting this TypeScript error in Angular. I have a class named StockComponent with the following property: protected stocks: Stock[] = []; The Stock class is a regular class I created to ...
0 votes
0 answers
15 views

After refreshing the page, the selected filters is lost

In my web application, when I try to select some values for filtering data, it is going to be selected and saved in backend (C#) successfully, but after refreshing the page, the selected data is lost. ...
0 votes
0 answers
23 views

How should I setup an additional interface to a class that already extends a generic class?

So I have this class: class TagsDao extends PGDao<Tag> {...} PGDao has this implementation: class PGDao<T> implements BaseDao<T, PoolClient> {...} Let's say I want to achieve this (...
0 votes
0 answers
25 views

ThreeJS animation not running in Typescript Eslint5 Next Application

I have a typesafe typescript application running on next and need to implement an "old" three.js animation I built for a react project. Since typescript is a bit tricky with getting document ...
  • 1
0 votes
0 answers
87 views

semantic error TS2574: A rest element type must be an array type

Here is the code src/object.ts(50,58) interface sanitizer<T> { (val: T): T } type MapSanitizor<T extends any[]> = T extends [infer P, ...(infer R)] ? [sanitizer<P>, ......
  • 35
0 votes
1 answer
26 views

join grid column not available in vaadin hilla using Lit?

in vaadin hilla grouping column header is working fine whereas joining column under one header not working. vaadin 14 had option for joining 2 columns which is lacking in hilla. if anyone has any ...
-1 votes
1 answer
45 views

How can I use date-fns to format a date from an API?

I receive data from an API in the format 'yyyy-MM-dd'. I would like to convert this date to 'dd-MM-yyyy'. When I specify this notation my table will not be displayed. How could I change the format in ...
-2 votes
2 answers
179 views

How to add variable as key name in typescript interface?

This is how my object would look like. This is very small version of object and I have to deal with large object. const obj = { name: 'name_key', details: 'details_key', profile: '...
0 votes
1 answer
162 views

Test Observable with fakeAsync, delay and tick using Jasmine

I have a pipe that helps return the state of an observable. import {Pipe, PipeTransform} from '@angular/core'; import {Observable, of} from 'rxjs'; import {catchError, map, startWith} from 'rxjs/...
1 vote
1 answer
25 views

How To scroll to the last message in the react virtualization message container

I am using scrollToIndex and scrollToRow but is not working on adding a new message, Also I tried with use ref but was not able to make it work, feel free to suggest. In your text, I would be more ...
0 votes
2 answers
46 views

Use a variable as as key of an interface to get the typeof

Is it possible to use a variable to get the typeof a key in a interface? For example: interface DbSchema { jobs: { jobId: number; jobName: string; } users: { userId: number; ...
  • 38
0 votes
1 answer
36 views

How do I type an object's key in an array in a type script?

I want to type the key values of the objects inside the already declared array. const temp = [ { key: "name", value: "mike" }, { key: "gender", value: "male"...
0 votes
0 answers
450 views

node.js ERR_IMPORT_ASSERTION_TYPE_MISSING TypeError: Module tsconfig.json needs an import assertion of type "json"

{ "extends": "../../tsconfig.json", "include": [ "**/*.ts" ], "exclude": [ "node_modules", "...
  • 2,982
0 votes
1 answer
158 views

How to query AWS DynamoDb using GSI Index and FilterExpression

My DynamoDB database table is as follows. It has primary key(ID) and sort key (receivedTime). ID(primary key) receivedTime(sort key) Data ID1 1670739188 3 ...
2 votes
1 answer
38 views

Create union of interface values based on keys of another type

I have an interface with keys as enums and further interfaces as values. enum Enum { Val1, Val2, Val3 } interface MyInterface { [Enum.Val1]: { bookingId: string } [Enum.Val2]: { videoId: string }...
0 votes
1 answer
47 views

Use keys of one type to create type containing keys of another type

I have an interface of types as such: interface MyInterface { Name1: { userId: string } Name2: { bookingId: string } } I have a type below that accepts an object of type { [key: keyof MyInterface]...
1 vote
1 answer
47 views

How to change pages using a function in React

When a user logs in and clicks the button, a function is called and this function calls a function that returns a Promise. When the user logs in, the href property is responsible for changing pages. I ...
  • 41
0 votes
0 answers
28 views

How to read and assign a type from one interface to another interface in Typescript

I have one parent interface ICountry export interface ICountry { } and one child interface ICountryOverview export interface ICountryOverview { } I want name and code properties in ICountryOverview ...
  • 117
0 votes
0 answers
28 views

how can i set timeout for WebSocket in lib.dom.d.ts

In my project, we use websocket like this ws = new WebSocket(url); now I want to set timeout for this ws object but I cannot find the parameter that can set timeout how can I to do this?
  • 1
0 votes
2 answers
1k views

How to remove script tags in index.html from Angular Component

<script data-jsd-embedded data-base-url="" data-key="" type="text/javascript" src="js-text-sample.js"></script> Above is my sample script tag which ...
-1 votes
2 answers
732 views

URLSearchParam type {property: value} is not assignable to undefined & Argument Type {property: value} not assignable to {property: value}

I keep getting this error when I try to execute the following code. Basically it takes in the given refresh token and send a POST request with the URLSearchParams to the URL. But for some reason ...
  • 90
0 votes
2 answers
25 views

typescript infer never[] when returned empty array from catch statement with async/await method

method getData() returns Promise<Output[]> without catch statement type of data inferred is Output[] but when I try to put catch statement in front of getData() method type of data becomes ...
-1 votes
1 answer
31 views

Typescript remove property restructure array

Convert array to array below in typescript. Before: ` [ {propety: 332}, {propety: 325}, {propety: 125} ] ` After: ` [ {332, 325, 125} ] `
0 votes
0 answers
33 views

converting string value to enum type value [duplicate]

I have created a enum in typescript: export enum ProductType { FRUIT, CLOTH, } I wonder if I receive string value fruit and cloth, how can I convert the string to the enum type. Here is what I ...
  • 5,498
0 votes
0 answers
15 views

TypeScript import paths giving 'Module not found' error in production [duplicate]

I'm trying to deploy a simple Express app to production, I've used TypeScript, and my tsconfig.json is as follows { "compilerOptions": { "target": "es2016", ...
  • 560
0 votes
1 answer
173 views

typescript: validate function argument based on callback return type

I'm trying to type a function witch run a callback for each array item and extend that item with a new properties: interface Row { a: number } export function extender< Data extends Row[], ...
  • 1
0 votes
0 answers
281 views

call my API (typescript) with my frontend application in VUE3 Js

hey i develloped an Api rest in nodejs and i 'd like now consume it but i've always the same strange error. i've never used vue before, moreover i'm using Vue3 which is recent. Hey here is my code ...
  • 21
0 votes
0 answers
27 views

Starting to work on Typescript : Not able to understand why this promise.all is not working [duplicate]

I was assuming that by using await I am making sure that the promise will get completed(it will wait at this statement until the promise is complete) before moving to the execution of next line. But ...
0 votes
1 answer
190 views

Type '{ description: String; }' is missing the following properties from type 'IOrderFormWithReactProps': context, siteUrlts(2769)

i dont know why this error occurs. it shows Type '{ description: String; }' is missing the following properties from type 'IOrderFormWithReactProps': context, siteUrlts(2769) ***...
1 vote
2 answers
177 views

Typescript :: Related Generic Constraints

In React, I have a generic interface like so: interface BaseProps<T> { data: T; } The consumers of my code will extend this to define their own Props and Component: interface MyProps extends ...
  • 1,626
0 votes
0 answers
18 views

Typescript is complaining filtering on array dynamically

you gorgeous Typescript expert. I need your help Here is the code const mapping = { [Tools.RECTANGLE]: 'rectangles', [Tools.ELLIPSE]: 'ellipses', [Tools.POLYGON]: 'polygons', [...
0 votes
0 answers
167 views

Im trying to integrate a js library(epub.js) into angular application,No errors and blank screen

import { Component } from '@angular/core'; declare const ePub: any; export class AppComponent { title = 'epubIntegration'; epub: any = null; constructor(){ var book = ePub("https://s3....
  • 775
0 votes
2 answers
295 views

TS : How to create a type factory using a string to generate the keys

I am trying to create a way to easily generate a type that defines a multitude of key values association with a specific name pattern in the keys. I have a specific type that is very repetitive, as ...
1 vote
0 answers
222 views

Type 'Recommendation[]' does not satisfy the constraint 'PathParams'. Index signature for type 'string' is missing in type 'Recommendation[]'.ts(2344)

I am building a app using react, typescript and msw. When I am adding types I got this error: Type 'Recommendation[]' does not satisfy the constraint 'PathParams'. Index signature for type 'string' is ...
2 votes
1 answer
91 views

Param type resolution when combining union and intersection types in TypeScript

Here are 3 simple types type T1 = | { letter: 'a'; valueFunc: (prop: number) => void; valueType: number } | { letter: 'b'; valueFunc: (prop: string) => void; valueType: string } type T2 = { ...
  • 1,594
3 votes
1 answer
293 views

typescript upgrade 1.8.10 to 2.9.2 and 4.6.4 build error

I have an angular application, using typescript 1.8.10 and working fine. I like to try and upgrade typescript from 1.8.10 to 2.9.2. Once I change this setting in package.json and run npm install I ...
-2 votes
1 answer
1k views

convert string date to datetime format in Angular / Typescript and compare it with current date

I'm new to angular and I need some help in datetime conversion. My datetime in string is Sat, 30 Apr 2022 00:00:00 GMT but I want to compare this date (only Sat, 30 Apr 2022) with current date. How do ...
  • 178
0 votes
1 answer
186 views

Typecasting when render the prop with union Types

I have a two properties in my component. prop1: CustomObject<string, type1> prop2: CustomObject<string, type2> | Array I will accept only prop1 on priority and if prop1 is not available ...
  • 1,694
0 votes
3 answers
2k views

How to avoid logout after a refresh in Angular

I have problem with logout after I refresh the page. I think that problem is in method for getting current user or in method for checking is user admin. admin-auth-guard.service.ts export class ...
-1 votes
2 answers
5k views

How to dynamically set month end date if start date is picked from the calendar of Angular's mat-datepicker functionality?

Eg. If Start date picked from calendar is "15/06/2000" and if no End Date is selected from calendar then End Date gets automatically set to "30/06/2000". End Date can also be ...
2 votes
3 answers
102 views

Want to write regex in javascript which will check if all the mentioned chars exist at least ones

I have string s and need to check if that string contains every single alphabet from a to z. What will the regex be to check this condition? where s can be very big string with multiple words ...
  • 179
2 votes
1 answer
331 views

Large file downloads don't work in Firefox browser

I have a Angular app where users can download some documents(.jpg, .mp4 and .pdf) that they uploaded. Basically the download of the file works in this way: A service is called which returns some ...
  • 431
1 vote
0 answers
13 views

typescript Can an array type be converted to an object? [duplicate]

In the type, is it possible to convert the array type to the object type? class Ad { constructor(name: string, age: number) {} } type Ac = ConstructorParameters<typeof Ad> // Ac = [name: ...
0 votes
1 answer
46 views

How to disabled the button, when checkbox are not selected

I am trying disabled the button, but the Typescript code doesn't work! When I selected the first and two checkbox, but I deselected the first checkbox, the button automatically is disabled. Example ...
0 votes
1 answer
921 views

Why do I keep getting Not all code paths return a value here?

I'm trying to understand why I keep getting this error from typescript. PS. I know I would just use the boolean in this case and not create function, this question is more about typescript. Not all ...
  • 123
0 votes
1 answer
611 views

Angular Typescript Create a File object from assets img directory

I'm trying to implement a custom image selection. I want to propose several image in a modal and when a user click on one element, put it in a File object in my ts (like a file picker). I don't want ...
  • 59
3 votes
0 answers
521 views

Cannot find module from 'node_modules/.pnpm/../dist/index.js' error when use package

How I can configure the a package that bundled with sub package? I configure my package as following and run test without any problem. However, when I tried to use the package_name in some other repo ...
  • 7,157

1
2 3 4 5
30