Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

additional properties for attributes #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,21 @@ export interface Attribute {
*/
defaultValue?: string;

/**
* Possible values of the attribute, if any.
*/
possibleValues?: string[];

/**
* If Type is numeric and has a minimum constraint.
*/
min?: string;

/**
* If Type is numeric and has a maximum constraint.
*/
max?: string;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case that you had these values by default, would they not likely be defined by the type? e.g.

type AllowedStrings = 'one of' | 'two of' | 'three of';
// ....
public myProp: AllowedStrings = 'one of';

Etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get what you mean. What is if the type is "numeric" and max is 9999. Would you list all values?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like maybe this is both “state of the art” and a little early, but possibly the approach that would make sense. microsoft/TypeScript#43505 Would have thought there’d already be types for this, but without the min/max makes more sense.

Copy link
Contributor Author

@jogibear9988 jogibear9988 May 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is if it's a number enum? as I said in #51
The combined type 1 | 2 | 3 would not help much.
You would know wich values are valid, but no meaning behind them.

/**
* The name of the field this attribute is associated with, if any.
*/
Expand Down