Declarations for engine and controller scripting API
These declarations allow modern code editors and IDEs, to show online syntax help and allows type checking (as far as JavaScript supports types).
To enable this, the mapping developer has to create a file jsconfig.json in the directory with the JavaScript mapping to edit. This file is editor independend an should work with all editors, which support the Language Server Protocol (LSP), like VS Code, Atom, Eclipse, Kate, Sublime, etc.
The jsconfig.json must have the a content like below, that allows the editor to find all include files and tells him to use ES6 syntax:
{
"compilerOptions": {
"target": "es6",
"checkJs": true,
"lib": ["ES6"]
},
"include": ["<mappingpath>/Traktor-Kontrol-Z2-hid-scripts.js",
"<mixxxpath>/res/controllers/common-hid-packet-parser.js",
"<mixxxpath>/res/controllers/common-controller-scripts.js",
"<mixxxpath>/res/controllers/hid-controller-api.d.ts",
"<mixxxpath>/res/controllers/engine-api.d.ts",
"<mixxxpath>/res/controllers/console-api.d.ts"]
}


Sounds reasonable. Does this put any mandatory work to the mapping developer, that makes work harder as a noob contributor?
Nothing mandatory, if you don't create the jsconfig.json file next to your mapping file, everything is as before.
Please ping me when this PR is ready for review. I'll take a look then.
Please ping me when this PR is ready for review. I'll take a look then.
@Swiftb0y This is now ready for review!
@JoergAtGithub please also take a look at my previous but abandoned attempt at this #2636
@JoergAtGithub please also take a look at my previous but abandoned attempt at this #2636
Wasn't aware of this PR. I'm not at home this week, and will address your review comments the week after.
No problem. I just wanted to supply some context for my review comments.
Is this one again ready for review?
FYI, most of my comments from the first review have not been addressed yet.
How do we want to visualize that case? Back to draft, or a new lable?
IMO stale?
I will continue here. IMHO the status is clear, @Swiftb0y requested changes and I clicked not yet on the re-review button, which is visually indicated.
Oh I am sorry for misusing your PR vor the general workflow questions. It is nothing wrong here. I will open a topic on Zulip for the general labling questions.
This PR is marked as stale because it has been open 90 days with no activity.
@JoergAtGithub do you consider this ready for review now?
I need to address the review remarks from Niko first.
I'll try to stay responsive if you reply on any of the open threads. Feel free to request a re-review once you see fit for it.
Thanks Niko! I will do, but I haven't clarified all questions you raised in the last review of this PR yet.
It would be nice if we could also lint the new typescript declaration files. Would you be willing to look into what it would take to add typescript-eslint to our eslint config?
After getting the jsconfig to work, I'm really annoyed by the fact that a developer needs to edit the jsconfig to reference their mapping in order for everything to work. After a bit of research and trial and error, I don't think there is anything we can do against that, right?
We could get that working by making each mapping their own project (which would make sense) but that would require putting each mapping to its own folder. That's something I would like to do anyways in the future, but is out-of-scope for this PR.
I think we should include a jsconfig as well. Putting this into res/controllers/ should work:
{
"compilerOptions": {
"target": "es6",
"checkJs": true,
"lib": ["ES6"]
},
"include": [
"*.d.ts",
"common-hid-packet-parser.js",
"common-controller-scripts.js",
// add the filename of your own mapping here:
""
// make sure to exclude any changes in this file from your submission
]
}
I would not like to add a jsconfig.json in the scope of this PR.
I would not like to add a jsconfig.json in the scope of this PR.
Thats fair. Though it certainly makes it more difficult to test.
Done
Time to celebrate twice - the PR is exactly 1 year old today. 🎂
Sorry, this took this long... Highly appreciate the effort though.
Thank you for the review!