Skip to content

Commit cb6e738

Browse files
committed
chore: use @types/superagent
1 parent 6146296 commit cb6e738

6 files changed

Lines changed: 12 additions & 147 deletions

File tree

packages/ionic/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
"@types/os-name": "^3.1.0",
8888
"@types/semver": "^6.0.0",
8989
"@types/split2": "^2.1.6",
90+
"@types/superagent": "^4.1.3",
9091
"@types/tar": "^4.0.0",
9192
"@types/through2": "^2.0.33",
9293
"@types/uuid": "^3.4.3",

packages/ionic/src/commands/package/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ Customizing the build:
341341

342342
if (!filename) {
343343
req.on('response', res => {
344-
const contentDisposition = res.headers['content-disposition'];
344+
const contentDisposition = res.header['content-disposition'];
345345
filename = contentDisposition ? contentDisposition.split('=')[1] : 'output.bin';
346346
});
347347
}

packages/ionic/src/lib/http.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ export function createFatalAPIFormat(req: SuperAgentRequest, res: APIResponse):
234234

235235
export function formatSuperAgentError(e: SuperAgentError): string {
236236
const res = e.response;
237-
const req = res.request;
237+
const req = (res as any).request; // TODO: `req` and `request` exist: https://visionmedia.github.io/superagent/docs/test.html
238238
const statusCode = e.response.status;
239239

240240
let f = '';

packages/ionic/src/lib/integrations/cordova/resources.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ export async function transformResourceImage(env: IonicEnvironment, resource: Im
179179
'encoding': 'png',
180180
})
181181
.on('response', res => {
182-
debug('response %d received for %s: (id: %s)', res.statusCode, resource.name, resource.imageId);
182+
debug('response %d received for %s: (id: %s)', res.status, resource.name, resource.imageId);
183183

184-
if (res.statusCode !== 200) {
185-
const generalErrorMsg = !res.statusCode || res.statusCode >= 500
184+
if (res.status !== 200) {
185+
const generalErrorMsg = !res.status || res.status >= 500
186186
? 'the server may be experiencing difficulties right now--please try again later.'
187187
: 'the server marked a source image as invalid for this resource.';
188188

@@ -198,7 +198,7 @@ export async function transformResourceImage(env: IonicEnvironment, resource: Im
198198
try {
199199
serverMsg = JSON.parse(serverMsg).Error;
200200
} catch (e) {
201-
serverMsg = formatResponseError(req, res.statusCode, serverMsg);
201+
serverMsg = formatResponseError(req, res.status, serverMsg);
202202
}
203203

204204
result.error = new Error(

packages/ionic/src/lib/utils/http.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ export async function createRequest(method: HttpMethod, url: string, { proxy, ss
3939
const superagentProxy = await import('superagent-proxy');
4040
superagentProxy(superagent);
4141

42-
if (req.proxy) {
43-
req.proxy(proxy);
42+
if ((req as any).proxy) { // TODO: create/use `@types/superagent-proxy`
43+
(req as any).proxy(proxy);
4444
} else {
4545
debug(`Cannot install proxy--req.proxy not defined`);
4646
}
@@ -77,16 +77,16 @@ export async function download(req: SuperAgentRequest, ws: NodeJS.WritableStream
7777
return new Promise<void>((resolve, reject) => {
7878
req
7979
.on('response', res => {
80-
if (res.statusCode !== 200) {
80+
if (res.status !== 200) {
8181
reject(new Error(
82-
`Encountered bad status code (${res.statusCode}) for ${req.url}\n` +
82+
`Encountered bad status code (${res.status}) for ${req.url}\n` +
8383
`This could mean the server is experiencing difficulties right now--please try again later.`
8484
));
8585
}
8686

8787
if (progress) {
8888
let loaded = 0;
89-
const total = Number(res.headers['content-length']);
89+
const total = Number(res.header['content-length']);
9090
res.on('data', chunk => {
9191
loaded += chunk.length;
9292
progress(loaded, total);

types/superagent.d.ts

Lines changed: 0 additions & 136 deletions
This file was deleted.

0 commit comments

Comments
 (0)