Skip to content

Commit c75ff34

Browse files
committed
feat: generate .d.ts files on publishing
Fixes #24
1 parent 8784cfb commit c75ff34

File tree

6 files changed

+31
-3
lines changed

6 files changed

+31
-3
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
node_modules
2+
index.d.ts
3+
skip-formatting.d.ts

index.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const recommendedConfig = require("eslint-plugin-prettier/recommended");
22

3+
/** @type {import('eslint').Linter.Config} */
34
module.exports = {
45
...recommendedConfig,
56
rules: {

package.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
"main": "index.js",
77
"files": [
88
"index.js",
9-
"skip-formatting.js"
9+
"index.d.ts",
10+
"skip-formatting.js",
11+
"skip-formatting.d.ts"
1012
],
1113
"exports": {
1214
".": "./index.js",
@@ -38,14 +40,16 @@
3840
},
3941
"devDependencies": {
4042
"eslint": "^9.11.0",
41-
"prettier": "^3.3.3"
43+
"prettier": "^3.3.3",
44+
"typescript": "^5.6.3"
4245
},
4346
"peerDependencies": {
4447
"eslint": ">= 8.21.0",
4548
"prettier": ">= 3.0.0"
4649
},
4750
"scripts": {
4851
"lint": "eslint . --fix",
49-
"format": "prettier *.{js,md} --write"
52+
"format": "prettier *.{js,md} --write",
53+
"prepublishOnly": "tsc"
5054
}
5155
}

pnpm-lock.yaml

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

skip-formatting.js

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const eslintConfigPrettier = require("eslint-config-prettier");
44
// Because that would be an overkill:
55
// - since we are not formatting, the plugin isn't needed;
66
// - and without the `prettier/prettier` rule, we don't have to disable the conflicting `arrow-body-style` and `prefer-arrow-callback` rules.
7+
8+
/** @type {import('eslint').Linter.Config} */
79
module.exports = {
810
...eslintConfigPrettier,
911
rules: {

tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"include": ["index.js", "skip-formatting.js"],
3+
"compilerOptions": {
4+
"allowJs": true,
5+
"declaration": true,
6+
"emitDeclarationOnly": true,
7+
"skipLibCheck": true
8+
}
9+
}

0 commit comments

Comments
 (0)