-
Notifications
You must be signed in to change notification settings - Fork 5
Upgrade json-schema-to-typescript, update schema, switch to eslint #34
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
Conversation
eablack
commented
Jun 14, 2024
- Update json-schema-to-typescript to v14
- Update types to latest json.schema
- Replace tslint with latest eslint
- Introduce script for updating the types
| * result of postdeploy script | ||
| */ | ||
| export type Postdeploy = { | ||
| [k: string]: unknown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have strong reservations about this. The ability to append arbitrary keys and make all properties optional to every interface within this schema is generally not useful.
This is a Postdeploy object according to this schema. It's also a PlatformAddOnPlanAction. It's also literally any type in this schema.
const actions: Postdeploy = { notThere: 'myValue' };
This usually indicates a mistake but TS allows it to go on it's merry way.
Also, this will mandate the use of the optional chaining operator when reading keys:
const postdeploy: Postdeploy = {exit_code: 0};
if (postdeploy?.exit_code === 0) {
// Do stuff
}
PostDeploy.exit_code is also listed as readonly in the schema but it's optional/read/write in the interface
"exit_code": {
"description": "The exit code of the postdeploy script",
"example": 1,
"readOnly": true,
"type": [
"integer"
]
}
|
I'm not sure this new schema alleviates the problems we have with the existing one. I believe we need a parser that understand JSON Hyper-Schema since this is what is specified in the Heroku API JSON document. e.g. |
justinwilaby
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not yet convinced this is the best path forward. See the main thread for a comment on my specific concerns.
justinwilaby
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a discussion with Eric, this PR will be used for 1.x while 2.x efforts focus on applying hyper-schema rules.