Skip to content

Commit

Permalink
Add strict types
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 2, 2022
1 parent 47dbf38 commit a26c9ad
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import process from 'node:process'
import {URL} from 'node:url'
import {syllable} from './index.js'

/** @type {Object.<string, unknown>} */
/** @type {Record<string, unknown>} */
const pack = JSON.parse(
String(fs.readFileSync(new URL('package.json', import.meta.url)))
)
Expand Down Expand Up @@ -43,7 +43,7 @@ function getSyllables(value) {
}

/**
* @param {Array.<string>} values
* @param {Array<string>} values
*/
function syllables(values) {
let sum = 0
Expand Down
1 change: 1 addition & 0 deletions problematic.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/** @type {Record<string, number>} */
export const problematic = {
abalone: 4,
abare: 3,
Expand Down
6 changes: 4 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -7,12 +8,12 @@ import {syllable} from '../index.js'

const own = {}.hasOwnProperty

/** @type {Object.<string, unknown>} */
/** @type {Record<string, unknown>} */
const pack = JSON.parse(
String(fs.readFileSync(new URL('../package.json', import.meta.url)))
)

/** @type {Object.<string, number>} */
/** @type {Record<string, number>} */
const fixtures = JSON.parse(
String(fs.readFileSync(new URL('fixture.json', import.meta.url)))
)
Expand Down Expand Up @@ -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 () {
Expand Down
18 changes: 10 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit a26c9ad

Please sign in to comment.