Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kenotron/typeversion
Semantic Version for your TypeScript declaration files
https://github.com/kenotron/typeversion
Last synced: 10 days ago
JSON representation
Semantic Version for your TypeScript declaration files
- Host: GitHub
- URL: https://github.com/kenotron/typeversion
- Owner: kenotron
- Created: 2023-10-04T22:23:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-17T00:12:08.000Z (11 months ago)
- Last Synced: 2024-12-08T01:13:07.014Z (about 1 month ago)
- Language: TypeScript
- Homepage:
- Size: 1.57 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.json
Awesome Lists containing this project
README
# Semver checker for TypeScript
This is a node library that helps you find incompatibilities in your TypeScript library. The way it achieve this is to draw inspiration from https://semver-ts.org. We heavily leverage TypeScript itself with an internal function that helps us retrieve compatibility information.
A library author would have a workflow similar to the following:
1. bundle and check in a single d.ts representing your public API
a. you may find it helpful to use `api-extractor` or `dts-bundle-generator` to create that single d.ts file
2. on a CI / PR job, create a d.ts that represent the updated version of the public API
3. create a tool that uses `typeversion` to compare before and after d.ts to inform whether the change is a breaking change or not## Node API
```ts
import { compare } from "typeversion";
import fs from "fs";async function main() {
const results = await compare({
base: { fileName: "base.ts", source: fs.readFileSync("base.ts", "utf-8") },
target: {
fileName: "target.ts",
source: fs.readFileSync("target.ts", "utf-8"),
},
});// results now contain the recommended change type and optionally a list of messages that indicate why `typeversion` recommends
// a certain kind of change
}main();
```