Skip to content

Add a .d.ts file… - #9

Merged
savetheclocktower merged 3 commits into
masterfrom
add-d-ts
Sep 20, 2026
Merged

savetheclocktower merged 3 commits into
masterfrom
add-d-ts

Conversation

@savetheclocktower

Copy link
Copy Markdown

…and some tests to ensure the .d.ts document everything in the Repository interface (and nothing that isn't there).

This one builds on #8 and thus will stay in draft until that PR lands.

I was looking for ways to add inline documentation for this module. Ordinarily I'd prefer to write JSDoc comments and then use tooling to generate a .d.ts from that… but git-utils defines some methods in JS and some methods in the native C++ bindings. Hence there's no place to hang a JSDoc comment for about half the methods.

Instead, I've hand-authored a .d.ts file. To ensure that the definitions are in sync with what actually exists in the repo, there's a new spec/api-surface-spec.js suite that inspects the .d.ts and the Repository class and ensures they agree.

…and some tests to ensure the `.d.ts` document everything in the `Repository` interface (and nothing that isn't there).
@savetheclocktower
savetheclocktower marked this pull request as ready for review September 20, 2026 18:47
@savetheclocktower

Copy link
Copy Markdown
Author

Did a late pass of arethetypeswrong on these changes and it caught something: I was exporting Repository from the .d.ts as though it could be imported as a value. But the only way you can get an instance of Repository is via the return value of open.

So it's now been changed such that you can import the Repository type… but import { Repository } from '@pulsar-edit/git-utils' will correctly fail type checking.

@savetheclocktower
savetheclocktower merged commit 06d27da into master Sep 20, 2026
8 checks passed
@savetheclocktower
savetheclocktower deleted the add-d-ts branch September 20, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant