-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[types] Generate declarations from JS (#564)
* feat: Generate declarations from JSDoc * feat: Add back `package.json` types mentions * fix: Add missing `copy-declarations.js` script * fix: Ordering in `build:ts` script Co-authored-by: Lloyd Kupchanko <lloyd@lloydk.ca> * fix: Create declarations directory if nonexistant Co-authored-by: Lloyd Kupchanko <lloyd@lloydk.ca> * fix: Add missing import Co-authored-by: Lloyd Kupchanko <lloyd@lloydk.ca> * fix: Remove non-existent file from `TO_COPY` * build: Add `watch:ts` script --------- Co-authored-by: Lloyd Kupchanko <lloyd@lloydk.ca>
- Loading branch information
1 parent
774b04b
commit 2821bc4
Showing
7 changed files
with
61 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ assets/js/prism.js | |
api/ | ||
/dist/ | ||
docs/ | ||
types/src/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,7 @@ node_modules/ | |
!test/*.html | ||
!benchmarks/*.html | ||
|
||
api/ | ||
# Ignore generated TypeScript files | ||
types/src/ | ||
|
||
api/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copy manually-written `.d.ts` files from `src/` to `types/src/` | ||
import { copyFileSync, mkdirSync } from "node:fs"; | ||
import { dirname, resolve } from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
|
||
const SOURCE = "../src/"; | ||
const DEST = "../types/src/"; | ||
|
||
/** | ||
* `.d.ts` files to copy. | ||
* Paths written relative to the `src/` directory | ||
*/ | ||
const TO_COPY = [ | ||
"color.d.ts", | ||
"ColorSpace.d.ts", | ||
"hooks.d.ts", | ||
"index.d.ts", | ||
"space-coord-accessors.d.ts", | ||
"types.d.ts", | ||
]; | ||
|
||
/** Script file directory */ | ||
const __dirname = dirname(fileURLToPath(import.meta.url)); | ||
mkdirSync(resolve(__dirname, DEST), { recursive: true }); | ||
for (const file of TO_COPY) { | ||
copyFileSync( | ||
resolve(__dirname, SOURCE, file), | ||
resolve(__dirname, DEST, file), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
// Minimum TypeScript Version: 5.0 | ||
export { default } from "./src/index.js"; | ||
export * from "./src/index.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters