500 questions
1 vote
1 answer
67 views
Angular FormBuilder with spread operator on object with arrays has FormControls of the wrong type
I'm using the Angular FormBuilder (import { FormBuilder } from '@angular/forms';) to create my FormGroup and inner FormControls as this right now: formGroup = new FormBuilder().nonNullable.group({ ....
0 votes
1 answer
48 views
Is the spread operator (...) available in AssemblyScript?
I couldn't find any information about this in the AssemblyScript docs. Is the spread operator available in AssemblyScript? I would like to define an object like so: { ...params, category: "...
0 votes
2 answers
62 views
TypeScript misunderstanding. How to fix problem?
Have a code (typescriptPlayground) problem is in spread operator. in case of secondObjectFull i have an error. It is ok. firstObject cannot spread to secondFullMapped But in case of thirdObjectFull ...
-2 votes
3 answers
63 views
JavaScript 2D arrays and returning matching rows
I have 2 arrays, each is like a database table row set. array1 = [ ['AB2C', 'Red', 113], ['BE4F', 'Green', 164], ['AE3G', 'Blue', 143], ] array2 = [ [143, 'FabricB2', 'W5'], [189, 'FabricC9', 'W4'], [...
0 votes
0 answers
70 views
Type error when using generics and looping over functions
I have an object of methods which I am seeking to extend with copies of those methods but scoped to a given method e.g. the method fetchOnce() will have copies postOnce(), getOnce() etc. The original ...
0 votes
3 answers
267 views
Prepend an element to each list in a list
Let's say we have the following base list: [["foo"],["bar"]] and the input string "a" I want to prepend the input string to each list in the list, which results in: [[&...
0 votes
1 answer
80 views
Spread not works for Array(16) _wgpuMatrix.mat4.invert return NUll filled array
For matrix transformation i use wgpu-matrix library. I already have implemented raycast (hit object trigger) in other project. I wanna implement it also in my new project matrix-engine-wgpu. In this ...
0 votes
2 answers
180 views
Is there an easy way to merge object arrays using javascript ellipsis or similar?
let arr = [ {id: 1, data: {foo: "bar 1"}}, {id: 2, data: {foo: "bar 2"}} ]; //In case the ID does not exist just add as a new element on the array arr = [...arr, {id: 3, data: {foo: "bar 3"}}] ...
1 vote
1 answer
82 views
is there a typescript generic that handles T | T[] | "*"
I'm new to generics in typescript, it's confusing is there a way to make the spread operator ... work in the snippet below the issue the line [ key: U, ...rest: Reg[U] ], doesn't work as I expect the ...
2 votes
1 answer
356 views
How to create a type that enforces exclusion of properties in typescript when using spread operator?
I have a backend model with some properties that I want to be able to send to the frontend with certain properties excluded. I'd like to use typing to help me ensure they have been excluded. I tried ...
1 vote
0 answers
32 views
extract partial attributes of an object using typescript types [duplicate]
how to extract partial attributes of an object using typescript types? is it even possible? export interface Product { brandName: string; modelNo: string; rate: number | null; someOtherProp1: ...
1 vote
0 answers
43 views
Why does Javascript spread maintain defined keys that are set to undefined, and how do they differ from non-existent keys? [duplicate]
I have a code sample below that demonstrates this. I ran into this unexpected behavior of the spread operator where a key that gets set as undefined is not treated the same way keys that have never ...
1 vote
4 answers
177 views
Cannot use spread inside conditional operator [duplicate]
Suppose the following: const arr = [1, 2, 3]; const insertValues = [-1, 0]; const condition = true; arr.splice(0, 0, condition ? ...insertValues : insertValues); This throws a syntax error: ...
0 votes
0 answers
60 views
Using immutability-helper or spread op to make changes to an object, what is better: repeatedly $set, or $merge only once an object with all changes?
In my state I have a dictionary of a flat object: export interface INodeVisibility { id: string; level: number; isExpanded: boolean; } export type NodeVisibilityDict = { [key: string]: ...
1 vote
1 answer
128 views
React State modification despite the fact I used spread operator to avoid direct modification of it
I tried to use spread operator to avoid modifications of my state without the use the set State. But despite that, my state is still modified. I can eventually make a deepCopy of my state but I don't ...