Registry / type-stubs / retyped-chai-http-tsd-ambient

retyped-chai-http-tsd-ambient

JSON →
library0.0.0-0jsnpmunverified

This package provides TypeScript ambient type declarations for the `chai-http` library. It originates from the `retyped` project, which aimed to offer curated typings for various JavaScript libraries. However, the `retyped` project itself appears to be abandoned, with most packages, including this one, maintaining a `0.0.0-0` version number, indicating no active development or updates. Modern `chai-http` (version 4.2.4 and above) ships with its own built-in TypeScript definitions, making external typing packages like `retyped-chai-http-tsd-ambient` largely obsolete. Users are generally advised to rely on `chai-http`'s native types rather than this unmaintained package or even the stub `@types/chai-http` package.

npm install retyped-chai-http-tsd-ambient
INSTALL
IMPORT
SIG · RETYPED-CHAI-HTTP-
R
retyped-chai-http-tsd-ambient
type-stubsjavascriptv0.0.0-0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

chai
import * as chai from 'chai';
const chai = require('chai');
Standard ES module import for the Chai assertion library. `chai-http` augments the `chai` namespace.
chaiHttp
import chaiHttp from 'chai-http';
import { chaiHttp } from 'chai-http'; // Incorrect named import const chaiHttp = require('chai-http'); // Might lose type augmentation without specific TS syntax
Chai-HTTP is typically imported as a default export. For CommonJS environments with TypeScript, `import chaiHttp = require('chai-http');` is a specific syntax to ensure type augmentation works correctly, especially with older `chai-http` types. However, with `chai-http`'s built-in types, the `import` statement usually suffices.
request
import { request } from 'chai-http';
import * as request from 'chai-http'; // Incorrect if only `request` is needed
While `chaiHttp` is often used to enable the plugin, `request` can also be directly imported from `chai-http` for making requests, especially when not using `chai.use()` with an `app`.

Demonstrates a basic TypeScript test setup using `chai`, `chai-http`, and `mocha` to make and assert HTTP requests against a simple Express.js application, leveraging the provided typings.

import * as chai from 'chai'; import chaiHttp from 'chai-http'; import { Application } from 'express'; // Assuming Express.js application import 'mocha'; // For test runner globals // Optionally import superagent types if not implicitly resolved by chai-http's built-in types // import '@types/superagent'; // Initialize Chai HTTP plugin chai.use(chaiHttp); // Create a dummy Express app for testing const app: Application = require('express')(); app.get('/test', (req, res) => res.status(200).send('Hello Test!')); app.post('/data', (req, res) => res.status(201).json({ message: 'Data received' })); describe('Chai-HTTP with TypeScript', () => { it('should get a successful response from /test', (done) => { chai.request(app) .get('/test') .end((err, res) => { chai.expect(err).to.be.null; chai.expect(res).to.have.status(200); chai.expect(res.text).to.equal('Hello Test!'); done(); }); }); it('should post data and get a created response from /data', (done) => { chai.request(app) .post('/data') .send({ item: 'test' }) .end((err, res) => { chai.expect(err).to.be.null; chai.expect(res).to.have.status(201); chai.expect(res).to.be.json; chai.expect(res.body.message).to.equal('Data received'); done(); }); }); });
Debug
Known issues
breakingThe `retyped` project, which this package is part of, appears to be abandoned (last activity on GitHub for the main repo was in 2017). This package is unlikely to receive updates for new `chai-http` versions or TypeScript changes.
fix
Migrate to `chai-http`'s built-in type definitions, as `chai-http` (v4.2.4+) now ships with its own types. Remove `retyped-chai-http-tsd-ambient` and `@types/chai-http` (which is a stub).
affects: >=0.0.0-0
gotcha`chai-http` (versions 4.2.4 and newer) provides its own type declarations directly within the package. Installing `retyped-chai-http-tsd-ambient` or `@types/chai-http` is unnecessary and can potentially lead to type conflicts or outdated definitions.
fix
Uninstall `retyped-chai-http-tsd-ambient` and `@types/chai-http`. Ensure `chai-http` is updated to a version that includes its own types (e.g., `npm install chai-http@latest`).
affects: >=0.0.0-0
gotchaWhen using `chai-http` with TypeScript, particularly in CommonJS environments, incorrect import syntax can prevent type augmentation of `chai`. For example, `const chaiHttp = require('chai-http')` might not correctly apply types.
fix
Use ES module imports: `import chaiHttp from 'chai-http';` or, for explicit CommonJS type augmentation in older setups, `import chaiHttp = require('chai-http');`.
affects: >=0.0.0-0
gotchaTypeScript errors such as 'Property 'get' does not exist on type 'Agent'' can occur if the types for `superagent` (which `chai-http` uses internally) are not correctly resolved or are missing. This is because `chai-http` extends `superagent`'s request objects.
fix
Install `@types/superagent` as a devDependency: `npm install --save-dev @types/superagent`. This typically resolves issues with missing HTTP method types on `chai.request` objects.
affects: >=0.0.0-0
Errors
Common errors & fixes
Property 'request' does not exist on type 'ChaiStatic'.
The TypeScript compiler cannot find the `request` property augmentation on the `chai` object, typically due to missing or incorrectly loaded `chai-http` type declarations.
fix
Ensure `chai-http` is installed and updated to a version with built-in types. Remove `retyped-chai-http-tsd-ambient` and `@types/chai-http`. If using an older `chai-http` version, ensure `import chaiHttp = require('chai-http');` is used in CommonJS contexts.
Property 'get' does not exist on type 'Agent'.
The types for `superagent`, which `chai-http` extends, are not correctly applied, leading to missing HTTP method declarations on the `chai.request` object.
fix
Install `@types/superagent` as a development dependency: `npm install --save-dev @types/superagent`. This provides the necessary declarations for the HTTP methods.
Could not find a declaration file for module 'chai-http'.
TypeScript cannot locate the type definition files (`.d.ts`) for `chai-http`.
fix
Ensure `chai-http` is installed and that its version includes built-in types. If not, consider upgrading `chai-http` or manually installing `@types/chai-http` (though `chai-http`'s native types are preferred if available). Confirm your `tsconfig.json` includes `node_modules/@types` in `typeRoots` or similar.
Parameter 'res' implicitly has an 'any' type.
When using `chai-http` with Promises or callbacks, TypeScript might not infer the type of the `res` (response) object if `chai-http`'s types or `superagent`'s types are not fully resolved, or if `chai.use(chaiHttp)` is not correctly applied.
fix
Ensure all relevant typing packages (`chai`, `chai-http`, `superagent`) are installed and properly configured. Explicitly type the callback parameters (e.g., `(err: any, res: ChaiHttp.Response) => { ... }`) as a temporary workaround, but the root cause is usually missing or conflicting types.
Upgrade
Version history
0.0.0-0latest on npm
Audit
Dependencies
chai-httprequiredThis package provides type definitions for the `chai-http` runtime library. It is a devDependency.
chairequired`chai-http` is a plugin for the `chai` assertion library, so `chai` is implicitly required for runtime usage and its types.
@types/superagentoptionalChai-HTTP extends `superagent`'s request interface. Missing `@types/superagent` can lead to TypeScript errors regarding HTTP method properties (e.g., `.get()`, `.post()`) on the `Agent` type.
Agent activity
27 hits · last 30 days
node
24
OpenAI (training)
2
Resources
retyped-chai-http-tsd-ambient — npm install retyped-chai-http-tsd-ambient · libregistry