Skip to content

Commit 84c0299

Browse files
committed
Add JSDoc based types
1 parent 8d42926 commit 84c0299

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
2+
*.d.ts
23
*.log
34
.nyc_output/
45
coverage/

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
// Remove final newline characters from `value`.
1+
/**
2+
* Remove final newline characters from `value`.
3+
*
4+
* @param {unknown} value Value with trailing line feeds, coerced to string.
5+
* @return {string} Value without trailing newlines.
6+
*/
27
export function trimTrailingLines(value) {
38
return String(value).replace(/\n+$/, '')
49
}

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,30 @@
2323
"sideEffects": false,
2424
"type": "module",
2525
"main": "index.js",
26+
"types": "index.d.ts",
2627
"files": [
28+
"index.d.ts",
2729
"index.js"
2830
],
2931
"devDependencies": {
30-
"c8": "^7.6.0",
32+
"@types/tape": "^4.0.0",
33+
"c8": "^7.0.0",
3134
"prettier": "^2.0.0",
3235
"remark-cli": "^9.0.0",
3336
"remark-preset-wooorm": "^8.0.0",
37+
"rimraf": "^3.0.0",
3438
"tape": "^5.0.0",
39+
"typescript": "^4.0.0",
3540
"xo": "^0.38.0"
3641
},
3742
"scripts": {
43+
"prepublishOnly": "npm run build && npm run format",
44+
"prebuild": "rimraf \"*.d.ts\"",
45+
"build": "tsc",
3846
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
3947
"test-api": "node test.js",
4048
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
41-
"test": "npm run format && npm run test-coverage"
49+
"test": "npm run build && npm run format && npm run test-coverage"
4250
},
4351
"prettier": {
4452
"tabWidth": 2,

tsconfig.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"files": ["index.js"],
3+
"include": ["*.js"],
4+
"compilerOptions": {
5+
"target": "ES2020",
6+
"lib": ["ES2020"],
7+
"module": "ES2020",
8+
"moduleResolution": "node",
9+
"allowJs": true,
10+
"checkJs": true,
11+
"declaration": true,
12+
"emitDeclarationOnly": true,
13+
"allowSyntheticDefaultImports": true,
14+
"skipLibCheck": true
15+
}
16+
}

0 commit comments

Comments
 (0)