Courses / Frontend Testing
25. Type-checked tests (expectType, tsd)
Techniques and tools to assert types in tests, like expectType helpers or tsd for declaration tests.
JavaScript / TypeScript
Type-checked tests (expectType, tsd)
Tests that assert TypeScript types at compile time so your public API keeps the types you expect.
"I want my library updates to fail the build if I accidentally change a function's declared types."
Type-checked tests are small pieces of code (or helper calls) that are compiled by TypeScript to assert types — they cause errors when types don't match expected shapes rather than checking runtime values.
"I want my library updates to fail the build if I accidentally change a function's declared types."
Type-checked tests are small pieces of code (or helper calls) that are compiled by TypeScript to assert types — they cause errors when types don't match expected shapes rather than checking runtime values.