You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi!
I'm making a reactive version of Pixi.JS library.
I've got typescript to check for 'invalid' hierarchy - e.g. Graphics can be 'parent' of Circle, while the opposite way would be a type error.
But I'd like to add custom error messages that would be emitted by TS compiler for better library user-experience
(e.g. 'Circle component cannot be a valid parent of Graphics' alongside 'Circle does not implement IParentablyBy<Graphics>' ), but couldn't find any typescript articles on this.
EDIT:
So I'm looking for someone else to propose some typescript syntax that would provide some ways to provide custom type-level error messages, which would definitely be better than the sample one below:
exportfunctioncreateComponent<BlueprintClassextendsBaseBlueprint,PropsTypeextendsBasePropsType>(blueprintClass: {new(): BlueprintClass&IParentableBy<BaseBlueprint,BasePropsType>}){typeParentableByBlueprint=IParentableBy<BlueprintClassasChildBlueprintClass,BasePropsType>withCustomTypeErrorMessage(// THIS would be the magic sauce I'm hoping forts.typeErrors.invalidGenerics(childBlueprintClass),`${ChildBlueprintClass} cannot be a child of ${BlueprintClass}`);// above isn't even a valid ts syntax - I'm making up above, but you get the idea (hopefully)returnfunction_componentMetaData(props: PropsType,children: Array<RenderableType<BasePropsType,BaseBlueprint&ParentableByBlueprint>>): RenderableType<PropsType,BlueprintClass>{return{blueprint: blueprintClass,
props,
children,};}}
ps: Is there already a way to 'customize' typescript error messages? (or at least provide extra type-error messages?)
pps: I'd love to have them in-code (so typescript-compiler would actually type-check custom-error messages too), with options to get further error-info ('digging-into') to actually get to the raw error messages by TS compiler.
The text was updated successfully, but these errors were encountered:
Hi!
I'm making a reactive version of Pixi.JS library.
I've got typescript to check for 'invalid' hierarchy - e.g. Graphics can be 'parent' of Circle, while the opposite way would be a type error.
But I'd like to add custom error messages that would be emitted by TS compiler for better library user-experience
(e.g. 'Circle component cannot be a valid parent of Graphics' alongside 'Circle does not implement IParentablyBy<Graphics>' ), but couldn't find any typescript articles on this.
EDIT:
So I'm looking for someone else to propose some typescript syntax that would provide some ways to provide custom type-level error messages, which would definitely be better than the sample one below:
ps: Is there already a way to 'customize' typescript error messages? (or at least provide extra type-error messages?)
pps: I'd love to have them in-code (so typescript-compiler would actually type-check custom-error messages too), with options to get further error-info ('digging-into') to actually get to the raw error messages by TS compiler.
The text was updated successfully, but these errors were encountered: