Skip to content

Commit 3a26104

Browse files
committed
add jsdoc types in js files
1 parent eed8ce7 commit 3a26104

File tree

5 files changed

+56
-8
lines changed

5 files changed

+56
-8
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
"@babel/preset-typescript": "^7.7.4",
2323
"@rollup/plugin-replace": "^2.2.1",
2424
"@types/jest": "26.x",
25+
"@types/jsonfile": "^6.0.1",
2526
"@types/react": "16.x",
2627
"@types/react-dom": "16.x",
2728
"@types/react-native": "*",
2829
"@types/react-test-renderer": "16.x",
30+
"@types/semver": "^7.3.8",
2931
"@typescript-eslint/eslint-plugin": "^4.28.3",
3032
"@typescript-eslint/parser": "^4.28.3",
3133
"babel-eslint": "^10.1.0",

scripts/publish.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ function invariant(cond, message) {
1717
if (!cond) throw new Error(message);
1818
}
1919

20+
/**
21+
* @returns {string}
22+
*/
2023
function getTaggedVersion() {
2124
let output = execSync("git tag --list --points-at HEAD").toString();
2225
return output.replace(/^v|\n+$/g, "");
2326
}
2427

28+
/**
29+
* @param {string} packageName
30+
* @param {string|number} version
31+
*/
2532
async function ensureBuildVersion(packageName, version) {
2633
let file = path.join(rootDir, "build", packageName, "package.json");
2734
let json = await jsonfile.readFile(file);
@@ -31,6 +38,10 @@ async function ensureBuildVersion(packageName, version) {
3138
);
3239
}
3340

41+
/**
42+
* @param {string} packageName
43+
* @param {string} tag
44+
*/
3445
function publishBuild(packageName, tag) {
3546
let buildDir = path.join(rootDir, "build", packageName);
3647
console.log();
@@ -39,6 +50,9 @@ function publishBuild(packageName, tag) {
3950
execSync(`npm publish ${buildDir} --tag ${tag}`, { stdio: "inherit" });
4051
}
4152

53+
/**
54+
* @returns {Promise<1 | 0>}
55+
*/
4256
async function run() {
4357
try {
4458
// 0. Ensure we are in CI. We don't do this manually

scripts/version.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import path from "path";
22
import { fileURLToPath } from "url";
33
import { execSync } from "child_process";
4-
54
import chalk from "chalk";
65
import Confirm from "prompt-confirm";
76
import jsonfile from "jsonfile";
@@ -10,10 +9,19 @@ import semver from "semver";
109
const dirname = path.dirname(fileURLToPath(import.meta.url));
1110
const rootDir = path.resolve(dirname, "..");
1211

12+
/**
13+
* @param {string} packageName
14+
* @returns {string}
15+
*/
1316
function packageJson(packageName) {
1417
return path.join(rootDir, "packages", packageName, "package.json");
1518
}
1619

20+
/**
21+
* @param {*} cond
22+
* @param {string} message
23+
* @returns {asserts cond}
24+
*/
1725
function invariant(cond, message) {
1826
if (!cond) throw new Error(message);
1927
}
@@ -27,6 +35,12 @@ function ensureCleanWorkingDirectory() {
2735
);
2836
}
2937

38+
/**
39+
* @param {string} currentVersion
40+
* @param {string} givenVersion
41+
* @param {string} [prereleaseId]
42+
* @returns {string}
43+
*/
3044
function getNextVersion(currentVersion, givenVersion, prereleaseId) {
3145
invariant(
3246
givenVersion != null,
@@ -47,18 +61,29 @@ function getNextVersion(currentVersion, givenVersion, prereleaseId) {
4761
return nextVersion;
4862
}
4963

64+
/**
65+
* @param {string} question
66+
* @returns {Promise<string>}
67+
*/
5068
async function prompt(question) {
5169
let confirm = new Confirm(question);
5270
let answer = await confirm.run();
5371
return answer;
5472
}
5573

74+
/**
75+
* @param {string} packageName
76+
*/
5677
async function getPackageVersion(packageName) {
5778
let file = packageJson(packageName);
5879
let json = await jsonfile.readFile(file);
5980
return json.version;
6081
}
6182

83+
/**
84+
* @param {string} packageName
85+
* @param {(json: string) => any} transform
86+
*/
6287
async function updatePackageConfig(packageName, transform) {
6388
let file = packageJson(packageName);
6489
let json = await jsonfile.readFile(file);

tsconfig.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
"stripInternal": true,
1818
"jsx": "react"
1919
},
20-
"files": [
21-
"packages/react-router/index.tsx",
22-
"packages/react-router-dom/index.tsx",
23-
"packages/react-router-dom/server.tsx",
24-
"packages/react-router-native/index.tsx"
25-
],
26-
"include": ["types/global.d.ts"]
20+
"include": ["packages/**/*", "types/*"],
21+
"exclude": ["**/*.*.snap"]
2722
}

yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1681,6 +1681,13 @@
16811681
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
16821682
integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4=
16831683

1684+
"@types/jsonfile@^6.0.1":
1685+
version "6.0.1"
1686+
resolved "https://registry.yarnpkg.com/@types/jsonfile/-/jsonfile-6.0.1.tgz#639eff0748d60dfbc9d5f743ca7178bd93f53c71"
1687+
integrity sha512-SSCc8i9yl6vjgXSyZb0uEodk3UjXuWd55t1D+Ie1zuTx7ml+2AEj0Xyomi3NBz1gCBsZVyWWnXOLXowS1ufhEw==
1688+
dependencies:
1689+
"@types/node" "*"
1690+
16841691
"@types/minimatch@*":
16851692
version "3.0.4"
16861693
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.4.tgz#f0ec25dbf2f0e4b18647313ac031134ca5b24b21"
@@ -1750,6 +1757,11 @@
17501757
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.1.tgz#18845205e86ff0038517aab7a18a62a6b9f71275"
17511758
integrity sha512-EaCxbanVeyxDRTQBkdLb3Bvl/HK7PBK6UJjsSixB0iHKoWxE5uu2Q/DgtpOhPIojN0Zl1whvOd7PoHs2P0s5eA==
17521759

1760+
"@types/semver@^7.3.8":
1761+
version "7.3.8"
1762+
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.8.tgz#508a27995498d7586dcecd77c25e289bfaf90c59"
1763+
integrity sha512-D/2EJvAlCEtYFEYmmlGwbGXuK886HzyCc3nZX/tkFTQdEU8jZDAgiv08P162yB17y4ZXZoq7yFAnW4GDBb9Now==
1764+
17531765
"@types/stack-utils@^1.0.1":
17541766
version "1.0.1"
17551767
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"

0 commit comments

Comments
 (0)