Skip to content

Static types testing

Chris Hibbert edited this page Apr 19, 2023 · 2 revisions

We have some tests for static types per se, which don't get run in agoric-sdk-unit-testing.

For example,

At one point we had collocated the tests with the unit tests using test.skip('types') but it made "skip" noise in output and the .js syntax prevented us from using some helpful features of https://github.com/SamVerschueren/tsd.

So these tests use the .ts syntax to allow for specifying expected types, like so: https://github.com/Agoric/agoric-sdk/blob/f3bb7952ee1a7f6832ecbddf3aa4b26545723f4c/packages/vat-data/src/index.test-d.ts#L70-L73

These files are read only by the tsc checker run by yarn lint:types. Note that these aren't .d.ts files which are TypeScript declarations. The .test-d.ts is a convention of TSD but you can think of them as any other .ts file. It's never run because it's not in src and it doesn't match the pattern Ava looks for in tests. It's parsed only by tsc. When the package gets built the tsc config will transpile it, but to a similarly ignored test file.

Clone this wiki locally