{"id":30261658,"url":"https://github.com/peerigon/typescript-exercises-tools","last_synced_at":"2025-08-15T20:55:24.825Z","repository":{"id":40291610,"uuid":"217064119","full_name":"peerigon/typescript-exercises-tools","owner":"peerigon","description":"Tools for writing and validating TypeScript exercises","archived":false,"fork":false,"pushed_at":"2024-06-25T21:03:55.000Z","size":2232,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-08-08T20:55:23.201Z","etag":null,"topics":["assertions","comments","testing","typescript","typings","validation"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peerigon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-23T13:26:57.000Z","updated_at":"2024-06-25T21:03:57.000Z","dependencies_parsed_at":"2023-01-30T00:45:53.436Z","dependency_job_id":null,"html_url":"https://github.com/peerigon/typescript-exercises-tools","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/peerigon/typescript-exercises-tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peerigon%2Ftypescript-exercises-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peerigon%2Ftypescript-exercises-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peerigon%2Ftypescript-exercises-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peerigon%2Ftypescript-exercises-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peerigon","download_url":"https://codeload.github.com/peerigon/typescript-exercises-tools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peerigon%2Ftypescript-exercises-tools/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269657264,"owners_count":24454808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-09T02:00:10.424Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assertions","comments","testing","typescript","typings","validation"],"created_at":"2025-08-15T20:55:22.155Z","updated_at":"2025-08-15T20:55:24.819Z","avatar_url":"https://github.com/peerigon.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @peerigon/typescript-exercises-tools\n\n**Tools for writing and validating TypeScript exercises.**\n\n[![](https://img.shields.io/npm/v/@peerigon/typescript-exercises-tools.svg)](https://www.npmjs.com/package/@peerigon/typescript-exercises-tools)\n[![](https://img.shields.io/npm/dm/@peerigon/typescript-exercises-tools.svg)](https://www.npmjs.com/package/@peerigon/typescript-exercises-tools)\n[![Dependency Status](https://david-dm.org/peerigon/@peerigon/typescript-exercises-tools.svg)](https://david-dm.org/peerigon/@peerigon/typescript-exercises-tools)\n[![Build Status](https://travis-ci.com/peerigon/@peerigon/typescript-exercises-tools.svg?branch=master)](https://travis-ci.com/peerigon/@peerigon/typescript-exercises-tools)\n[![Coverage Status](https://coveralls.io/repos/github/peerigon/typescript-exercises-tools/badge.svg?branch=master)](https://coveralls.io/github/peerigon/typescript-exercises-tools?branch=master)\n[![Known Vulnerabilities](https://snyk.io/test/github/peerigon/typescript-exercises-tools/badge.svg)](https://snyk.io/test/github/peerigon/typescript-exercises-tools)\n\nThis module allows you to annotate expected type errors in your TypeScript code like this:\n\n```ts\nexport const add = (a: number, b: string) =\u003e {\n  return a + b;\n};\n\n// 💥 Expect error 2345: Argument of type '4' is not assignable to parameter of type...\nadd(3, 4);\n```\n\nWith the TypeScript language service plugin provided by this module, these expected type errors will show up as a suggestion instead of an error:\n\n![Screenshot of an editor that shows a type error as a suggestion](./docs/editor-screenshot-1.jpg)\n![Screenshot of an editor that shows the suggestion popup](./docs/editor-screenshot-2.jpg)\n\nFurthermore, these comments will cause the editor to show an error if there is _no type error_ at this location:\n\n![Screenshot of an editor that shows an error when there is no type error](./docs/editor-screenshot-3.jpg)\n\nAt the time of writing, only editors use TypeScript language service plugins. Calling `tsc` from the command line will not execute the plugin. That's why there is also a programmatic API that allows you to do assertions on the program:\n\n```ts\nimport { assertProgramToOnlyHaveExpectedErrors } from \"@peerigon/typescript-exercises-tools/tests\";\n\ntest(\"The program has only expected errors\", () =\u003e {\n  assertProgramToOnlyHaveExpectedErrors(\"/path/to/module.ts\");\n});\n```\n\nThis module is ideal for:\n\n- testing types by doing assertions on the behavior of types\n- creating TypeScript exercises\n\n## Installation\n\n```\nnpm install @peerigon/typescript-exercises-tools\n```\n\nNow you need to add the TypeScript language service plugin to your `tsconfig.json`:\n\n```json\n{\n  \"compilerOptions\": {\n    \"plugins\": [\n      {\n        \"name\": \"@peerigon/typescript-exercises-tools\"\n      }\n    ]\n  }\n}\n```\n\n**Please note that you need to configure your editor to use your local TypeScript version.** Otherwise TypeScript may not find the plugin. If you're using VSCode, create a file in your repository at `.vscode/settings.json` and add this:\n\n```json\n{\n  \"typescript.tsdk\": \"node_modules/typescript/lib\"\n}\n```\n\n## API\n\n### assertProgramToOnlyHaveExpectedErrors(\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;programPath: string,\u003cbr\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;compilerOptions?: ts.CompilerOptions,\u003cbr\u003e): void\n\nCompiles the program at the given `programPath` and throws the first unexpected error it encounters. It's recommended to use an absolute path. If you don't pass any `compilerOptions` to this function, it uses TypeScript's internal `findConfigFile()` to locate the closest `tsconfig.json` to `programPath`.\n\n```ts\nimport { assertProgramToOnlyHaveExpectedErrors } from \"@peerigon/typescript-exercises-tools/tests\";\n\nassertProgramToOnlyHaveExpectedErrors(\"/path/to/module.ts\"); // may throw\n\nassertProgramToOnlyHaveExpectedErrors(\n  \"/path/to/module.ts\",\n  { strict: true }, // custom compiler options\n);\n```\n\n## License\n\nUnlicense\n\n## Sponsors\n\n[\u003cimg src=\"https://assets.peerigon.com/peerigon/logo/peerigon-logo-flat-spinat.png\" width=\"150\" /\u003e](https://peerigon.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeerigon%2Ftypescript-exercises-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeerigon%2Ftypescript-exercises-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeerigon%2Ftypescript-exercises-tools/lists"}