Back to all reviewers

Verify types in tests

fastify/fastify
Based on 2 comments
TypeScript

Use explicit type assertions in TypeScript tests to verify that types behave as expected across various scenarios. Include assertions for inheritance relationships, property types, and different response status codes.

Testing TypeScript

Reviewer Prompt

Use explicit type assertions in TypeScript tests to verify that types behave as expected across various scenarios. Include assertions for inheritance relationships, property types, and different response status codes. This helps catch type-related regressions early and ensures the type system correctly models your application’s behavior.

Example:

instance.register(childInstance => {
  // Verify inherited properties maintain correct types
  expectType<void>(childInstance.testPropSync)
  expectType<string>(childInstance.testValueSync)
  expectType<number>(childInstance.testFnSync())
})

// Verify response types with different status codes
expectType<(payload?: string) => typeof res>(res.code(200).send)
// Add assertions for other status codes
2
Comments Analyzed
TypeScript
Primary Language
Testing
Category

Source Discussions