TypeScript

Testing TypeScript (Vitest, expectTypeOf)

Në shqip: Testimi i TypeScript

ShpjegimiSQ

Vitest punon me TypeScript pa konfigurim. Me expectTypeOf mund të testosh edhe vetë tipet: expectTypeOf(f).returns.toEqualTypeOf<number>() — e dobishme për librari.

EnglishEN

Vitest works with TypeScript with no setup. With expectTypeOf you can even test the types themselves: expectTypeOf(f).returns.toEqualTypeOf<number>() — useful for libraries.

Si ta mendosh

Si të kontrollosh jo vetëm që ushqimi shijon mirë, por edhe që receta është shkruar saktë.

Lexoje në anglisht

Like checking not just that the food tastes good, but that the recipe is written correctly.

Shembull koditypescript

test("mblidh", () => {
  expect(mblidh(2, 3)).toBe(5);
  expectTypeOf(mblidh).returns.toEqualTypeOf<number>();
});

Terma të lidhur