Skip to main content
1 vote
1 answer
60 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({ ....
Kevin Cruijssen's user avatar
0 votes
1 answer
46 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: "...
Paul Razvan Berg's user avatar
0 votes
2 answers
60 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 ...
Andrew M's user avatar
-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'], [...
Liquid Nitrogen's user avatar
0 votes
0 answers
67 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 ...
wheresrhys's user avatar
  • 23.7k
0 votes
3 answers
251 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: [[&...
rph's user avatar
  • 2,679
0 votes
1 answer
79 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 ...
Nikola Lukic's user avatar
  • 4,292
0 votes
2 answers
178 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"}}] ...
David's user avatar
  • 668
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 ...
azzmi's user avatar
  • 75
2 votes
1 answer
349 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 ...
Tom's user avatar
  • 2,454
1 vote
0 answers
29 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: ...
muon's user avatar
  • 14.2k
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 ...
Summitch's user avatar
  • 389
1 vote
4 answers
170 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: ...
Mike K's user avatar
  • 6,625
0 votes
0 answers
56 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]: ...
Sammybar's user avatar
1 vote
1 answer
125 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 ...
Poumon's user avatar
  • 61

15 30 50 per page
1
2 3 4 5
34