From a26c9ad5f9b6d33433595c9d18ad121a8dad49ea Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 2 Nov 2022 12:46:49 +0100 Subject: [PATCH] Add strict types --- cli.js | 4 ++-- problematic.js | 1 + test/index.js | 6 ++++-- tsconfig.json | 18 ++++++++++-------- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/cli.js b/cli.js index e08690e..2b699b6 100755 --- a/cli.js +++ b/cli.js @@ -4,7 +4,7 @@ import process from 'node:process' import {URL} from 'node:url' import {syllable} from './index.js' -/** @type {Object.} */ +/** @type {Record} */ const pack = JSON.parse( String(fs.readFileSync(new URL('package.json', import.meta.url))) ) @@ -43,7 +43,7 @@ function getSyllables(value) { } /** - * @param {Array.} values + * @param {Array} values */ function syllables(values) { let sum = 0 diff --git a/problematic.js b/problematic.js index d5b0c84..81baf1e 100644 --- a/problematic.js +++ b/problematic.js @@ -1,3 +1,4 @@ +/** @type {Record} */ export const problematic = { abalone: 4, abare: 3, diff --git a/test/index.js b/test/index.js index 55a7b2d..63e0f07 100644 --- a/test/index.js +++ b/test/index.js @@ -1,3 +1,4 @@ +import assert from 'node:assert/strict' import {exec} from 'node:child_process' import fs from 'node:fs' import {URL} from 'node:url' @@ -7,12 +8,12 @@ import {syllable} from '../index.js' const own = {}.hasOwnProperty -/** @type {Object.} */ +/** @type {Record} */ const pack = JSON.parse( String(fs.readFileSync(new URL('../package.json', import.meta.url))) ) -/** @type {Object.} */ +/** @type {Record} */ const fixtures = JSON.parse( String(fs.readFileSync(new URL('fixture.json', import.meta.url))) ) @@ -273,6 +274,7 @@ test('cli', function (t) { t.deepEqual([error, stdout, stderr], [null, '6\n', ''], 'stdin') }) + assert(subprocess.stdin, 'expected `stdin` on child process') input.pipe(subprocess.stdin) input.write('syllab') setImmediate(function () { diff --git a/tsconfig.json b/tsconfig.json index 1cb61bf..016d1f4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,15 +1,17 @@ { - "include": ["*.js", "test/**/*.js"], + "include": ["**/**.js"], + "exclude": ["coverage", "node_modules"], "compilerOptions": { - "target": "ES2020", - "lib": ["ES2020"], - "module": "ES2020", - "moduleResolution": "node", - "allowJs": true, "checkJs": true, "declaration": true, "emitDeclarationOnly": true, - "allowSyntheticDefaultImports": true, - "skipLibCheck": true + "exactOptionalPropertyTypes": true, + "forceConsistentCasingInFileNames": true, + "lib": ["es2020"], + "module": "node16", + "newLine": "lf", + "skipLibCheck": true, + "strict": true, + "target": "es2020" } }