Questions tagged [typescript]

TypeScript is a typed superset of JavaScript created by Microsoft that adds optional types, classes, interfaces, async/await, and many other features, and compiles to plain JavaScript. This tag is for questions specific to TypeScript. It is not used for general JavaScript questions.

0
votes
0answers
5 views

Why does TypeScript's 'declare global' cause ESLint error?

So, I have this global interface Window at the top of the .ts file: declare global { interface Window {myOwnName: string;} } I need this because I want to assign new values to the window ...
0
votes
1answer
28 views

Angular 6 - Get row data on click on toggle button

I would need to get the row detail on click of that particular toggle-button. Below is my HTML code <div class="container"> <div> <h3>Manage Announcements</h3> </...
0
votes
0answers
9 views

Keep class when dragging - Drag and Drop Angular7

I need that when dragging an element of the left to the containers of the right the element conserves its background-color to be able to differentiate it. And if it is "Therapists" it is above all ...
1
vote
3answers
33 views

How to get checked checkboxes values in Typescript

I'm trying to get the values of checked checkboxes and put them into a strig , that string will be used in my api. I want to get the values once the checkbox is checked and retrieve the value if that ...
1
vote
1answer
16 views

How to pass className to `h${headingLevel}` custom tag

I'm creating a custom component with a dynamic-level heading: const HeadingTag = `h${headingLevel}`; ... <HeadingTag className='heading'> {headingText} </HeadingTag> However, I get the ...
0
votes
1answer
13 views

Using text Method in TweenLite show undefined

I am using Green Sock Animation i am currently building the loader progress and adding the percentage counter Example :- https://codepen.io/linxlatham/pen/aWJaXp I am using this link for reference to ...
0
votes
1answer
10 views

vuejs typescript and child components “Avoid mutating a prop directly”

I'm going round in circles here. I have a vuejs2 app up and running with typescript but hitting an error when i try to pass data to a child component that originates from the store. <template> ...
-1
votes
0answers
19 views

map English characters to Persian chars in typing simultaneously [on hold]

My program is designed for Persian users and should only take Persian chars I have an angular application and I want to create a pipe or method that can map English chars to Persian ones(for example ...
-1
votes
0answers
10 views

How to find a bug in Angular Universal app?

I'm having strange render bug on ssr version of app. Basically, somewhy it double renders one component. I can't reproduce it in dev (static) mode. Is there is a way to track that bug using ssr? I'm ...
0
votes
1answer
17 views

How to fix 'Property assigned to a value in subscribe() function returning undefined' in Angular 7

I'm trying to get the current URL or route in my web application, I figured out the way to do this in angular is using the following code ``` import { Injectable } from '@angular/core'; import { ...
-2
votes
0answers
27 views

http status code with 400 but it is returning values

I am using angular 7.In my application i have grid and i'm getting data from mssd(microsoft sql serve database). In that grid i'm using action buttons like edit and delete.What my requirement is when ...
1
vote
2answers
28 views

TypeScript: How to merge an object from another interface?

I have the following interfaces: interface TxInterface { field1: string; field2: string; field3: number; } interface RxInterface { field1: string; field2: string; field3: ...
0
votes
4answers
34 views

How to concat() multiple array's and check if values already exist

i concat multiple Arrays to one Array. This works well this.facetsLocations = [].concat( response.facets['134_locations'].terms, response.facets['135_locations']....
0
votes
0answers
20 views

Type is missing the following properties

I need some help. I create User entity by using typeorm and I want to overwrite toResponseObject at Customer class for change return attribute but when I write finished the error occurs as "Type '{ ...
1
vote
0answers
23 views

Type guard indexed property access - Typescript

This is failing with the message left/right hand side of an arithmatic operation should be of type 'number', 'bigint' etc .... sort({ key, direction }: SortOptions<Listing>) { this....
1
vote
1answer
21 views

Typescript Generics wrapper: Untyped function calls may not accept type arguments

This code snippet with Generics works perfectly fine (Link to Simple and Working Code) const state: Record<string, any> = { isPending: false, results: ['a', 'b', 'c'] } const useValue =...
0
votes
0answers
12 views

Cant manage to retrieve data thourgh relation query from TypeORM in resolver

So I'm trying to retrieve elements out of a join relation in an Apolo resolver. I've got a User table, a Notification table. And a Relation table named: notification_recipients_user defined by a ...
0
votes
0answers
14 views

TS2451: Cannot redeclare block-scoped variable 'custom'

I'm using typescript in a web project. I use awesome-typescript-loader as a webpack loader. I am getting error when building my project: ERROR in [at-loader] ./node_modules/@types/node/index.d.ts:82:...
0
votes
2answers
30 views

How to loop through an array and get the name corresponding to id and assign the result to another array

I am new to typescript .please help me in doing this. I have an array as below. let pets=[{id:"1",name:"animal"},{id:"2",name:"animal"}]; i want to loop through pets and get the names of animals ...
1
vote
2answers
46 views

Why does alert box shows twice?

Whenever I run this code alert box pops-up twice <p *ngIf="serverCreated">{{alertBox(Success)}}</p> else noServer <ng-template #noServer> <p>{{alertBox(Failed)}}</p&...
2
votes
2answers
52 views

How to calculate Customer since i.e Duration of customer in Typescript

I want to find out how long a person has been a customer. I mean I simply want to subtract current date from start date. However I can't understand what I am doing wrong. customerStartDate: String; ...
2
votes
0answers
35 views

Cannot use Map in Typescript

Throwing typedoc error while using Typescript Map. Find the below error. Property 'clear' does not exist on type 'Map< string, number>'. Property 'has' does not exist on type 'Map< ...
0
votes
1answer
16 views

Webpack / Typescript not correctly parsing for-await loop

Hitting a snag with yarn build in my vue-cli typescript project: tmpDataDocs is an array of Promise<DisplayableData> objects. As far as I understand the for await control structure, the type of ...
2
votes
3answers
23 views

ion-datetime: How to get date value without timestamp?

I'm using ion-datetime in ionic4 using NgModel to bind to a property, however, no matter what options I include in format, I always get the time with the timestamp included. ¿How can I remove ...
1
vote
0answers
28 views

published npm package not searchable

I published an npm package named container-object-model but currently, it's not visible in npmjs.com. but I can install it using yarn add container-object-model. (files in node_modules) package....
0
votes
1answer
22 views

subtype value can assignable to parent type variable?

subtype value can assignable to parent type variable, on the contrary can't, is that true ? i'am confused, if that's true and document say that all types in TypeScript are subtypes of a single top ...
2
votes
1answer
28 views

double assertion on class definition

I have the following interface export interface DefElement<G> { id: string; element: G; } export interface DefEvent<T> { type: T; value: any; } I want to be able to set the ...
0
votes
1answer
48 views

What does this mean: items:Array<any>

Very new to Angular and Javascript. I have a homework for angular.js class. We have a code hint and need to create a simple form. In the code hint there is: export class AppComponent { items:...
0
votes
1answer
18 views

How do I setup JSS in a TS/NextJS project?

I am trying to setup a basic web app using React, TypeScript, NextJS and Material-UI. The issue I am experiencing is with setting styles within the project I have. I've set up a CodeSandbox ...
-8
votes
1answer
25 views

Ionic 3 Phone Call via Internet [on hold]

I have a question: I am currently working with Ionic and would like to make something like a phone call over the internet. something like whatsapp or telegram. However, I can not find any plugins that ...
0
votes
0answers
10 views

Best way to convert only JSX in TSX and maintaining TS

I have a bunch of TSX components written in Inferno (similar to React/Preact). I'm in need of just .ts versions with the JSX aspects converted. The environment I'm using it in only supports TypeScript ...
0
votes
2answers
39 views

Problem with converting Promise to Observable

I have request to google drive using gapi: getFolders(folderId: string): Observable<{ id: string, name: string }[]> { const promise = gapi.client.drive.files.list({ fields: '...
1
vote
1answer
10 views

How to fix cannot read property error in foreach loop

I have a foreach loop where i fetch data from firebase. i want to set a global variable to hold the "spotrating" (a property of each object). But when i call the global variable inside the forEach ...
0
votes
1answer
19 views

Accessing values in response of http request without getting error?

The results.session_id has a red squiggly on it because it is an unknown parameter. How do I let Angular/TS that it is a valid parameter? ``` this.requestManager.loginRequest(email, password)....
-1
votes
0answers
13 views

How to connect to AWS Websocket API Gateway using angular

I am trying to programmatically connect a user my AWS Websocket API Gateway but I am not having any luck. My websocket api gateway gives me the following url: https://xxxxxx.execute-api.us-east-1....
0
votes
0answers
17 views

Typescript file recognizes functions in other files without import

I have two typescript files in my project: // src/file1.ts function foo(): void { console.log('hello'); } // src/file2.ts foo(); When i compile the project, i would expect tsc to complain about ...
0
votes
1answer
12 views

How to update signature of typescript when testing with a mock

I am using jest to mock implementation of a method with this signature (arg1: string, arg2: string, arg3: callback) (arg1: string, arg3: callback) and I want to invoke the arg3 directly inside my ...
0
votes
1answer
20 views

How to structure typescript microservices repository on github

I am working on designing an collection of microservices. I was using the following structure where each item is its own repository. my-project-logger my-project-numbers-service imports: my-project-...
-1
votes
2answers
24 views

How to fix 'Item' is missing the following properties from type 'Item[]': length, pop, push, concat, and 26 more

Can someone please help to fix this? I'm making CRUD app via firebase and i'm new to ts and firebase. Help me please i'm working on this for days. Thanks My ts file: import { Injectable } from '@...
0
votes
0answers
16 views

How to fix 'TypeScript error: JSX elemen'

I would like to do HoC component in my react with typescript app. But, when I wrapped my component here: RegisterForms.tsx: import React from "react"; import SingleFormGroup from "../atoms/...
1
vote
1answer
20 views

TypeError: Cannot read property 'xyz' of undefined although it is defined

I have a variable called cuisines in my component.ts file which has been declared as follows: component.ts export class xyzComponent implements OnInit { constructor(private route:Router,private ...
0
votes
1answer
10 views

Restrict interface's property value to one of object's values

I want TypeScript to throw an error if the object that is type of IExpression interface has a expressions.null.property or expressions.video.property value that is not one of PROPERTIES values. I ...
0
votes
2answers
56 views

call back function are called before the request is finished

I have a like button similar to the one in twitter, which calls a function which deals with the requests and in the call back function which increases the number of likes and change liked bool to true ...
-1
votes
2answers
29 views

Get name and value of url params [duplicate]

I have some url like this /posts/singlepost?page=99 I need to get key and value of query in url and to put in new array, that i can loop,and use that key and value in my http request. In url page ...
0
votes
1answer
38 views

Wrong number of parameters in function type in TypeScript

This is my code: type ComparatorFunc<T> = (o1: T, o2: T) => number; export interface Comparable<T> { compareTo​(o: T): number; test(func: ComparatorFunc<T>); } let c: ...
1
vote
1answer
25 views

Why “void” not works for optional parameter, when i use generic type?

When i use a "void" type directly as function's parameter, it works good, but when i use generic, it not inferred. I use TypeScript 3.4.4. // It works perfectly :-) function test(param: void){ } ...
0
votes
0answers
17 views

Ionic 4 fails to load on mobile once i add Google Firebase to the project

My ionic 4 project works great on chrome, devapp and even after compiling to apk. But once I add firebase config it fails to load using both devapp or even after compiling to apk. here is how I add ...
1
vote
1answer
18 views

I'm having a problem with method decorators and class decorators

I have a class decorator, and that class decorator changes the class and adds a property inside of it. Then i have a method decorator, that's inside a class with that class decorator, and the method ...
0
votes
1answer
13 views

how to programmatically change toggle in ionic v4

I'm trying to retrieve toggle state from the server and update the view accordingly here is the HTML for that <ion-list *ngIf="this.devices.length > 0 " no-padding > <ion-item *...
0
votes
0answers
22 views

React component briefly renders the wrong data

I have a Profile component that checks to see if the user passed in url params. If not, the Profile component will render using the current logged in user. If they did, it will pull that value and use ...

http://mssss.yulina-kosm.ru