Skip to content

Commit

Permalink
chore: typescript maintenance
Browse files Browse the repository at this point in the history
- Combined the jsconfig files in to a single one.
- Disable declaration sourcemaps
- Correctly set module to NodeNext and resolve inconsistencies.
- Removes types from the repo and .gitignore them for the next commits
- Adds TSC run in CI
- Runs tsc in prepublishOnly, so we can still include .d.ts files in to the published NPM packages
  • Loading branch information
dirkdev98 committed Aug 7, 2023
1 parent 6037fa0 commit 7b3e0f9
Show file tree
Hide file tree
Showing 318 changed files with 3,907 additions and 13,944 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/main-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,35 @@ on:
branches: [main]

jobs:
types:
permissions:
contents: read
timeout-minutes: 15
strategy:
matrix:
node: [20]
runs-on: ubuntu-latest
env:
CI: true
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Node.js ${{ matrix.node }}
uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
cache: "npm"

- name: Install dependencies
run: |
npm ci
- name: Generate and run types
run: |
npx compas generate --skip-tsc --skip-lint
npx compas run types
test:
permissions:
contents: read
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,35 @@ jobs:
CI=false npx compas generate --skip-tsc
npx compas lint
types:
permissions:
contents: read
timeout-minutes: 15
strategy:
matrix:
node: [20]
runs-on: ubuntu-latest
env:
CI: true
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Node.js ${{ matrix.node }}
uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
cache: "npm"

- name: Install dependencies
run: |
npm ci
- name: Generate and run types
run: |
npx compas generate --skip-tsc --skip-lint
npx compas run types
test:
permissions:
contents: read
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ coverage

# Types
**.d.ts.map
**.d.ts
!advanced-types.d.ts
!common/types.d.ts

# Examples
# Ignore any generated output of examples
Expand Down
14 changes: 8 additions & 6 deletions jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
"compilerOptions": {
"target": "esnext",
"lib": ["esnext"],
"noEmit": true,
"module": "esnext",
"module": "NodeNext",
"checkJs": true,
"maxNodeModuleJsDepth": 0,
"baseUrl": "./",
"moduleResolution": "node",
"strict": true,
"noImplicitAny": false
"noImplicitAny": false,
"declaration": true,
"noEmit": false,
"emitDeclarationOnly": true,
"extendedDiagnostics": true
},
"typeAcquisition": {
"enable": true
},
"include": ["**/*.js", "**/types/**/*.d.ts"],
"exclude": ["**/*.test.js", "**/*.bench.js"]
"include": ["packages/**/*"],
"exclude": ["packages/eslint-plugin/**/*", "**/*.test.js", "**/*.bench.js"]
}
12 changes: 0 additions & 12 deletions jsconfig.types.json

This file was deleted.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"private": true,
"type": "module",
"scripts": {
"prepublishOnly": "compas run types",
"postpublish": "compas run types --script-args='clean'",
"docs:dev": "vitepress dev docs",
"docs:build": "vitepress build docs",
"docs:serve": "vitepress serve docs"
Expand Down
10 changes: 0 additions & 10 deletions packages/cli/index.d.ts

This file was deleted.

8 changes: 4 additions & 4 deletions packages/cli/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/**
* @typedef {import("./src/generated/common/types").CliCommandDefinitionInput} CliCommandDefinitionInput
* @typedef {import("./src/generated/common/types.js").CliCommandDefinitionInput} CliCommandDefinitionInput
*/

/**
* @typedef {import("./src/generated/common/types").CliCompletion} CliCompletion
* @typedef {import("./src/generated/common/types.js").CliCompletion} CliCompletion
*/

/**
* @typedef {import("./src/cli/types").CliResult} CliResult
* @typedef {import("./src/cli/types.js").CliResult} CliResult
*/

/**
* @typedef {import("./src/cli/types").CliExecutorState} CliExecutorState
* @typedef {import("./src/cli/types.js").CliExecutorState} CliExecutorState
*/

/**
Expand Down
9 changes: 6 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
"name": "@compas/cli",
"version": "0.6.0",
"description": "CLI containing utilities and simple script runner",
"main": "./index.js",
"exports": {
".": "./index.js",
".": {
"import": {
"types": "./index.d.ts",
"default": "./index.js"
}
},
"./package.json": "./package.json"
},
"types": "./index.d.ts",
"type": "module",
"bin": {
"compas": "src/compas/index.js"
Expand Down
3 changes: 0 additions & 3 deletions packages/cli/src/benchmarking/index.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/cli/src/benchmarking/printer.d.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/cli/src/benchmarking/printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function printBenchResults() {

/**
* @param {string[]} result
* @param {import("./state").BenchState[]} state
* @param {import("./state.js").BenchState[]} state
*/
function printSuccessResults(result, state) {
if (state.length === 0) {
Expand Down Expand Up @@ -120,7 +120,7 @@ function printSuccessResults(result, state) {

/**
* @param {string[]} result
* @param {import("./state").BenchState[]} state
* @param {import("./state.js").BenchState[]} state
*/
function printErrorResults(result, state) {
if (state.length === 0) {
Expand Down
22 changes: 0 additions & 22 deletions packages/cli/src/benchmarking/runner.d.ts

This file was deleted.

8 changes: 4 additions & 4 deletions packages/cli/src/benchmarking/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { isNil } from "@compas/stdlib";
import { benchLogger, state } from "./state.js";

/**
* @param {import("./state").BenchState[]} state
* @param {import("./state.js").BenchState[]} state
* @returns {Promise<void>}
*/
export async function runBenchmarks(state) {
Expand Down Expand Up @@ -38,7 +38,7 @@ export async function runBenchmarks(state) {
* @since 0.1.0
*
* @param {string} name
* @param {import("./state").BenchCallback} callback
* @param {import("./state.js").BenchCallback} callback
* @returns {void}
*/
export function bench(name, callback) {
Expand Down Expand Up @@ -75,7 +75,7 @@ class InternalRunner {

constructor(state) {
/**
* @type {import("./state").BenchState}
* @type {import("./state.js").BenchState}
*/
this.state = state;
}
Expand Down Expand Up @@ -122,7 +122,7 @@ class InternalRunner {
/**
*
* @param {InternalRunner} runner
* @returns {import("./state").BenchRunner}
* @returns {import("./state.js").BenchRunner}
*/
function createBenchRunner(runner) {
return {
Expand Down
68 changes: 0 additions & 68 deletions packages/cli/src/benchmarking/state.d.ts

This file was deleted.

4 changes: 2 additions & 2 deletions packages/cli/src/benchmarking/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/

/**
* @type {Logger}
* @type {import("@compas/stdlib").Logger}
*/
// @ts-ignore
export let benchLogger = undefined;
Expand All @@ -49,7 +49,7 @@ export function setAreBenchRunning(running) {
/**
* Set the bench logger
*
* @param {Logger} logger
* @param {import("@compas/stdlib").Logger} logger
*/
export function setBenchLogger(logger) {
benchLogger = logger;
Expand Down
13 changes: 0 additions & 13 deletions packages/cli/src/benchmarking/utils.d.ts

This file was deleted.

Loading

0 comments on commit 7b3e0f9

Please sign in to comment.