Typespec is just annotation and not used at runtime (like @doc).
@doc
To raise an error at runtime - you may add guard to functions so that you get no match found error. There are a few libraries to add abstraction for generating typespec and guard…
See also:
(you can see people in this thread there!)