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

Creating a new string literal type based on another

The CSS.Pseudo types of csstypes have a bunch of CSS selectors like for ':hover' , ':active' and so on. Is it possible to create a new type based on CSS.Pseudo, which accepts all the CSS.Pseudo types ...
0
votes
0answers
2 views

Converting circular structure to JSON in a trivial Firebase Function

Error message: Error: function crashed. Details: Converting circular structure to JSON I receive the error despite a trivial code that should work. It must be something with regards to the Firebase ...
1
vote
0answers
6 views

TS rxjs-compat doesn't support prototype operators?

I'm following this migration guide to update from rxjs 5.5.5 to 6..**. It looks from this article and many other posts that simply having rxjs-compat in my project will allow to migrate step-by-step. ...
0
votes
0answers
3 views

A Jasmine spec timed out. Resetting the WebDriver Control Flow

I am getting Jasmine spec timed out. Resetting the WebDriver Control Flow. I have also used fakesyn before but getting same error message as above. Please help me This is my specs: describe('...
0
votes
1answer
10 views

Is it possible to use async/await when invoking a method specified by an inteface?

Given: export interface UserAuthenticator { async isValid(username: string, password: string): Promise<boolean> } Compiling generates error message TS1070: 'async' modifier ...
0
votes
0answers
9 views

Ensuring Object does not exist in Array [duplicate]

I am trying to ensure that my list does not contain an object that has just been instantiated. In it's current form the code lets any element into the list. Any suggestions would be greatly ...
1
vote
1answer
21 views

How to force change detection on input when input value doesn't change

Currently on Angular 7. A component input is a boolean value that may stay the same after falling into and out of an indeterminate state. For example: I have expandable rows that can be opened ...
0
votes
0answers
5 views

Having unused 'mergedProps' parameter on 'connect' throws error on component rendering

I'm using Redux for my current Typescript React project and have a bit of a hard time to get into it. Connecting components works fine so far for me though. interface OwnProps { ownProp?: boolean;...
0
votes
1answer
13 views

Can you enforce a key on an object but let typescript deduce the type of Value?

I am trying to create an object where I would like to enforce the keys, but am happy to let typescript deduce the types of the values. A quick example is const fooVals = { a: null, b: null, c:...
0
votes
0answers
6 views

require('fs-extra') not loading: throwing error “Cant find module fs-extra”

Trying to use some installed npm packages like fs-extra into below js files given by Truffle.But it says "can't find module "fs-extra". 1) Tried importing local js files using require() method but ...
0
votes
1answer
9 views

Generic repository that creates instances of generic type

I'm trying to write a generic repository in TypeScript that serializes/deserializes using localStorage. I've read many related questions regarding new() in ts, but they are full of foos, bars and ...
0
votes
0answers
6 views

Horizontal stacked bar chart with d3.js on angular 7

I'm trying to adapt example https://codepen.io/goodforenergy/pen/PNPxxv on Angular 7 using d3.js 5+ version. Here is part of my typescript code: const width = sizes.width - margins.left - margins....
1
vote
1answer
16 views

TypeError: book.isEqual is not a function

A method defined in a Class is not recognized as a function when called in an other class. file : models/book.model.ts export class Book { constructor(public title: string, public author: string)...
-2
votes
2answers
23 views

ngModel default value setting doesnt receive info from model

I have a form and I want to set some default values to be shown inside it. I have tried the following code: <h3>ِStart Time</h3> <div class="row" > <div class="col">...
0
votes
0answers
8 views

Validation for Material Design (dialog-)form

I got some problems with the validation of the Material Design dialog. Tried so much different ways of validation (Bootstrap) but nothing really works. Anyone got a solution for it? Tried many ways ...
0
votes
1answer
10 views

typescript does not find jszip types

I have a strange issue where typescript does not find the types for jszip. other types work fine the types seem to be in the correct location in my source-file I use these imports e.g. import * ...
0
votes
0answers
14 views

Distribute values over keys in TypeScript

I have a list of 7 keys and 4 values ('A', 'B', 'C', 'D') I want to distribute the values to the keys so that I will have in the end value 'A' once, value 'B' once, value 'C' twice and value 'D' ...
0
votes
0answers
9 views

How to use a .d.ts without generate a module

I'm writing types for plugins in kuzzle.io I would like to define the shape of a Kuzzle plugin using ts, there is no import in the file atm, so I decided to make a .d.ts file Here is the shape : ...
0
votes
1answer
13 views

Import typescript files based on naming convention in React Native

So I have three ts files named as below : MyModule.ios.ts MyModule.android.ts MyModule.ts ( this is empty ) first two files have a method named : setup() which need to run based on platform Also ...
0
votes
1answer
23 views

Subscribe to a service of a local library

I have created an Angular library, which gets build with ngpackagr when I build my main application. Everything works fine, however I now have following use-case: In my library I have a service, ...
1
vote
1answer
33 views

Angular - change objects to array and make it listen to on change

This problem is very basic, I know, but I need help in the following situation. First I want to use the balance value of the Fix interface in a single array, to add it to the chart.js data and the ...
0
votes
2answers
35 views

Iterating through list of items, show allocated image on hover

I'm currently trying to display a list of names and its allocated images. Therefore I've created a service containing all the name and their images (ignore link): import { Case } from './case'; ...
0
votes
0answers
8 views

Setting the namespace and default namespace when transforming with i18next-scanner

I am working on a React Native project done with Typescript. The project has a modular structure, and each module has it's own translated strings. The problem is that when I generate the translations, ...
1
vote
0answers
15 views

Angular 8 lazy routes resolve with and without prefix and redirect before parent

I am trying to work with the router and lazy loading in angular 8. I have previously successfully used it in Angular 7. I have a few basic routes which are as follows: /home /auth /auth/login /auth/...
0
votes
2answers
50 views

How to build an array of promises' responses using for loop?

I'm building an Angular app to show my website's articles and votes and I want to show them sorted based on their vote. I can retrieve votes making http calls, in particular: I have to make a http ...
0
votes
1answer
10 views

NestJs TypeORM async configuration

I am trying to use the @nestjs/typeorm module and using the async configuration. In my app.module.ts I have the following: @Module({ controllers: [ AppController, ], exports: [ConfigModule],...
0
votes
2answers
26 views

Angular Relative Form Based On Drop down value need to change

I have a Reactive form in angular 7 that containing 2 dropdowns (select) working as cascading dropdown, the problem the cascading dropdown not works, when I choose the first select box [object Object] ...
0
votes
0answers
12 views

Is it possible to concatenate and emit output to more than one file with TypeScript?

How to set up tsconfig.json parameters to concatenate and emit output to more than one main file? I am able to generate .js files in to different directories, but I would like to concatenate them as ...
0
votes
2answers
20 views

How can I declare several variables within an array directly in TypeScript

I need to declare several variables of the same type (interface) at the time that I declare an array. I am using it in an Angular 8 project, obviously using typescript. I have this now: export ...
0
votes
1answer
20 views

Extending connected stateful connected component

I would like to create a base Redux component with its own state and properties. When I extend it in a generic way, I want to merge the extended object's properties and state also with the base. This ...
-2
votes
0answers
21 views

Firefox 'Cross-Origin Request Blocked' withcredentials [duplicate]

i tried to open my app angular in firfox but i have the below warning, and the app does not open Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at ...
0
votes
0answers
21 views

Is it possible to run transpiled JS code (from Typescript) in place of TS files with React Native?

Recently we have been working on converting our React Native application from using Javascript to Typescript. I have our app working with Typescript just fine. However, I have been asked to determine ...
-1
votes
2answers
38 views

How can I switch between angular components without reloading the entire webpage?

I'm trying to create three components that can be switched between with a navbar at the top. When I click on the navbar to switch to a different component, I want the navbar to stay static at the top ...
0
votes
1answer
17 views

Failed to load module script

After deploying an angular app on herocu, a blank page is shown when URL is reached and in console its showing MIME type errors. error is : Failed to load module script: The server responded with ...
-1
votes
0answers
22 views

Can I specify a generic type on an interface?

I am trying to write a nice sessionstorage decorator, that should work about like this psuedocode: const barConfig = { key: 'bar', parameter: 'bar', inflator: JSONBar:object => new Bar(...
0
votes
0answers
22 views

How to update array and save the select input [duplicate]

I'm working in a code using google maps and ionic, but I can't resolve a problem. My project is to create a map and the user click on it, then will create a marker on the point clicked, then the user ...
0
votes
0answers
21 views

How to access this in closures? [duplicate]

I have one function which sets class variable to Konva.Stage and I want to add event listener to this variable in same function. But unfortunately I cannot access other class functions and variables ...
-1
votes
1answer
34 views

Creating a forum with Laravel but having problems with Angular

I'm creating a forum with users, posts and comments with Laravel and now I have to use Angular but I'm new to it so I have no Idea where to begin. I've tried to return the json data from my laravel ...
2
votes
1answer
19 views

typescript: decorator in abstract method

I have the following class: export abstract class CanDeactivateComponent { abstract canLeavePage(): boolean; abstract onPageLeave(): void; @someDecorator abstract canDeactivateBeforeUnload():...
2
votes
1answer
17 views

Jest configure typescript without webpack

Well I'm writing some NPM module with typescript, but i'm not using Webpack to compile the scripts. how should I configure jest to run properly with typescript files? // test.spec.ts import {calc} ...
1
vote
2answers
23 views

Typescript: define interface without specific keys & chain objects

I have such example of data, that I receive: { Europe: { WestEurope: { Belgium: [French, English, Dutch] } } } Not sure how I can create an interface for such a dynamic structure, ...
-1
votes
1answer
21 views

Typescript package to one .js file

I have some typescript library downloaded from GitHub I see many dependencies to other npm packages Is it possible to built it to one .js file by npm, webpack etc? I want to avoid "export/import" js ...
0
votes
1answer
52 views

How to load custom javascript code in Angular 7

I'm trying to load js file in my not-found component. I'm reed information from https://www.truecodex.com/course/angular-6/how-to-use-external-js-files-and-javascript-code-in-angular So, create file,...
0
votes
1answer
43 views

Call function into an Array structure

i'm trying to generate an array from a function in typescript. My array looks like this: model = { roles: { 4: true } }; i need to change the values 4 with a function that generate values ...
-4
votes
0answers
15 views

“[object Object] error” when a .ts file is executed in selenium

When a .ts file is executed in selenium; [object Object] thrown is displayed. Spec files are not executed [object Object] thrown
0
votes
1answer
26 views

How to access a variable data in typescript, or javascript

I would suggest you see the code first and read this. I'm trying to access the data of eventClick that is in "options" object like shown in the code. the problem is if want to access the data outside ...
1
vote
1answer
17 views

Implementing 'active' css class on active ion-slide

I want to change css of active slide in DOM .html <ion-slides> <ion-slide class="swiper-slide"></ion-slide> <ion-slide class="swiper-slide active"></ion-slide> /...
0
votes
1answer
20 views

Update the document by separating array into objects using the string as first object in any array

I have a document like below { "_id" : ObjectId("5d0768f50557b958f0c6c9cf"), "list" : [ "abc", "xyz", "mno" ], "timestamp" : "2019-06-17T10:18:29.986Z" } I ...
0
votes
2answers
28 views

Typescript | Argument of type '{ username: string; password: string; }' is not assignable to parameter of type 'string'

I have this simple service that takes and endpoint and execute a HTTP_CALL. This is it below: export const updatePassword = (data: { username: string; password: string; }): HttpResponse<string&...
0
votes
0answers
13 views

Errors while implementing contextAPI with react and typescript

I have been trying to use contextAPI , where I will pass down an instance of tinycache(https://github.com/andyburke/tinycache) for the caching purposes. I am trying to pass down a single instance of ...