https://github.com/steelydylan/type-tester
https://github.com/steelydylan/type-tester
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/steelydylan/type-tester
- Owner: steelydylan
- License: mit
- Created: 2023-07-06T04:21:27.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-05-03T11:52:00.000Z (about 2 years ago)
- Last Synced: 2025-03-16T09:35:45.923Z (about 1 year ago)
- Language: TypeScript
- Size: 1.61 MB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Browser Type Tester
too heavy to use it in production, but it's good for testing types in browser
## Usage
```ts
import { TypeTester } from "browser-type-tester";
const code = `
type Speed = "slow" | "medium" | "fast";
const speed: Speed[] = ["slow"];
function getSpeed(speed: Speed): number {
switch (speed) {
case "slow":
return 10;
case "medium":
return 50;
case "fast":
return 200;
}
}
`;
const typeTest = new TypeTester({ code });
typeTest.test("getSpeed function should return number", () => {
typeTest
.expect("getSpeed")
.toBeType(`(speed: "slow" | "medium" | "fast") => number`);
});
const results = await typeTest.run();
console.log(results);
```