{"id":20120859,"url":"https://github.com/vstirbu/chai-as-typed","last_synced_at":"2026-05-10T02:13:56.320Z","repository":{"id":48315883,"uuid":"108119585","full_name":"vstirbu/chai-as-typed","owner":"vstirbu","description":"Chai assertions for types defined via JSDoc","archived":false,"fork":false,"pushed_at":"2021-08-02T03:15:23.000Z","size":2172,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-03T19:16:52.930Z","etag":null,"topics":["chai","jsdoc","testing","types","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vstirbu.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":"2017-10-24T11:50:20.000Z","updated_at":"2020-01-20T06:16:05.000Z","dependencies_parsed_at":"2022-09-15T07:20:21.718Z","dependency_job_id":null,"html_url":"https://github.com/vstirbu/chai-as-typed","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vstirbu%2Fchai-as-typed","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vstirbu%2Fchai-as-typed/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vstirbu%2Fchai-as-typed/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vstirbu%2Fchai-as-typed/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vstirbu","download_url":"https://codeload.github.com/vstirbu/chai-as-typed/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vstirbu%2Fchai-as-typed/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":257820957,"owners_count":22608264,"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","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":["chai","jsdoc","testing","types","typescript"],"created_at":"2024-11-13T19:23:33.185Z","updated_at":"2026-05-10T02:13:56.291Z","avatar_url":"https://github.com/vstirbu.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chai-as-typed\n\n[![Build Status](https://travis-ci.org/vstirbu/chai-as-typed.svg?branch=master)](https://travis-ci.org/vstirbu/chai-as-typed)\n[![Coverage Status](https://coveralls.io/repos/github/vstirbu/chai-as-typed/badge.svg?branch=master)](https://coveralls.io/github/vstirbu/chai-as-typed?branch=master)\n[![Greenkeeper badge](https://badges.greenkeeper.io/vstirbu/chai-as-typed.svg)](https://greenkeeper.io/)\n\n## Motivation\n\n[TypeScript](https://www.typescriptlang.org/) has now the ability to do [type checking](https://github.com/Microsoft/TypeScript/wiki/Type-Checking-JavaScript-Files) in plain JavaScript files. This behavior is not based on magic, but on well formed JSDoc [comments](https://github.com/Microsoft/TypeScript/wiki/JSDoc-support-in-JavaScript).\n\nNow, if I have a JavaScript file augmented with the proper JSDoc comments, an editor such as [Visual Studio Code]() will be able to automatically get IntelliSense, which includes autocompletion and type checking:\n\n![](https://raw.github.com/vstirbu/chai-as-typed/master/media/fsm-events-typescript.gif)\n\nHowever, exposing reliably the type information about a module APIs requires testing. This plugin enhances Chai with specific helpers that make the task of checking the type information in plain JavaScript files easy.\n\n## How to use\n\nConsidering that we have a javascript file, which starts with the following line:\n\n```javascript\n// @ts-check\n```\n\nwe can test that the types used are correct with the following assertion:\n\n```javascript\nexpect('/absolute/path/to/filename.js').to.have.types.validated();\n```\n\nIf there are type errors, an error will be thrown indicating the position of the type violations:\n\n```\nError: /absolute/path/to/filename.js (Ln 5, Col 6): Argument of type '123' is not assignable to parameter of type 'string'\n```\n\nAlso, in case errors are expected, we can test using the following assertions indicating the number of errors expected:\n\n```javascript\nexpect('/absolute/path/to/filename.js').to.have.types.errors(1);\n```\n\n## Installation ans setup\n\nDo `npm install --save-dev chai-as-typed`, then:\n\n```javascript\nvar chai = require('chai');\nvar chaiAsTyped = require('chai-as-typed');\n\nchai.use(chaiAsTyped);\n```\n\n## Disclaimer\n\nThe plugin is in experimental phase. Use it gently and provide feedback! :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvstirbu%2Fchai-as-typed","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvstirbu%2Fchai-as-typed","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvstirbu%2Fchai-as-typed/lists"}