Hey there, how's everyone doing today? I'm venturing into something new and different, stepping slightly away from the usual concept but aiming to accomplish my goal in a more refined manner. Currently, I am utilizing a repository pattern and l ...
Can anyone explain why I am unable to utilize the Pick utility type in order to select a property from my interface and apply it to type my component's state? This is what my interface looks like: export interface IBooking { ... propertyId: strin ...
Does TypeScript have a predefined "primitive" type or similar concept? Like type primitive = 'number' | 'boolean' | 'string';. I'm aware I could define it manually, but having it built-in would be neat. ...
In my software library, there exists a map function with the following definitions: function map<T, U>(f: (x: T) => U, a: Array<T>): Array<U> function map<T, U>(f: (x: T) => U, a: Functor<T>): Functor<U> Furtherm ...
I'm currently working on a project using React, TypeScript, and styled components along with the material-ui library. I have created styled material-ui buttons as shown below: import React from 'react' import styled from 'styled-compone ...
I'm currently utilizing an API call to retrieve an image from a service, and I would like to display a progress bar while the image is being fetched. It seems that I need to incorporate the progress bar within the service as the image data is returned ...
Is there a way to avoid using ts-ignore when using object properties referenced as strings in TypeScript? For example, if I have something like: const myList = ['aaa', 'bbb', 'ccc']; const appContext = {}; for (let i=0; i< ...
I am currently working with TypeScript and need to determine if a JSX.Element instance is a subclass of another React component. For instance, if I have a Vehicle component and a Car component that extends it, then when given a JSX.Element generated from ...
I'm working with TypeScript and have the following code snippet: type SportJournal = { type: 'S', sport: boolean, id: string} type ArtJournal = { type: 'A', art: boolean, id: string} type Journal = SportJournal | ArtJournal; type J ...
I am currently in the process of migrating my code from version 1.x to 2.x of @ngrx/effects. Previously, in version 1.x, I was able to access the state tree directly within an effect: constructor(private updates$: StateUpdates<AppState>) {} @E ...
Utilizing Express, I have set specific fields on the request object to leverage a TypeScript feature. To achieve this, I created a custom interface that extends Express's Request and includes the additional fields. These fields are initialized at the ...
Hey there, I am currently working with 3 different APIs that require unique auth tokens for authentication. My goal is to set up 3 separate HTTP interceptors, one for each API. While I'm familiar with creating a generic httpInterceptor for the entire ...
Can you give me your thoughts on how to post an array with some object? This is the code I am working with: const selectedJobs = this.ms.selectedItems; if (!selectedJobs) { return; } const selectedJobsId = selectedJobs.map((jobsId) => ...
Can you guide me on how to verify and create a URL under different circumstances? I am dealing with 3 cases that involve different types of objects: "repositories": { "toto": { "tata": "https://google.com/", ...
Having an issue with utilizing the Cascader component from AntDesign and managing its values upon change. The error arises when attempting to assign an onChange function to the onChange property of the component. Referencing the code snippet extracted dire ...
Just a simple query here... my goal is to extract data.user.roles, but there's a possibility that data may be empty. In such cases, I want an empty array as the output. Additionally, I need to specify the type of user - which in this instance is any. ...
Having some trouble using pdftron with my docx editor. I can use the editor fine, but keep encountering an error like the one shown below: https://i.stack.imgur.com/OnJxE.png https://i.stack.imgur.com/l9Oxt.png Here is a snippet of my code: wordeditor.t ...
I am currently working on testing my Create-User-Component which relies on an Auth Service that includes methods like 'login, logout,' etc. The Auth Service imports both AngularFireAuth and AngularFirestore, and it is responsible for handling da ...
When I responded to the query on whether Typescript Interfaces can express co-occurrence constraints for properties, I shared the following code snippet: type None<T> = {[K in keyof T]?: never} type EitherOrBoth<T1, T2> = T1 & None<T2&g ...
At my workplace, there is a practice in the legacy code where every single model is imported into all components, regardless of whether they are needed or not. For example: import * as models from '../../view-models/models' ....... let parrot: m ...
I'm currently developing a web application using DevExtreme JQuery. Within the frontend, I have set up a DataGrid in a cshtml file. With DevExtreme functionality, it's possible to include an Add Button to the DataGrid that triggers a popup for in ...
I am trying to dynamically add a class to a div based on two conditions. To achieve this, I have created a custom directive as shown below: import { Directive, HostBinding, Input } from '@angular/core'; @Directive({ selector: '[confirmdia ...
I have a unique yarn monorepo structure that is oddly shaped. Here's how it's set up: monorepo root ├── frontend │ ├── dashboard <-- not managed by yarn workspaces │ | ├── src │ | ├── node_modules │ ...
I'm in the process of indexing the created_at and updated_at columns using knex js. However, when I try to use the index() function, I encounter the following error: Property 'index' does not exist on type 'void' await knex.sche ...
Within parent.component.html The HTML code I have implemented is as follows: <button type="button" class="btn btn-secondary (click)="AddComponentAdd()">Address</button> <app-addresse *ngFor="let addres of collOfAdd" [add]="addres">< ...
I encountered an issue when trying to set up an event listener for clicks. The error message I received was that classList does not exist on type EventTarget. class UIModal extends React.Component<Props> { handleClick = (e: Event) => { ...
Issue with Material UI Table Display When Changing Pages When receiving an array of Artist Objects through props to create a checklist table, I encounter some display issues. The table works fine initially, but when changing pages or sorting, more rows th ...
I've noticed that the types for @hapi/joi appear to be outdated - some configuration parameters mentioned in the official documentation are missing from the types. To address this, I am attempting to enhance the existing types. node_modules/@types/ha ...
This particular situation was a bit perplexing for me. When I use the search function, I am seeking substring matches of the search keywords. Therefore, before comparing any object, I convert all properties to strings and check for substrings. Based on my ...
I am currently facing a challenge in defining a function that can wrap any other function while maintaining the parameter types and return type. I have managed to achieve this when the function does not use generics, but I am encountering difficulties wi ...
When calling the sendEmail method, emails can be sent to either a single user or multiple users (with the variable type string | string[]). I'm trying to find a more efficient and cleaner way to distinguish between the two in order to search for them ...
I'm having trouble understanding the following lambda function definition in TypeScript. It could be a beginner question. type P = { id: string } type F = <T>(x: T) => string const f: F = (x: P) => x.id f({ id: 'abc' } However, ...
I'm currently working on a file called createCheckoutSession.ts: import { db } from '../firebase/firebaseInit'; import { collection, addDoc, onSnapshot } from 'firebase/firestore'; import { User } from 'firebase/auth'; e ...
I'm trying to find a method similar to keyof typeof myModule in typescript. However, instead of a union of key strings, I need a union of the value types. I have a module with an increasing number of exports - myModule.ts: export const Thing1; expor ...
I recently came across this intriguing playground example outlining a scenario where I attempted to convert an object literal into an object with specific properties, but encountered unexpected results. class X { y: string; get hi(): string { ...
Can decorators be used on parameters within an arrow function at this time? For instance: const func: Function = (@Decorator param: any) => { ... } or class SomeClass { public classProp: Function = (@Decorator param: any) => { ... } } Neither W ...
I have been working on a project using Angular 2, where I created a dropdown component with the following code: @Component({ selector: 'dropdown', template: ` <div class="row" > <div class="col-sm-3"> ...
Here is the affected code with Typescript errors in local. The component name is correct: {template.elements.map((element: TemplateElementModel, i) => { const stand = roomStands?.find( (stand: ExhibitorModel) => stand.standN ...
I'm in the process of creating a tool to automatically generate boilerplate code for me. The concept involves parsing all .json files within a folder called config, and then creating interfaces and auxiliary functions based on that data. Thanks to t ...
My issue is very similar to the one mentioned in this thread: Typescript: instance of an abstract class, however, there are some distinctions. If it is indeed a duplicate problem, I would appreciate a clear explanation as I am currently unable to resolve t ...
In my TypeScript monorepo utilizing NPM Workspaces, I have two packages: A and B. Package B requires type definitions from package A. To accomplish this, I included a reference to A's definition file in the tsconfig.json of package B. However, somet ...
I am encountering an issue with the following code snippet: var headers = new Headers(); // headers.append('Content-Type', 'application/json'); headers.append('Content-Type ...
I have written the following code snippet: export function myIsEmpty(input?: unknown): boolean { if (input === undefined || input === null) { return true; } if (input instanceof Array) { return input.length === 0; } return input == false; ...
I would like developers to use a class or interface instead of directly importing functions. Is there a way to restrict so only the class can import the function? I prefer not to consolidate all the functions in a single file, especially in a large proje ...
I'm currently working on writing Jest tests for my TypeScript code. To ensure compatibility with older browsers, I have included some polyfills and other necessary imports for side effects. Here is a snippet of my code (variables changed for anonymit ...
Currently, I am debugging my ng2 application using console logs. When logging an array, it shows an AnonymousSubject with the following attributes: AnonymousSubject _isScalar:false closed:false destination:AnonymousSubject hasError:false isStopped:false o ...
Issues are arising as I attempt to utilize a Proxy. The structure of my class is as follows: export class Builder { public doSomething(...args: (string | number | Raw | Object)[]): this { // Do stuff return this } } export class M ...
In my code, there is an abstract class: export default abstract class TableAction<T = any, R = any> extends React.Component<T, R> { protected abstract onClick(e: React.MouseEvent<HTMLButtonElement>): void | Promise<void>; pr ...
I have a button with a click event that opens a dropdown list. I would like for the button text to be updated and for the selected option to be removed from the dropdown list when the user makes a selection. Currently, using {{interestSortingOptions.label} ...
Whenever this code is executed, the following error is displayed: Cannot read property 'filter' of undefined contrat: Contrat[]; gpss: GPS[]; homeboxp: HomeboxP[]; sensors: Sensors[]; homebox: Homebox[]; getProductName(productid: s ...
Is there a way to create a Json with field names that contain dots '.' in a JavaScript application (specifically, TypeScript)? This is the expected Json output: { "tasks.max": "1", "key.converter": "io. ...
Is it possible to define the name and components in a <script setup> mode? In a <script> mode, you can do something like this: export default { name: 'App', props: ['foo', 'greetingMessage'], components: { ...
In my code, I have the following declaration: const x : A | (A & B) I am curious if there exists a way to introduce an "optional" version of the & operator so that I can write more succinctly like this: const x : A &? B This would indicate th ...
Presently, I have developed two distinct frontend applications. One is a lightweight mobile client, and the other is a heavy administration panel. Both of these were built using Create React App (CRA), utilizing TypeScript throughout. The current director ...
Exploring the usage of top-level await with Node and TypeScript has been my current experiment. import { readFile } from "fs/promises"; async function getNum(filename: string) { return parseInt(await readFile(filename, "utf8"), 10); ...
I'm currently in search of a solution for using BaseService to handle common methods for Objection models. While it works well with UserService, I'm looking to implement some additional methods in the BaseService class. base.service.ts class Bas ...
My current project involves managing a product with multiple providers, each having its own price. The challenge I am facing is that when using populate() to retrieve provider information by ID, it returns the data as a string instead of JSON format. Below ...
Show me a similar example of what I'm attempting to accomplish. Is there a way to achieve this in SvelteKit without having to create an additional file just for the "GET_2" endpoint? // +server.ts export const GET: RequestHandler = async () => { ...
I recently started using the jest-cucumber library to execute my jest tests in BDD format. However, when I try running a sample test, I encounter the following issue: ? Given Test for given step Undefined. Implement with the following snippet: ...
Recently, I made the leap from angular 7 to angular 11 in my app. Everything was running smoothly until I decided to incorporate angular universal for server-side rendering. Shortly after implementing server-side rendering, a flurry of errors cropped up, ...
Currently, I am facing an issue with TypeScript where I need to call a Modal within a function. The problem arises when a service is called to validate certain data from the server asynchronously. Depending on the response received from the server, I want ...
In my app, I have a scenario where I need to fetch JSON data in a series of "category data" subscriptions inside a for loop. This data is then filtered based on the user's current location. The issue I'm facing is that my app doesn't wait fo ...
Struggling with updating my UI using React and useState. Any help would be greatly appreciated. I am trying to remove an item that a user added. interface Links { link: string; } const [redirectLinks, setRedirectLinks] = useState<Links[]>([ { ...
Currently, I have a few npm packages that are crucial for our internal company projects. I am looking to open up some of the interfaces utilized by these dependencies from within this component. For instance, in a project involving an npm package named "c ...
Using a custom dropdown created with div, I encountered an issue when receiving an object response cards from the API. The problem arises when trying to iterate through the data using the custom dropdown - after selecting an item, the next clicked dropdown ...
This snippet is written in Angular and involves using a variable to modify a conditional statement without having to repeatedly update every variable type. The code snippet below showcases an example in an HTML input tag. import { FormBuilder, FormGroup, V ...
I am encountering an issue in my TypeScript project where the date selected by users is not being parsed correctly. For example: (JSON) "IssueDate":"Wed Jan 18 2017 00:00:00 GMT+0200 (Jordan Standard Time)" However, when I try to parse the object using ...
Embarking on my journey to create my inaugural Yeoman generator using TypeScript, I have encountered some challenges. While my TypeScript code transpiles smoothly into JavaScript and the basic test Yeoman generator functions properly, I am puzzled by the e ...
I am working on synchronizing a postgresql database with data from a remote API at regular intervals. The script will make API calls at scheduled times, process the responses, and update the database with the relevant information for each record. Below i ...
I have an array of numbers like this: const dataset = [0.5, 2, 1, 93, 67.5, 1, 7, 34]; The minimum value is 0.5 and the maximum value is 93. I want to round the extremes of this dataset to a specified step value. For example: If step = 5, the result sho ...
Here is the data I am working with: { "2022-06-01": { "09:00am": { "time_table_id": 1, "job_id": 4, "start_working_time": "09:00am", "end_working_time": &qu ...
I have a unique sample object that needs to be transformed into form controls: [ { "labelName": "Full Name", "inputType": "textbox", "inputValues": "", "ma ...
When it comes to JavaScript, the spread syntax allows for one object to be spread into another object like this: const a = {one: 1, two: 2} const b = {...a, three: 3} // = {one: 1, two: 2, three: 3} But what about spreading a TypeScript interface into an ...
Just starting out with Angular and experimenting with Angular forms. Even though I followed a tutorial and copied the code below, I keep encountering the following error: Property 'updateEmployeeName' does not exist on type 'ContactFormCom ...
I currently have a function signature that looks like this: getProperty<T extends HTMLElement>(name: keyof T): Promise<T[keyof T]>; While developing Web Components that extend HTMLElement, I have included a property named rows which stores va ...