ts-method-checker
Check typescript method arguments and return types during execution
usage
It is necessary to specify the following contents in the settings of tsconfig.json
{ "compilerOptions": { "experimentalDecorators": true, "emitDecoratorMetadata": true }}
Specify @CHECK for a method that requires type checking at runtime
;
If an invalid type is used in the program, an exception will be raised
// Create instance; //do it righttest.func010, "A", true; //OK //Incorrect number of argumentstry catch e //Incorrect argument typetry catch e //Call the method with the wrong return valuetry catch e
Judgable type
- number
- string
- boolean
- Array
- Function
Only simple types above can be determined Anything else that cannot be judged is ignored
license
MIT