summaryrefslogtreecommitdiff
path: root/mime
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2019-05-30 14:59:30 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-05-30 08:59:30 -0400
commit50a79584cb12129b3db1ef3e0eb9d0c8b9f20b62 (patch)
treeee9a90a8b8018c03b1e1a6ace07abdaa494ea90d /mime
parent80b3c486f6222f65b52eb2eca903b67312e8ce0c (diff)
chore: Implement strict mode (denoland/deno_std#453)
Original: https://github.com/denoland/deno_std/commit/be24677d15494e83eea2e99bfc5ccfdde31cb892
Diffstat (limited to 'mime')
-rw-r--r--mime/multipart.ts24
-rw-r--r--mime/multipart_test.ts5
2 files changed, 15 insertions, 14 deletions
diff --git a/mime/multipart.ts b/mime/multipart.ts
index 580b81dc3..461563a4e 100644
--- a/mime/multipart.ts
+++ b/mime/multipart.ts
@@ -177,20 +177,20 @@ class PartReader implements Reader, Closer {
close(): void {}
- private contentDisposition: string;
- private contentDispositionParams: { [key: string]: string };
+ private contentDisposition!: string;
+ private contentDispositionParams!: { [key: string]: string };
private getContentDispositionParams(): { [key: string]: string } {
if (this.contentDispositionParams) return this.contentDispositionParams;
const cd = this.headers.get("content-disposition");
- const params = {};
- const comps = cd.split(";");
+ const params: { [key: string]: string } = {};
+ const comps = cd!.split(";");
this.contentDisposition = comps[0];
comps
.slice(1)
- .map((v): string => v.trim())
+ .map((v: string): string => v.trim())
.map(
- (kv): void => {
+ (kv: string): void => {
const [k, v] = kv.split("=");
if (v) {
const s = v.charAt(0);
@@ -292,7 +292,7 @@ export class MultipartReader {
file.close();
formFile = {
filename: p.fileName,
- type: p.headers.get("content-type"),
+ type: p.headers.get("content-type")!,
tempfile: filepath,
size
};
@@ -302,20 +302,20 @@ export class MultipartReader {
} else {
formFile = {
filename: p.fileName,
- type: p.headers.get("content-type"),
+ type: p.headers.get("content-type")!,
content: buf.bytes(),
size: buf.length
};
maxMemory -= n;
maxValueBytes -= n;
}
- result[p.formName] = formFile;
+ result[p.formName] = formFile!;
}
return result;
}
- private currentPart: PartReader;
- private partsRead: number;
+ private currentPart: PartReader | undefined;
+ private partsRead: number = 0;
private async nextPart(): Promise<PartReader | EOF> {
if (this.currentPart) {
@@ -437,7 +437,7 @@ export class MultipartWriter {
return this._boundary;
}
- private lastPart: PartWriter;
+ private lastPart: PartWriter | undefined;
private bufWriter: BufWriter;
private isClosed: boolean = false;
diff --git a/mime/multipart_test.ts b/mime/multipart_test.ts
index ed033ad9a..a2fc960b7 100644
--- a/mime/multipart_test.ts
+++ b/mime/multipart_test.ts
@@ -142,6 +142,7 @@ test(async function multipartMultipartWriter3(): Promise<void> {
);
await assertThrowsAsync(
async (): Promise<void> => {
+ // @ts-ignore
await mw.writeFile("bar", "file", null);
},
Error,
@@ -197,7 +198,7 @@ test(async function multipartMultipartReader2(): Promise<void> {
assertEquals(form["bar"], "bar");
const file = form["file"] as FormFile;
assertEquals(file.type, "application/octet-stream");
- const f = await open(file.tempfile);
+ const f = await open(file.tempfile!);
const w = new StringWriter();
await copy(w, f);
const json = JSON.parse(w.toString());
@@ -205,7 +206,7 @@ test(async function multipartMultipartReader2(): Promise<void> {
f.close();
} finally {
const file = form["file"] as FormFile;
- await remove(file.tempfile);
+ await remove(file.tempfile!);
}
});