Skip to content

Commit

Permalink
Generate .d.ts files automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
Domi04151309 committed Jul 13, 2024
1 parent 57c34e4 commit e4c8b02
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
],
"ignorePatterns": [
"coverage/*",
"generated/*",
"out/*"
],
"parser": "@typescript-eslint/parser",
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/generate-types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Generate Types

on:
push:
branches:
- main
paths:
- '**.js'
- '**.ts'
- '**.json'
pull_request:
branches:
- main

concurrency:
group: generate-types-${{ github.ref }}
cancel-in-progress: true

jobs:
generate-types:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install Dependencies
run: bun install
- name: Run
run: bun run generate-types
- name: Push
continue-on-error: true
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Update generated types"
git push
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
"type": "module",
"name": "build",
"main": "./src/index.js",
"types": "./generated/index.d.ts",
"scripts": {
"eslint": "eslint --no-eslintrc -c .eslintrc.json .",
"generate-types": "rm -rf ./generated && tsc -p tsconfig.d.json",
"lint": "npm run eslint && npm run tsc",
"test": "vitest run",
"test:ui": "vitest --ui --coverage",
Expand Down
18 changes: 18 additions & 0 deletions tsconfig.d.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "generated",
"declarationMap": true,
"removeComments": true
},
"exclude": [
"**/*.config.js",
"**/*.test.js",
"coverage/*",
"generated/*",
"out/*"
]
}

0 comments on commit e4c8b02

Please sign in to comment.