{"id":26345,"library":"rtts_assert","title":"rtts_assert","description":"A run-time type assertion library for JavaScript, used internally by Angular for runtime type checks. Current stable version is 2.0.0-alpha.37 (pre-release, adapted from v0.1.0 originally designed for Traceur). No regular release cadence—packaged within Angular monorepo. Key differentiator: provides runtime type checking akin to TypeScript's emitDecoratorMetadata, useful in testing and dynamic type validation. Lightweight with no runtime dependencies.","status":"maintenance","version":"2.0.0-alpha.37","language":"javascript","source_language":"en","source_url":"https://github.com/angular/angular","tags":["javascript"],"install":[{"cmd":"npm install rtts_assert","lang":"bash","label":"npm"},{"cmd":"yarn add rtts_assert","lang":"bash","label":"yarn"},{"cmd":"pnpm add rtts_assert","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v2; no CommonJS support.","wrong":"const assert = require('rtts_assert');","symbol":"assert","correct":"import { assert } from 'rtts_assert';"},{"note":"assert.type requires two args; direct assert() with one arg is different (returns an assertion object).","wrong":"assert(value, Type);","symbol":"assert.type","correct":"assert.type(value, Type);"},{"note":"First argument must be a string name, not a class/function.","wrong":"assert.define(MyType, function(value) { ... });","symbol":"assert.define","correct":"assert.define('MyType', function(value) { ... });"}],"quickstart":{"code":"import { assert } from 'rtts_assert';\n\nassert.type('hello', String); // passes\nassert.type(42, String); // throws: Expected String, got Number.\n\nconst value = 'test';\nassert(value).is(String); // passes\nassert(value).is(Number); // throws\n\nassert.define('Email', function(value) {\n  assert(value).is(String);\n  if (value.indexOf('@') === -1) {\n    assert.fail('must contain @');\n  }\n});\n\nassert.type('user@example.com', Email); // passes\nassert.type('invalid', Email); // throws: must contain @","lang":"typescript","description":"Shows basic type assertion, value assertion, and custom type definition."},"warnings":[{"fix":"Replace assert.argumentTypes(arg1, Type, arg2, Type) with individual assert.type calls.","message":"assert.argumentTypes is deprecated and removed in v2; use assert.type instead.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use a modern bundler (e.g., esbuild, Webpack) to transpile ES6 sources.","message":"ES5 build script es5build.js is no longer maintained.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Do not assign the result: use assert(value).is(Type) without assignment.","message":"assert(value).is(...) returns an assertion object, not a boolean; must be called as a statement.","severity":"gotcha","affected_versions":"*"},{"fix":"assert.define('MyClass', fn) instead of assert.define(MyClass, fn).","message":"Custom types defined with assert.define must use a string name; using a class name will silently fail.","severity":"gotcha","affected_versions":"*"},{"fix":"Use assert.type(value, assert.string) or assert(value).is(assert.string) still works.","message":"Predefined types like assert.string now require assert.type(value, assert.string) instead of assert(value).is(assert.string) pattern changed.","severity":"breaking","affected_versions":">=2.0.0-alpha.37"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Replace with assert.type(arg1, Type), assert.type(arg2, Type), etc.","cause":"assert.argumentTypes was removed in v2.0.0.","error":"TypeError: assert.argumentTypes is not a function"},{"fix":"assert.define('MyType', ..., not assert.define(MyType, ...).","cause":"assert.define first argument must be a string name, not a type reference.","error":"Error: Expected argument to be a string but got 'undefined'"},{"fix":"Check the value and type: assert.type(value, ActualType).","cause":"Value does not match the asserted type.","error":"AssertionError: Expected String, got Number."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}