Runtime type inspection with typeInfo, and TypeValidator for checking the shape of unknown values.
npm install @tsdotnet/reflectionimport { typeInfo } from '@tsdotnet/reflection';
typeInfo(42).isValidNumber; // true
typeInfo('a').isString; // true
typeInfo(null).isNullOrUndefined; // trueTypeValidator<T> (the default export) is built from a descriptor object; isSubsetOf(value) checks the value has at least those members and narrows it to T.
ESM (import { typeInfo } from '@tsdotnet/reflection';) or CommonJS (const { typeInfo } = require('@tsdotnet/reflection');).
In a browser, without a bundler
<script src="https://cdn.jsdelivr.net/npm/@tsdotnet/type@1/dist/umd/type.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tsdotnet/compare@1/dist/umd/compare.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tsdotnet/reflection@1/dist/umd/reflection.min.js"></script>
<script>
const { typeInfo } = tsdotnet.reflection;
</script>