Publish the new types + a suggestion to export result type seperately
Closed this issue · 4 comments
What should we do?
The new types are not yet available in the latest version on npmjs.com. Additionally I would like to add the suggestion of providing a separate type for the result object. In our project we have done the following:
declare module "xsd-schema-validator" {
export function validateXML(
// Type comes straight from the package, so not going to fix this linter warning.
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
xml: string | ReadableStream | { file: string },
pathToXsd: string
): Promise<xmlSchemaValidatorResult>;
export type xmlSchemaValidatorResult = {
valid: boolean;
result: string;
messages: string[];
};
}
Let me know if I should create a PR for this and if you agree with the naming conventions etc.
Why should we do it?
Point one: The latest "@types/xml-schema-validator" package contains types for older versions, this breaks updating to post v0.8, of which the latest version does not yet supply its own types
Point two: A separate result type is a bit cleaner when writing TypeScript on "strict" settings, e.g:
const result: xmlSchemaValidatorResult = await validator.validateXML(xml, xsdFilePath);
Thank you 🥇
I have not tested the types extensively yet, and hence did not get to a release. Happy to take a PR to improve the types.
I'll want to verify that the types work locally as well using the typescript compiler (cf. https://github.com/bpmn-io/min-dash/blob/main/tsconfig.json or others).
Have been able to validate that the type declaration above works in our use case, bit busy mixing work with taking care of my dad (recently had a severe stroke) so will create the PR in between everything, might need a reminder though given the situation.
Thanks!
Released with v0.9.0
Hi, completely forgot about this. Thanks for merging it in! :)