Enable TS strict mode by default (#3899)

Fixes #3324 

Co-authored-by: Kitson Kelly <me@kitsonkelly.com>
This commit is contained in:
Maximilien Mellen 2020-02-19 21:36:18 +01:00 committed by GitHub
parent 852823fa50
commit 90125566bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
56 changed files with 314 additions and 179 deletions

View file

@ -36,7 +36,9 @@ test(function formDataParamsGetSuccess(): void {
formData.append("a", "true");
formData.append("b", "false");
formData.append("a", "null");
// @ts-ignore
formData.append("d", undefined);
// @ts-ignore
formData.append("e", null);
assertEquals(formData.get("a"), "true");
assertEquals(formData.get("b"), "false");
@ -63,8 +65,10 @@ test(function formDataParamsSetSuccess(): void {
assertEquals(formData.getAll("b"), ["false"]);
formData.set("a", "false");
assertEquals(formData.getAll("a"), ["false"]);
// @ts-ignore
formData.set("d", undefined);
assertEquals(formData.get("d"), "undefined");
// @ts-ignore
formData.set("e", null);
assertEquals(formData.get("e"), "null");
});
@ -101,15 +105,22 @@ test(function formDataParamsForEachSuccess(): void {
});
test(function formDataParamsArgumentsCheck(): void {
const methodRequireOneParam = ["delete", "getAll", "get", "has", "forEach"];
const methodRequireOneParam = [
"delete",
"getAll",
"get",
"has",
"forEach"
] as const;
const methodRequireTwoParams = ["append", "set"];
const methodRequireTwoParams = ["append", "set"] as const;
methodRequireOneParam.forEach((method): void => {
const formData = new FormData();
let hasThrown = 0;
let errMsg = "";
try {
// @ts-ignore
formData[method]();
hasThrown = 1;
} catch (err) {
@ -133,6 +144,7 @@ test(function formDataParamsArgumentsCheck(): void {
let errMsg = "";
try {
// @ts-ignore
formData[method]();
hasThrown = 1;
} catch (err) {
@ -152,6 +164,7 @@ test(function formDataParamsArgumentsCheck(): void {
hasThrown = 0;
errMsg = "";
try {
// @ts-ignore
formData[method]("foo");
hasThrown = 1;
} catch (err) {