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
3 views

firebase transactions you must return a promise

I am trying to figure out how to write transactions to a firebase database from an angular 6 / typescript application. One working example I am using as a guide is the following: const transactions =...
0
votes
2answers
7 views

promise async data extract issue

loadcsv(file: File): string[] { let csvRecordsArray: string[]; this.parse(file).then((p) => {console.log(p); csvRecordsArray = p as string[]; } ); console.log('mydata', ...
0
votes
0answers
4 views

Testing a fs library function with Jest/Typescript

I am trying to test a library function that I have written (it works in my code) but cannot get the testing with the mock of the fs to work. I have a series of functions for working with the OS ...
0
votes
0answers
4 views

Babel 7 + Inversify 4 + WebPack 4 - Unexpected character '@' on @inject

I have a typescript Vue SPA project where I use Inversify. I used awesome-typescript-loader for compiling my typescript source code; now I want to switch to Babel but when I compile my application ...
0
votes
0answers
10 views

Argument of type '(event: any) => void' is not assignable to parameter of type 'KeyboardEvent'

I'm trying to hook on the keydown event on a textarea like this constructor($textArea: HTMLTextAreaElement) { ... $textArea.onkeydown((event: KeyboardEvent) => { ...
0
votes
1answer
24 views

Angular detect if a popup window is opened

In my board (written in Angular 4), the dialogues are opened like below: Importing ActivatedRoute, Router import { ActivatedRoute, Router } from '@angular/router'; Adding Router and ActivatedRoute ...
1
vote
1answer
15 views

Observable chaining, flatMap and type casting

I'm new to observables and I want to learn. I have an API.get() method that returns a promise of type T as T is: export interface T { data?: object; errors?: [object]; extensions?: { ...
1
vote
0answers
13 views

Protractor test case for greater than 100 but passing string from html

How to change the string to integer in Protractor. We are unable to know the problem, it is giving correct results sometimes and sometimes it is giving the wrong results. Need Help...Thank you app....
0
votes
0answers
11 views

json 2 typescript mapping gives type error

Okej so Im trying to map a list of .Net objects to my Angular frontend by way of Web Api 2. The objects are sent, I get them, but depending on the circumstances the objects and their properties might ...
0
votes
0answers
24 views

Angular takes URL parameters and write them in input field

I have a system where I have a change password component. The problem here is that my URL parameters from resetPW go into the first input field. when i load the page the params from reset goes into ...
0
votes
0answers
12 views

Merging two JSON arrays with different key indices: Typescript

I have two JSON arrays say, A: [ {"id": 123, "name": "AnyName1", "type": "AnyType"}, {"id": 231, "name": "AnyName2", "type": "AnyType"} ] B: [ {"id": 569, "thing": "AnyThing3"}, {"id": 891, "...
0
votes
0answers
9 views

Define IIS Express Javascript POST handler

I have a simple TypeScript website that I am running with IIS Express. The purpose of this website is to send HTTP GET/POST messages to a microservice that I am testing. The microservice sends ...
0
votes
1answer
18 views

Typescript: use types for explicit import

I'm programming a webextension in Typescript. Since I would like to target both Chrome and Firefox, I need this polyfill. Importing it looks like this: import browser from "webextension-polyfill" ...
0
votes
0answers
12 views

SheetJS file upload in React

I'm new from react and javascript. I have a jhipster gateway project generated with react/redux, so I have tsx files for design web pages. I want to upload xls file from browser.And then read the data ...
1
vote
0answers
54 views

How to apply [ngClass] to :after of an element?

I am trying to modify existing code that styles a progress line to look a little like a London Underground map, with circles for each stop. The CSS is currently selecting the :after property of my &...
2
votes
2answers
23 views

How to write a TypeScript function accepting a class implementing an interface as a parameter?

I want to write a function which accepts a class as an argument, but only classes which implement a specific interface. I know that I can use any, but it would be nice to rely on the type system to ...
0
votes
1answer
21 views

Ionic Popover button

I want to make a log out button at the end of the navbar. I made something like this: but I want to do like this:
0
votes
0answers
11 views

Asp.Net Mvc Core 2.1 ReactRedux with webpack and typescript

I created new Asp.Net Mvc Core 2.1 React Redux project. I added webpack and typescript to this project. Now that I try to run it, I get an error message: TimeoutException: The create-react-app server ...
-1
votes
1answer
36 views

Object inheritance in Typescript

I am trying to extend a class using typescript in angular and I am having this error: export class Product { constructor(public id?: number, public name?: string, public brand?: string, ...
0
votes
1answer
17 views

Convert a typescript enum into an array of enums

I have an enum export enum A{ X = 'x', Y = 'y', Z = 'z' } I want this to be converted to [A.X, A.Y, A.Z] Type of the array is A[]. How to do this?
0
votes
2answers
52 views

Parse Array without key in nativescript-angular2

JsonStructure: { "share": [ { "id": "1", "name": "Denver", "address": [ "people" ], "iconUrl": "" ...
1
vote
1answer
17 views

Type error in typescript casting a class that has static variables when using strictFunctionTypes

I just turned on strictFunctionTypes for my codebase and I got this error I can't quite wrap my head around. I have an interface that is meant to be a generic presentation of a class (...
0
votes
1answer
42 views

Observable does not get a value in template

In my Angular component isLoading$ Observable depends on counter$ and defines is it data loading: export class MediaQueriesWidgetComponent implements OnChanges, OnDestroy { // ... some code ...
1
vote
4answers
53 views

How to clear an typed array in typescript and preserving its type?

Now in a class, I declared an array with type: CustomType, like below class Example { public exampleArray: CustomType[]; public clearArray() { this.exampleArray = []; } } As you can see ...
0
votes
0answers
23 views

How to make a Redux connected higher order component in TypeScript?

I found a few examples https://gist.github.com/mikebridge/9abd8407a6f022c8f9d213d15c1c0426 https://www.triplet.fi/blog/react-higher-order-components-hoc-using-typescript/ I personally prefer number ...
0
votes
2answers
42 views

Want to know from where the data is received : TypeScript

I want to know from where my data is coming from which class, from which method let's take an example like EditValue(data) { /* my operations */ } Now there are multiple classes in my project ...
-1
votes
1answer
20 views

Typescript :Sort Object by value

Input let input = {"ab":"a","cd":"n","kl":"o"} Output let output = {"ab":"a","kl":"o","cd":"n"} Sort the object according to the value..
0
votes
1answer
28 views

Angular - How to access Map<K, V> values in DTO from JSON?

I have got 3 DTO-s inside eachother like this: export class firstDTO { public data: secondDTO; } export class secondDTO{ public data: Map<Color, thirdDTO>; } After I receive the JSON ...
0
votes
1answer
13 views

TypeScript: Any class that implements a particular interface

Let's say I have this interface interface CanFly { fly(): void; } And I will create two classes, Bird and AirPlane that both implement the above interface. And finally, I want to create a ...
1
vote
2answers
22 views

TS Property does not exist after just checking its existence

I have an object that a user passes, could be any kind of object. In the function I check for a prop, and if that exist I want to return it: if ('id' in payload) return payload.id I have declared ...
-1
votes
1answer
26 views

How to use Interface from @types/socket.io

I Have followed How-to-use socket.io with typescript article. In the article, they are installing @types/socket.io. However, when they are declaring a function that needs to get a socket, they are ...
-1
votes
1answer
14 views

'topFunction' is declared but its value is never read

in Angular project, i have given a function name called "topFunction" in my html page and written the function within the ngOnit() in component.ts ngOnInit() { function topFunction() { ... } ...
0
votes
0answers
13 views

Getting memory leak after keeping IE11 open for 2 days

Recently I found there is a memory leak in IE11 for angular6 application where i have several's tabs in application and each tab is having multiple graphs to show. There is no memory leak for sudden ...
-1
votes
1answer
31 views

Remove string which has <html> and <body> part

I want to remove text in between the some html tags. For example : <html xmln><head>............<body lang="">after this I need the text I am trying to remove <html> to <...
0
votes
1answer
26 views

Angular: page title service still get changes on navigation

I am facing the issue on browser navigation buttons. the scenario is like I have dynamic page title service that changes the browser title with routing. When a user logs in the website and then log ...
1
vote
1answer
26 views

Using a reusable component in Ionic 2 [duplicate]

I want to use a component in another component (home.html). But i get an error as : Error: Template parse errors: 'reusable' is not a known element: 1. If 'reusable' is an Angular component, then ...
1
vote
1answer
17 views

Firefox: how to serve sourcemaps for web extension

I'm developing a webextension based on typescript. For debugging, I need sourcemaps, both in the background and contentscripts. Currently, I'm using parcel to bundle my extension (but I don't think ...
1
vote
0answers
15 views

d3 rotate relate relative without coordinate

I append text and textPath to a path with d3.js. But the text is upside-down when the direction of the path is 1. I want to rotate the text 180 degrees to correct position。 But the trahsform-origin is ...
1
vote
0answers
11 views

Custom VSTS Extension: how to invoke dotnet tool in VSTS extension's build task script

I'm trying to create VSTS Build Task extension, that invoke following CLI command: libman restore Of course, the libman CLI does not have to be installed on the build agent, so I think it should ...
0
votes
1answer
15 views

Automatically include declaration files of libraries outside of node_modules in Typescript Angular cli project

I have a Angular Project that has a lib folder for cases where a node_module needs to be modified. I'm able to connect the lib folder with using tsconfigs paths options and actually can compile the ...
0
votes
2answers
16 views

The specified Date value does not conform to the required format Angular 5

In my Angular App , I am Showing data from API to component in input fields . All fields are getting populated but not Input element with type Date Below is html markup <input [(ngModel)]="...
1
vote
1answer
10 views

Type declaration for a function that returns a concrete class constructor

Consider the following code: abstract class AbstractFoo { } class Foo extends AbstractFoo { } class Bar { getFooConstructor(): typeof AbstractFoo { return Foo; } } let bar = new ...
1
vote
1answer
23 views

Function that returns a function that retrieves a membervariable

Consider: const compose = <S, T, R>(func1: (inp2: T) => R, func2: (inp: S) => T): (inp: S) => R => ((arg: S) => func1(func2(arg))); const not = (val: boolean): boolean => !...
-1
votes
0answers
20 views

How can I identify an element type from a “div” in React JS or Angular JS?

I am trying to store the XPaths of all the elements in my web page in a database. I can store the XPath and name/class of the element, but how do I get the type of element? I would like to know ...
1
vote
1answer
24 views

setting a value that can be A or B to a value that is A after checking

I have a value that can either be of Type A or B and one that is explicitly A: let valueOptional: A|B; let valueExplicit: A; Now i do a typecheck and then set the value: if ((typeof valueOptional)....
1
vote
1answer
30 views

Get all element attributes using protractor with Typescript?

I have seen this solution for getting all attributes with protractor: Get all element attributes using protractor But I am using typescript with Angular 6 and cannot seem to extend it with the above ...
0
votes
0answers
47 views

expected at least 0 arguments, but got 2

I am getting the type error, Expected 0 type arguments, but got 2 on updateRole() from the following code account-endpoint.service.ts getRoleByRoleNameEndpoint<T>(roleName: string): Observable&...
0
votes
0answers
21 views

How to set object as data attribute within the select option tag and access it in type script code

My requirement was that set selected obj as a data attribute within the option tag. <select blockUI="true" displayDelay="0" name="products" [(ngModel)]="model.selectedOption" style="width: ...
0
votes
1answer
40 views

Angular Cannot read property 'create' of undefined

I'm using Angular 6 and I want to implement the dynamic addition of components according to the instructions, but I get an error: "Cannot read property 'create' of undefined." component.html <mat-...
-1
votes
1answer
32 views

I, cannot set property 'IS_CHECK' of undefined TYPE ERROR

I'm trying to make a checkbox that when it selected everything should be selected. I handled the code using this link with angular 2 example. But I get an error called "ERROR TypeError: Cannot set ...