transpiler
transpiler copied to clipboard
Additional Properties - typing is too loose for typescript
Additional properties and Patterned Properties append an any type to the end of the typing. The JSON schema spec doesn't quite line up with the typings generated. This would be a potentially breaking change for consuming clients. As they would all of a sudden generate types that didn't work with any. We want to move slowly here about introducing more specificity.

suggested change is probably
if (s.additionalProperties === true || s.additionalProperties === undefined) {
propertyTypings.push(" [k: string]: any;");
}
else if (s.additionalProperties !== false) {
const subTypes: string[] = [];
Object.values(s.additionalProperties!).forEach((prop: JSONSchema) => {
const title = this.getSafeTitle(this.refToTitle(prop));
if (subTypes.includes(title) === false) {
subTypes.push(title);
}
});
propertyTypings.push(` [k: string]: ${subTypes.join(" | ")}`);
}
This issue will serve as tracking for open-rpc changes floating down the pipeline.