Skip to content

Commit

Permalink
Enable @ts-check to work (again) and add it to some files (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis committed Mar 26, 2024
1 parent e5710f4 commit 9a89a24
Show file tree
Hide file tree
Showing 25 changed files with 49 additions and 44 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Expand Up @@ -6,6 +6,4 @@ dist/
dist-build/
dist-ssr/
dist-start/
.eslintcache
yarn.lock
tsconfig.tsbuildinfo
5 changes: 2 additions & 3 deletions package.json
Expand Up @@ -5,8 +5,8 @@
"scripts": {
"postinstall": "node ./postinstall.js",
"prepare": "husky",
"lint": "concurrently -c auto --group 'pnpm:lint:*'",
"lint:eslint": "eslint --cache .",
"lint": "pnpm run '/^lint:.*/'",
"lint:eslint": "eslint --cache --cache-location 'node_modules/.cache/eslint/.eslintcache' .",
"lint:prettier": "prettier --cache --list-different '**/*.{js,ts,tsx,md,less,css}'",
"lint:tsc": "tsc",
"check": "pnpm install --frozen-lockfile && echo 'Ignore paths from lint-staged'",
Expand Down Expand Up @@ -47,7 +47,6 @@
"@tsconfig/node-lts": "^18.12.3",
"@types/jest": "^29.0.0",
"@types/node": "^18.16.19",
"concurrently": "^8.2.1",
"debug": "^4.3.1",
"dedent": "^1.5.1",
"eslint": "^8.41.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/sku/lib/allocatePort.js
@@ -1,9 +1,10 @@
// @ts-check
const { yellow, bold } = require('chalk');
const getPort = require('get-port');
const debug = require('debug')('sku:allocatePort');

/**
* @param {{ port?: number, host?: string }}
* @param {{ port?: number, host?: string }} options
*/
const allocatePort = async ({ port, host }) => {
debug(`Finding available port with request for ${port}`);
Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/buildFileUtils.js
@@ -1,3 +1,4 @@
// @ts-check
const path = require('node:path');
const fs = require('node:fs/promises');
const { rimraf } = require('rimraf');
Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/copyDirContents.js
@@ -1,3 +1,4 @@
// @ts-check
const path = require('node:path');
const fs = require('node:fs/promises');
const exists = require('./exists');
Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/createServer.js
@@ -1,3 +1,4 @@
// @ts-check
const http = require('node:http');
const https = require('node:https');

Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/cwd.js
@@ -1,3 +1,4 @@
// @ts-check
const path = require('node:path');

let currentCwd = process.cwd();
Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/env.js
@@ -1,3 +1,4 @@
// @ts-check
const args = require('../config/args');

/**
Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/exists.js
@@ -1,3 +1,4 @@
// @ts-check
const { access } = require('node:fs/promises');

/**
Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/getSiteForHost.js
@@ -1,3 +1,4 @@
// @ts-check
const { sites } = require('../context');

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/sku/lib/install.js
@@ -1,9 +1,11 @@
// @ts-check
const { getAddCommand } = require('./packageManager');

const spawn = require('cross-spawn');

/**
* @param {import("../lib/packageManager").GetAddCommandOptions} options
* @returns {Promise<void>}
*/
module.exports = ({ deps, type, logLevel, exact = true }) =>
new Promise((resolve, reject) => {
Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/isCI.js
@@ -1 +1,2 @@
// @ts-check
module.exports = Boolean(process.env.CI || process.env.BUILDKITE_BUILD_ID);
1 change: 1 addition & 0 deletions packages/sku/lib/isCompilePackage.js
@@ -1,3 +1,4 @@
// @ts-check
const { getPathFromCwd } = require('./cwd');

const isCompilePackage = () => {
Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/isEmptyDir.js
@@ -1,3 +1,4 @@
// @ts-check
const { statSync, readdirSync } = require('node:fs');

/**
Expand Down
5 changes: 4 additions & 1 deletion packages/sku/lib/parseArgs.js
@@ -1,10 +1,11 @@
// @ts-check
const minimist = require('minimist');

/**
* Supports parsing args that look like:
* [/path/to/node/node, /path/to/sku, scriptName, arg1, arg2]
*
* @param {string[]} args - should look like process.argv
* @param {string[]} processArgv - should look like process.argv
*/
module.exports = (processArgv) => {
/**
Expand Down Expand Up @@ -48,6 +49,8 @@ module.exports = (processArgv) => {
// need to track them ourselves
unknown: (arg) => {
unknown.push(arg);

return true;
},
},
);
Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/routeMatcher.js
@@ -1,3 +1,4 @@
// @ts-check
const { match } = require('path-to-regexp');

/**
Expand Down
5 changes: 3 additions & 2 deletions packages/sku/lib/runBin.js
@@ -1,3 +1,4 @@
// @ts-check
const path = require('node:path');
const spawn = require('cross-spawn');

Expand Down Expand Up @@ -45,13 +46,13 @@ const spawnPromise = (commandPath, args, options) => {
*/

/**
* @param {Options}
* @param {Options} options
*/
const runBin = ({ packageName, binName, args, options }) =>
spawnPromise(resolveBin(packageName, binName), args, options);

/**
* @param {Options}
* @param {Options} options
*/
const startBin = ({ packageName, binName, args, options }) => {
const childProcess = spawn(resolveBin(packageName, binName), args, options);
Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/runTsc.js
@@ -1,3 +1,4 @@
// @ts-check
const chalk = require('chalk');
const { runBin } = require('./runBin');
const { cwd } = require('./cwd');
Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/runVocab.js
@@ -1,3 +1,4 @@
// @ts-check
const { compile } = require('@vocab/core');
const { getVocabConfig } = require('../config/vocab/vocab');

Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/storybook.js
@@ -1,3 +1,4 @@
// @ts-check
const path = require('node:path');
const fs = require('node:fs/promises');
const debug = require('debug');
Expand Down
1 change: 1 addition & 0 deletions packages/sku/lib/suggestScript.js
@@ -1,3 +1,4 @@
// @ts-check
const { getRunCommand, getExecuteCommand } = require('./packageManager');

const chalk = require('chalk');
Expand Down
2 changes: 2 additions & 0 deletions packages/sku/package.json
Expand Up @@ -130,7 +130,9 @@
},
"devDependencies": {
"@types/cross-spawn": "^6.0.3",
"@types/debug": "^4.1.12",
"@types/express": "^4.17.11",
"@types/minimist": "^1.2.5",
"@types/react": "^18.2.3",
"@types/react-dom": "^18.2.3",
"@types/which": "^3.0.0",
Expand Down
4 changes: 0 additions & 4 deletions packages/sku/tsconfig.json

This file was deleted.

46 changes: 16 additions & 30 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion tsconfig.json
Expand Up @@ -5,7 +5,9 @@
"allowJs": true,
"jsx": "react-jsx",
"noEmit": true,
// Output incremental build info to node_modules
"outDir": "node_modules/.cache/typescript",
"incremental": true
},
"include": ["tests/**/*", "test-utils/**/*"]
"exclude": ["node_modules", "fixtures", "packages/sku/template"]
}

0 comments on commit 9a89a24

Please sign in to comment.