Skip to content

Commit

Permalink
chore(tsconfig): enable checkJs compiler option
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Sep 17, 2023
1 parent fbedb02 commit f2502e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ const execFileAsync = promisify(execFile);
* @description Checks each option provided is valid, of the correct type, and can be used by specified
* version of binary.
* @ignore
* @param {object} acceptedOptions - Object containing options that a binary accepts.
* @param {object} options - Object containing options to pass to binary.
* @param {{[key: string]: {arg: string, type: string, minVersion: string, maxVersion?: string}}} acceptedOptions - Object containing accepted options.
* @param {{[key: string]: any}} options - Object containing options to pass to binary.
* @param {string} [version] - Semantic version of binary.
* @returns {string[]} Array of CLI arguments.
* @throws If invalid arguments provided.
*/
function parseOptions(acceptedOptions, options, version) {
/** @type {string[]} */
const args = [];
/** @type {string[]} */
const invalidArgs = [];
Object.keys(options).forEach((key) => {
if (Object.hasOwn(acceptedOptions, key)) {
Expand Down Expand Up @@ -53,6 +55,7 @@ function parseOptions(acceptedOptions, options, version) {
if (
acceptedOptions[key].maxVersion &&
version &&
// @ts-ignore: type checking is done above
gt(version, acceptedOptions[key].maxVersion)
) {
invalidArgs.push(
Expand Down Expand Up @@ -187,6 +190,7 @@ class UnRTF {
* v0.19.3 returns "0.19.3\r\n"
* v0.21.0 returns "0.21.10\nsearch path is: /usr/share/unrtf/\n"
*/
// @ts-ignore: parseOptions checks if falsy
const versionInfo = /^(\d{1,2}\.\d{1,2}\.\d{1,2})/u.exec(stderr)[1];

const args = parseOptions(acceptedOptions, options, versionInfo);
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"lib": ["ES2023"],
Expand Down

0 comments on commit f2502e6

Please sign in to comment.