Skip to content

Commit

Permalink
Test type generation from jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
bcomnes committed Oct 29, 2023
1 parent 3e5c6fd commit d973b06
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
/npm-debug.log
/test.js
package-lock.json

*.d.ts
*.d.ts.map
12 changes: 12 additions & 0 deletions declaration.tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"noEmit": false,
"emitDeclarationOnly": true
},
"exclude": [
"**/*.test.js",
]
}
15 changes: 12 additions & 3 deletions lib/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ const removeFile = require('./utils/remove-file')
// Exports
// ------------------------------------------------------------------------------

/**
* @typedef {{
cleaned: string[],
copied: string[],
options: object
}} CopyReport
*/

/**
* Copy files asynchronously.
* @param {string} source The glob pattern of target files.
Expand All @@ -32,9 +40,9 @@ const removeFile = require('./utils/remove-file')
* @param {boolean} [options.preserve=false] The flag to copy file attributes such as timestamps, users, and groups.
* @param {(function(string):void)[]} [options.transform] The array of the factories of transform streams.
* @param {boolean} [options.update=false] The flag to not overwrite newer files.
* @param {string|Array.<string>} [options.ignore] - gitignore string or array of gitignore strings
* @param {function(Error):void} [callback] The callback function which will go fulfilled after done.
* @returns {Promise<void>} The promise which will go fulfilled after done.
* @param {string[]|string|null|undefined} [options.ignore] - gitignore string or array of gitignore strings
* @param {function(Error, CopyReport):void} [callback] The callback function which will go fulfilled after done.
* @returns {Promise<CopyReport>} The promise which will go fulfilled after done.
*/
module.exports = async function copy (source, outputDir, options, callback) {
/* eslint-disable no-param-reassign */
Expand Down Expand Up @@ -81,6 +89,7 @@ module.exports = async function copy (source, outputDir, options, callback) {
return Promise.resolve()
})

/** @type {CopyReport} */
const report = {
cleaned,
copied: copied.filter(r => r), // clean holes,
Expand Down
17 changes: 13 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"node": ">=16"
},
"main": "lib/index.js",
"types": "./lib/index.d.ts",
"bin": {
"cpx": "bin/index.js"
},
Expand All @@ -14,14 +15,18 @@
"lib"
],
"scripts": {
"prepublishOnly": "git push --follow-tags && gh-release -y",
"prepublishOnly": "npm run build && git push --follow-tags && gh-release -y",
"postpublish": "npm run clean",
"version": "auto-changelog -p --template keepachangelog auto-changelog --breaking-pattern 'BREAKING CHANGE:' && git add CHANGELOG.md",
"_mocha": "_mocha \"test/*.js\" --timeout 35000",
"clean": "rm -rf .nyc_output coverage test-ws",
"clean": "run-p clean:*",
"coverage": "nyc report -r lcov && opener coverage/lcov-report/index.html",
"lint": "standard",
"test": "nyc --require @babel/register npm run -s _mocha",
"watch": "npm run -s _mocha -- --require @babel/register --watch --growl"
"watch": "npm run -s _mocha -- --require @babel/register --watch --growl",
"build": "npm run clean && run-p build:*",
"build:declaration": "tsc -p declaration.tsconfig.json",
"clean:declarations-lib": "rm -rf $(find {lib,bin} -type f -name '*.d.ts*' ! -name '*-types.d.ts')"
},
"dependencies": {
"debounce": "^1.2.0",
Expand All @@ -41,17 +46,21 @@
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/register": "^7.5.5",
"@types/node": "^20.8.9",
"@voxpelli/tsconfig": "^9.0.0",
"auto-changelog": "^2.2.0",
"babel-preset-power-assert": "^3.0.0",
"gh-release": "^7.0.2",
"mocha": "^10.2.0",
"npm-run-all2": "^6.1.1",
"nyc": "15.1.0",
"opener": "^1.5.1",
"p-event": "^6.0.0",
"power-assert": "^1.6.1",
"shelljs": "^0.8.3",
"standard": "^17.1.0",
"through": "^2.3.8"
"through": "^2.3.8",
"typescript": "~5.2.2"
},
"repository": {
"type": "git",
Expand Down
13 changes: 13 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "@voxpelli/tsconfig/node18.json",
"compilerOptions": {
"skipLibCheck": true
},
"include": [
"lib/**/*",
"bin/**/*"
],
"exclude": [
"node_modules"
]
}

0 comments on commit d973b06

Please sign in to comment.