tsc directly won’t catch Tokenami-specific type errors. This guide explains how to set up proper type checking in your CI pipeline.
Why widened types?
During development, Tokenami widens property types to improve IntelliSense performance in your editor. Instead of checking against thousands of possible token combinations on every keystroke, the TypeScript plugin provides interactive validation as you type. This approach gives you:- Fast autocomplete — Suggestions appear instantly as you type
- Real-time validation — The TypeScript plugin catches errors immediately
- Better developer experience — No lag when editing large files
tsc --noEmit in the command line, TypeScript skips the plugin validation and only checks the widened types. This means Tokenami type errors won’t be caught.
The solution: tokenami check
To ensure type safety in CI, use thetokenami check command. This command validates all Tokenami properties in your codebase against your theme configuration.
Basic setup
Add both commands to your type checking script:package.json
;) ensures both commands run, but tokenami check must pass first. If it fails, the script exits before running tsc.
CI configuration examples
GitHub Actions
GitHub Actions
.github/workflows/ci.yml
GitLab CI
GitLab CI
.gitlab-ci.yml
CircleCI
CircleCI
.circleci/config.yml
What tokenami check validates
Thetokenami check command validates:
Theme token references
Theme token references
Ensures all CSS variable references exist in your theme:
Property-theme mappings
Property-theme mappings
Validates that properties only use tokens from their configured theme keys:
Arbitrary values
Arbitrary values
Checks that arbitrary values use the correct syntax:
Selector configurations
Selector configurations
Verifies custom selectors are defined in your config:
Common CI issues
Config file not found
Iftokenami check can’t find your config file, specify the path:
TypeScript version mismatch
Ensure your CI environment uses the same TypeScript version as your local environment:package.json
Build order issues
If you generate types during the build process, ensure they’re created before type checking:package.json
Performance optimization
For large codebases, you can optimize CI performance:Check only changed files
Use a tool likelint-staged to check only modified files:
package.json
Parallel execution
If your CI supports it, run checks in parallel:package.json
Make sure to install
npm-run-all as a dev dependency: npm install -D npm-run-allLocal development workflow
Whiletokenami check is essential for CI, you don’t need to run it constantly during development. The TypeScript plugin provides real-time feedback in your editor.
However, it’s useful to run before committing:
package.json
Troubleshooting
False positives
Iftokenami check reports errors that don’t appear in your editor:
- Restart your TypeScript server in your editor
- Ensure your editor is using the workspace TypeScript version
- Check that your config file matches between local and CI
Slow CI builds
If type checking is slowing down your CI:- Use caching for
node_modulesand generated types - Split type checking into a separate job that runs in parallel
- Consider incremental type checking for monorepos
Editor vs CI mismatch
If your editor shows different errors than CI:- Verify both use the same TypeScript version
- Check that your
tsconfig.jsonis correctly configured - Ensure the TypeScript plugin is enabled in your
tsconfig.json:
tsconfig.json