-
Notifications
You must be signed in to change notification settings - Fork 16
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
auto-generate type definitions from the json schema #177
base: main
Are you sure you want to change the base?
Conversation
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.
This looks great. I really like to see more TS in our projects. It will make working with them a lot easier.
import shell from 'shelljs'; | ||
import YAML from 'js-yaml'; | ||
import marky from 'marky'; | ||
import { createRequire } from 'module'; | ||
import { compileFromFile } from 'json-schema-to-typescript'; | ||
import { toSafeString } from 'json-schema-to-typescript/dist/src/utils.js'; |
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.
Should we maybe ask in the repo to make this a public API?
I could not find any issue on this, yet https://github.com/search?q=repo%3Abcherny%2Fjson-schema-to-typescript+toSafeString&type=issues
@@ -30,7 +30,6 @@ export default [ | |||
'indent': ['off', 4], | |||
'keyword-spacing': 'error', | |||
'linebreak-style': ['error', 'unix'], | |||
'no-await-in-loop': 'error', |
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.
✅
For reference https://eslint.org/docs/latest/rules/no-await-in-loop
Don't see a reason why we would want to prevent this.
@@ -16,6 +16,7 @@ | |||
"chalk": "^5.0.1", | |||
"glob": "^10.1.0", | |||
"js-yaml": "^4.0.0", | |||
"json-schema-to-typescript": "^15.0.3", |
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.
Does it matter if this is in devDependencies
or dependencies
? It is only used during build so I kind of expected it to be a devDependencies
?
Besides from iD, there are several typescript projects which use this library. Currently, each project has to write their own type-definitions (see examples from overpass-turbo and osmapp). This is inconvenient and the definitions could easily become out-of-date.
This PR uses json-schema-to-typescript to generate TS definition files for the main JSON files in
dist/*
. This means that the next release of @openstreetmap/id-tagging-schema will include.d.json.ts
files - example hereExamples: