Skip to content

Commit da73a0a

Browse files
authored
Add typescript project references (#787)
1 parent 10ee3fa commit da73a0a

File tree

277 files changed

+3021
-525
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+3021
-525
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,14 @@ jobs:
124124
- uses: ./.github/actions/setup-node
125125
- run: npx eslint .
126126
- run: npx prettier --list-different .
127-
- run: npx lerna run --parallel build-tsc
128127

129128
check_typescript:
130129
name: 📋 Check TypeScript
131130
runs-on: ubuntu-24.04
132131
steps:
133132
- uses: actions/checkout@v4
134133
- uses: ./.github/actions/setup-node
135-
- run: npx lerna run build-ts
136-
- run: npx lerna run check-ts
134+
- run: yarn build:ts
137135

138136
lint_rust:
139137
name: 🦀 Lint Rust
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Type Coverage PR Comment
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
concurrency:
8+
# Cancel previous runs for the same PR
9+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
10+
cancel-in-progress: true
11+
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
16+
jobs:
17+
type-coverage:
18+
name: Type Coverage Report
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
with:
25+
# Fetch full history to enable comparison with base branch
26+
fetch-depth: 0
27+
28+
- name: Setup Node.js
29+
uses: ./.github/actions/setup-node
30+
31+
- name: Fetch base branch
32+
run: |
33+
git fetch origin ${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
34+
35+
- name: Install dependencies
36+
run: yarn install --frozen-lockfile
37+
38+
- name: Build TypeScript references
39+
run: yarn update-ts-references --frozen
40+
41+
- name: Run type coverage
42+
id: type-coverage
43+
uses: actions/github-script@v7
44+
with:
45+
result-encoding: string
46+
script: |
47+
const { generateTypeCoverageComment } = require('./scripts/generate-type-coverage-comment.js');
48+
49+
return generateTypeCoverageComment();
50+
51+
- name: Find existing comment
52+
uses: peter-evans/find-comment@v3
53+
id: find-comment
54+
with:
55+
issue-number: ${{ github.event.pull_request.number }}
56+
comment-author: 'github-actions[bot]'
57+
body-includes: '📊 Type Coverage Report'
58+
59+
- name: Create or update comment
60+
uses: peter-evans/create-or-update-comment@v4
61+
with:
62+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
63+
issue-number: ${{ github.event.pull_request.number }}
64+
body: ${{ steps.type-coverage.outputs.result }}
65+
edit-mode: replace

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"typescript.tsdk": "node_modules/typescript/lib",
23
"rust-analyzer.cargo.features": "all",
34
"rust-analyzer.check.command": "clippy",
45
"javascript.validate.enable": false,

crates/apvm/src/cmd/install_git.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,8 @@ pub fn install_from_git(
5858
println!("Building (Native)");
5959
exec_blocking(["yarn", "build-native-release"], &command_options)?;
6060

61-
println!("Building (Flow)");
62-
exec_blocking(["yarn", "build"], &command_options)?;
63-
6461
println!("Building (TypeScript)");
65-
exec_blocking(["yarn", "build-ts"], &command_options)?;
62+
exec_blocking(["yarn", "build"], &command_options)?;
6663

6764
// Save a little space
6865
fs::remove_dir_all(inner_temp.path().join("target"))?;

nx.json

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22
"$schema": "https://raw.githubusercontent.com/nrwl/nx/refs/heads/master/packages/nx/schemas/nx-schema.json",
33
"parallel": "200%",
44
"targetDefaults": {
5-
"check-ts": {
6-
"dependsOn": ["^check-ts", "^dev:prepare"],
7-
"inputs": [
8-
"{projectRoot}/src/**/*.{ts,tsx}",
9-
"{projectRoot}/tsconfig.json",
10-
"{projectRoot}/package.json"
11-
],
12-
"outputs": ["{projectRoot}/lib/**/*.js", "{projectRoot}/**/*.d.ts"],
13-
"cache": true
14-
},
155
"dev:prepare": {
166
"inputs": [
177
"{projectRoot}/**/*.{ts,tsx}",
@@ -35,15 +25,13 @@
3525
"test": {
3626
"dependsOn": [
3727
{"projects": ["*"], "target": "build-native-release"},
38-
{"projects": ["*"], "target": "build:lib"},
39-
{"projects": ["*"], "target": "check-ts"}
28+
{"projects": ["*"], "target": "build:lib"}
4029
]
4130
},
4231
"test:integration": {
4332
"dependsOn": [
4433
{"projects": ["*"], "target": "build-native-release"},
45-
{"projects": ["*"], "target": "build:lib"},
46-
{"projects": ["*"], "target": "check-ts"}
34+
{"projects": ["*"], "target": "build:lib"}
4735
]
4836
},
4937
"build-native-release": {
@@ -62,8 +50,7 @@
6250
"test:integration:ci": {
6351
"dependsOn": [
6452
{"projects": ["*"], "target": "build-native-release"},
65-
{"projects": ["*"], "target": "build:lib"},
66-
{"projects": ["*"], "target": "check-ts"}
53+
{"projects": ["*"], "target": "build:lib"}
6754
]
6855
}
6956
}

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@
1919
"@swc/core": "1.11.18"
2020
},
2121
"scripts": {
22-
"build": "yarn build:clean && yarn build:prepare && yarn build:tsc && yarn build:gulp && yarn build-ts",
22+
"build": "yarn build:clean && yarn build:prepare && yarn build:gulp && yarn build:ts",
2323
"build:clean": "node ./scripts/clean.mjs",
2424
"build:prepare": "lerna run dev:prepare",
25-
"build:tsc": "lerna run --parallel build-tsc",
2625
"build:gulp": "cross-env NODE_ENV=production ATLASPACK_BUILD_ENV=production ATLASPACK_REGISTER_USE_SRC=true gulp",
27-
"build-ts": "lerna run build-ts",
28-
"build-dts": "yarn check-ts",
26+
"build:ts": "yarn update-ts-references && tsc --build tsconfig.paths.json",
2927
"build-native": "node scripts/build-native.js",
3028
"build-native-release": "cross-env CARGO_PROFILE=release node scripts/build-native.js",
3129
"build-native-wasm": "cross-env CARGO_PROFILE=release RUSTUP_TARGET=wasm32-unknown-unknown scripts/build-native.js",
@@ -37,10 +35,10 @@
3735
"link-all": "node scripts/link-all.js packages",
3836
"unlink-all": "node scripts/unlink-all.js packages",
3937
"check": "flow check",
40-
"check-ts": "lerna run check-ts",
38+
"update-ts-references": "node scripts/update-ts-references.mjs",
4139
"lint": "node ./scripts/lint-all.mjs",
4240
"prepublishOnly": "yarn pre-publish",
43-
"pre-publish": "yarn build && yarn build-dts && node ./scripts/rewrite-package-types.mjs && yarn build-ts",
41+
"pre-publish": "yarn build && node ./scripts/rewrite-package-types.mjs",
4442
"changesets-publish": "yarn pre-publish && yarn changeset publish",
4543
"test": "yarn test:unit && yarn test:integration",
4644
"test:e2e": "yarn workspace @atlaspack/e2e-tests test",
@@ -61,7 +59,8 @@
6159
"tag:release": "lerna version --exact --force-publish=* --no-git-tag-version --no-push",
6260
"release": "lerna publish -y from-package --pre-dist-tag=next --no-git-tag-version --no-push",
6361
"prepare": "husky install",
64-
"postinstall": "patch-package"
62+
"postinstall": "patch-package",
63+
"type-coverage": "type-coverage -b tsconfig.paths.json"
6564
},
6665
"devDependencies": {
6766
"@babel/core": "^7.22.11",
@@ -94,6 +93,8 @@
9493
"rimraf": "^5.0.5",
9594
"semver": "^7.5.2",
9695
"sinon": "^7.3.1",
96+
"type-coverage": "^2.3.3",
97+
"typecov": "^0.2.3",
9798
"typescript": "^5.8.3",
9899
"zx": "^8.1.9"
99100
},

packages/bundlers/bundler-experimental/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"@atlaspack/fs": "2.15.26"
3333
},
3434
"scripts": {
35-
"check-ts": "tsc --emitDeclarationOnly --rootDir src",
3635
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
3736
}
3837
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2-
"extends": "../../../tsconfig.json",
3-
"include": ["src"]
2+
"extends": "../../../tsconfig.base.json",
3+
"include": ["src"],
4+
"composite": true
45
}

packages/bundlers/default/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"sorted-array-functions": "^1.0.0"
3131
},
3232
"scripts": {
33-
"check-ts": "tsc --emitDeclarationOnly --rootDir src",
3433
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
3534
}
3635
}
Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
11
{
2-
"extends": "../../../tsconfig.json",
3-
"include": ["src"]
2+
"extends": "../../../tsconfig.base.json",
3+
"include": ["src"],
4+
"compilerOptions": {
5+
"composite": true
6+
},
7+
"references": [
8+
{
9+
"path": "../../core/diagnostic/tsconfig.json"
10+
},
11+
{
12+
"path": "../../core/feature-flags/tsconfig.json"
13+
},
14+
{
15+
"path": "../../core/graph/tsconfig.json"
16+
},
17+
{
18+
"path": "../../core/plugin/tsconfig.json"
19+
},
20+
{
21+
"path": "../../core/rust/tsconfig.json"
22+
},
23+
{
24+
"path": "../../core/types-internal/tsconfig.json"
25+
},
26+
{
27+
"path": "../../core/utils/tsconfig.json"
28+
}
29+
]
430
}

0 commit comments

Comments
 (0)