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

Read from array1 write from array2
Type Mismatch in Array
Subtracting from each element in array in python
C# Problems importing a file to an array and put each character in it's own index
How to identify the position of a sequence of elements in an array in bash
Combine values of two arrays to form key and values to hash in ruby [duplicate]
Create array with key from dict with sorted by dict values
How do I convert every element in an array to its own array?
Adding a list to an array from different file format in perl
How to use Perl `sort` and `pairwise` if I already have variables `$a` and `$b`
Sum dynamic part of array values Excel VBA
Ada How to get input a list of integer from a user and put it into an array
count occurences in for loop
Update / create subdocument in array
Delphi: const list of const objects [duplicate]
Fastest way to search through a CSV and return specific array of values (Ruby)

Categories

HOME
google-apps-script
numpy
blockchain
firebase-app-indexing
aem
mapbox-gl-js
tomcat7
concourse
simpy
criteria
powershell-v3.0
outlook-web-addins
google-shopping
webmethods
sendkeys
scenebuilder
tree-traversal
zoho
ip-camera
jquery-waypoints
bootstrap-typeahead
searchbar
net-snmp
continuous-deployment
ui5
cep
helper
piecewise
apache-cloudstack
read-write
polymorphism
npm-shrinkwrap
sidr
xen
autocompletetextview
discord.net
elfinder
strstr
initializer
freetts
soundjs
android-preferences
dart-pub
control-flow-graph
median
lftp
lumen-5.3
floor
defold
dimple.js
broadcast
applepayjs
workflow-foundation-4.5
ticker
heroku-postgres
search-box
cfeclipse
packagemaker
zurb-foundation-apps
scalar
multifile-uploader
mercurial-hook
squirrel
gemini
magento-1.4
site-prism
datasnap
selendroid
jericho-html-parser
oai
urn
pyopengl
twitter-rest-api
crash-dumps
jazz
adodb
jcr-sql2
left-recursion
fragment-tab-host
grunt-express
snmp4j
proxies
picat
config-files
reserved-words
broadcasting
visual-studio-addins
shortcuts
zend-lucene
graph-coloring
maven-ear-plugin
pstree
hibernate3
datacontract
phpcrawl
getresource
open-graph-beta
requestfactory
google-instant
graph-layout
microsoft.ink
data-entry
msf
web-analytics-tools





Mobile Apps Dev
Database Users
javascript
java
csharp
php
android


MS Developer
developer works
python
ios
c
html
jquery


RDBMS discuss