Skip to content

Defining dynamic but consistent types #97

@js-jslog

Description

@js-jslog

The FooByUser object is a simple structure representing the amount of foo performed by each user, setting each property's key & value to the username & recorded foo respectively.

The collection of keys composing the object may vary between objects representing different periods. For example if new user3 records foo in April then the March and April objects will differ in keys : {user1: 100, user2: 3} vs {user1: 87, user2: 5, user3: 30 }.

From a code documentation perspective I want to define FooByUser as having a set of property keys of known origin & type (if such a word can be used), but which cannot be predetermined for each particular instance.

Could we have a syntax something like the following?

interface FooByUser {
  *<username>: Number
}
def username {
  desc:    "The username of a user",
  source: {type: "database", location: "users.id"} 
}

Where the <> demonstrate that that we are using a def rather than a static key and the * represents that there may be more than one of these keys.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions