Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { expect, it } from "vitest";
import { Equal, Expect } from "../helpers/type-utils";

function youSayGoodbyeISayHello(greeting: 'hello'): 'goodbye'
function youSayGoodbyeISayHello(greeting: 'goodbye'): 'hello'
function youSayGoodbyeISayHello<TGreeting extends "hello" | "goodbye">(
greeting: TGreeting
){
return greeting === "goodbye" ? "hello" : "goodbye";
}

it("Should return goodbye when hello is passed in", () => {
const result = youSayGoodbyeISayHello("hello");

type test = [Expect<Equal<typeof result, "goodbye">>];

expect(result).toEqual("goodbye");
});

it("Should return hello when goodbye is passed in", () => {
const result = youSayGoodbyeISayHello("goodbye");

type test = [Expect<Equal<typeof result, "hello">>];

expect(result).toEqual("hello");
});