arrays


Creating an interface with an array of variable length, containing objects in TypeScript/Angular4


I am attempting to create a variable within an in-memory database that contains a TypeScript interface that describes a JSON dataset. This dataset should contain multiple arrays, which in turn contain multiple objects with a fixed length and consistent attributes.
I am writing this in Angular4 and TypeScript. The arrays must be of variable length with a minimum of 1 member
I've written this pseudo code to show you what I mean:
export class MyHomeBrewery {
taps: Array<any> = [{
id: number;
name: string;
type: string;
quantity: number;
}][...];
barrels: Array<any> {
id: number;
name: string;
width: number;
height: number;
quantity: number;
}][...];
I've had a look through the TypeScript and Angular documentation and done a few searches and I can't find the correct syntax for this. Does anyone know?
You should be using them as interfaces as below
export interface MyHomeBrewery {
taps: Array<Taps>;
barrels: Array<Barrels>;
}
export interface Taps {
id: number;
name: string;
type: string;
quantity: number;
}
export interface Barrels {
id : number;
name: string;
width: number;
height: number;
quantity: number;
}

Related Links

Mysterious “extra argument in call” error in Array extension method [duplicate]
Recursively setting hash keys from an array of keys
Putting the count of a loop in an array index
How do I compare numbers in a string array?
Giving structure to a flat data array
Why is an array sometimes used as a key in JSON when this array has only one entry that contains a dictionary?
How to get value of array key from query in golang
Strongloop Loopback: where filter with two arrays
Mapping Json with nested array using ObjectMapper Swift 3
how to calculate the values of a 4d array by bilinear interpolation without 4 'for' loop
How to compare a random UIColor to colors in an array of colors in swift?
Express.js req.body parametr array
how to parse json array in android using volley
how to get one dimensional vector from an array in vba
How to split data when qr code reader device read c#?
Swift 3: How to Insert Array of an NSObject to another Array [duplicate]

Categories

HOME
shopify
tinyos
nlp
amazon-swf
ipython
avro
zend-framework2
mainframe
algorithmic-trading
spring-cloud-contract
pygame
onenote-api
hashicorp-vault
public-key-encryption
rhapsody
google-api-java-client
shippo
plsqldeveloper
sensu
nmf
iis-10
onesignal
lync-2013
cep
mayavi
data-conversion
dpi
websauna
ivy
powershell-remoting
ksoap
mms
redhat-datavirt
xamarin.uitest
elfinder
image-compression
exiftool
google-account
pytest-django
rkt
startapp
amazon-clouddrive
vcf
data-integration
amazon-machine-learning
goquery
tiddlywiki
windows-95
google-maps-ios
heroku-postgres
quintus
pycurl
iphone-developer-program
bettercms
vici
gradle-script-kotlin
libreadline
spring-ioc
push-diffusion
packagemaker
debugdiag
webkit2
foxit
spatial-query
selecteditem
post-processing
group-concat
brackets-shell
plone-3.x
selendroid
jericho-html-parser
anti-patterns
wif
connection-reset
ffprobe
c++-actor-framework
mser
cg
node-imagemagick
getimagedata
coin-flipping
broadcasting
android-json-rpc
bignum
onselect
leptonica
dllexport
prng
radchart
point-sprites
entity-framework-ctp5
for-xml-path
libavformat
hibernate3-maven-plugin
visual-c++-2008-express
oggvorbis
plinq
windows-controls
data-entry

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App