From cb23d177019bbc86600f3b23a66a809ec043b364 Mon Sep 17 00:00:00 2001 From: ExE Boss <3889017+ExE-Boss@users.noreply.github.com> Date: Mon, 2 Mar 2020 20:10:37 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20Disallow=C2=A0`"strict":=C2=A0false`=20?= =?UTF-8?q?(#277)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/dtslint/src/checks.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/dtslint/src/checks.ts b/packages/dtslint/src/checks.ts index 40ad164b2c..98c735123a 100644 --- a/packages/dtslint/src/checks.ts +++ b/packages/dtslint/src/checks.ts @@ -82,6 +82,7 @@ export async function checkTsconfig(dirPath: string, dt: DefinitelyTypedInfo | u case "lib": case "noImplicitAny": case "noImplicitThis": + case "strict": case "strictNullChecks": case "strictFunctionTypes": case "esModuleInterop": @@ -109,7 +110,17 @@ export async function checkTsconfig(dirPath: string, dt: DefinitelyTypedInfo | u throw new Error('Must specify "lib", usually to `"lib": ["es6"]` or `"lib": ["es6", "dom"]`.'); } - if (!("strict" in options)) { + if ("strict" in options) { + if (options.strict !== true) { + throw new Error('When "strict" is present, it must be set to `true`.'); + } + + for (const key of ["noImplicitAny", "noImplicitThis", "strictNullChecks", "strictFunctionTypes"]) { + if (key in options) { + throw new TypeError(`Expected "${key}" to not be set when "strict" is \`true\`.`); + } + } + } else { for (const key of ["noImplicitAny", "noImplicitThis", "strictNullChecks", "strictFunctionTypes"]) { if (!(key in options)) { throw new Error(`Expected \`"${key}": true\` or \`"${key}": false\`.`);