glTF-Validator
glTF-Validator copied to clipboard
Typescript declaration file for API
Hey I just wrote the declaration file according to document and what I tried. Hope this helps and if so, please publish it to npm . Code
@shrinktofit that's great! Do you know where are the hints?
Shouldn't it be:
export const enum Severity {
Error = 0,
Warning = 1,
Information = 2,
Hint = 3,
}
Ok, I have updated it.
Nice! We wrote something similar for Babylon.js. Do you mean to use https://github.com/shrinktofit/gltf-validator-typing/blob/master/index.d.ts#L53-L58 in https://github.com/shrinktofit/gltf-validator-typing/blob/master/index.d.ts#L81-L86?
Nice! We wrote something similar for Babylon.js. Do you mean to use https://github.com/shrinktofit/gltf-validator-typing/blob/master/index.d.ts#L53-L58 in https://github.com/shrinktofit/gltf-validator-typing/blob/master/index.d.ts#L81-L86?
Yes it should be typo. I have removed it.
By the way, I change the Severity from const-enum to type to avoid isolatedModule issue.
Should this go into the main repo for distribution via npm?
How is this coming along? Would be good to have these available (at least at @types/gltf-validator)
I'm interested in type definitions as well. If there's consensus on where the type declarations should be kept, I can open a PR.
- (a) Publish externally to DefinitelyTyped, as
@types/gltf-validator - (b) Add to this project, publish to NPM as part of
gltf-validatorpackage
@lexaknyazev can you refresh my memory on the index.ts file? Is it automatically generated or manually maintained? And do we use it for anything other than generating the API docs in the NPM readme? If it's hand-written and just used to generate docs, I would recommend we replace it with a TS definitions file so there's only one thing to maintain. We can still generate docs from that, and then TS users would have type declarations too.
If we'd have to maintain two files by hand here, then instead I'd suggest we push this to DefinitelyTyped, i.e. external maintenance (https://github.com/DefinitelyTyped/DefinitelyTyped).
I recently ran into this issue and I have time at the moment to fix this unless you have a PR sitting off to the side, @donmccurdy.
Some thoughts:
- I feel like option b is the better of the two options.
- It looks like
grinderonly copies theindex.jsandmodule.mjsfiles, so these appear to be manually created. We can add aindex.d.tsthat is copied in the same fashion. index.jsis the entry point for the NPM package, so I don't think we can replace it.
Please let me know what you all think. I may just open a PR in a day or two if there's no feedback.
I think (b) would be good, the API surface is narrow enough that this should not be much trouble to maintain I hope. For larger libraries with more API surface, and where the authors are not using TypeScript themselves, I tend to advise (a).