tsec is a static analysis tool built on the TypeScript compiler that validates code against Trusted Types compliance. At version 0.2.9, it provides extended compiler checks to enforce Trusted Types, a browser security primitive that mitigates DOM XSS attacks. Unlike runtime polyfills, tsec catches violations at compile time, integrating into the build pipeline without runtime overhead. It requires Bazel build system (with @bazel/bazelisk and @bazel/concatjs) and TypeScript >=3.9.2. Its key differentiator is compile-time enforcement, making it suitable for large codebases where runtime approaches are insufficient.
npm install tsecNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates tsec usage as a Bazel test rule, enforcing that no code uses .innerHTML without Trusted Types approval.
Integrate Bazel or consider alternative trust-checking tools.
Rename 'disallowed' to 'blocked' in your tsec config.
Upgrade Bazel dependencies to minimum versions.
Ensure all relevant code is in .ts files.
Use import syntax or upgrade to ESM-compatible runtime.
Run 'npm install tsec' and ensure peer dependencies are installed.
Change to 'import tsec from "tsec"' and ensure package.json has 'type':'module'.
Replace 'disallowed' with 'blocked' in your tsec configuration.
Add 'load("@npm//tsec:index.bzl", "tsec_test")' to your BUILD file.