Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Commit

Permalink
Force fork-ts-checker to watch all TS files in the repo
Browse files Browse the repository at this point in the history
There is an issue with fork-ts-checker (or perhaps we are misusing it) such that it does not re-typecheck the correct files when a change is made in the app, most notably for files that only export types. (TypeStrong/fork-ts-checker-webpack-plugin#611)

This change forces it to look at these files in our package source directories rather than the symlinks in node_modules created by yarn workspaces. Now they are correctly watched and new type errors show up when a type-only file is edited.

fix build error

fix yarn.lock

Move base tsconfig changes to desktop tsconfigs
  • Loading branch information
jtbandes committed May 15, 2021
1 parent 1427f7a commit bf1887a
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 18 deletions.
21 changes: 19 additions & 2 deletions desktop/main/tsconfig.json
@@ -1,7 +1,24 @@
{
"extends": "@foxglove/tsconfig/tsconfig.base.json",
"include": ["./**/*"],
"include": [
"./**/*",
// These includes are added to ensure that fork-ts-checker correctly typechecks changed files:
// https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/611
"../../app/*.ts",
"../../package.json",
"../../packages/log/src/**/*"
],
"compilerOptions": {
"noEmit": true
"rootDir": "../..",
"noEmit": true,

// These paths are added to ensure that fork-ts-checker correctly typechecks changed files.
// Using these resolutions will force TS to give us an error if we forgot to add these files to
// one of our tsconfig "include"s.
// https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/611
"paths": {
"@foxglove-studio/app/*": ["../../app/*"],
"@foxglove/*": ["../../packages/*", "../../packages/foxglove/*"]
}
}
}
26 changes: 23 additions & 3 deletions desktop/preload/tsconfig.json
@@ -1,9 +1,29 @@
{
"extends": "@foxglove/tsconfig/tsconfig.base.json",
"include": ["./**/*", "../common/types.ts"],
"include": [
"./**/*",
"../common/types.ts",

// These includes are added to ensure that fork-ts-checker correctly typechecks changed files:
// https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/611
"../../app/*.ts",
"../../package.json",
"../../packages/electron-socket/*",
"../../packages/electron-socket/src/**/*",
"../../packages/log/src/**/*"
],
"compilerOptions": {
"rootDir": "../",
"rootDir": "../..",
"noEmit": true,
"lib": ["dom", "es2020"]
"lib": ["dom", "es2020"],

// These paths are added to ensure that fork-ts-checker correctly typechecks changed files.
// Using these resolutions will force TS to give us an error if we forgot to add these files to
// one of our tsconfig "include"s.
// https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/611
"paths": {
"@foxglove-studio/app/*": ["../../app/*"],
"@foxglove/*": ["../../packages/*", "../../packages/foxglove/*"]
}
}
}
29 changes: 26 additions & 3 deletions desktop/renderer/tsconfig.json
@@ -1,10 +1,33 @@
{
"extends": "@foxglove/tsconfig/tsconfig.base.json",
"include": ["./**/*", "../common/**/*"],
"include": [
"./**/*",
"../common/**/*",

// These includes are added to ensure that fork-ts-checker correctly typechecks changed files:
// https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/611
"../../app/**/*",
"../../app/**/*.json",
"../../app/.storybook/**/*",
"../../package.json",
"../../packages/@foxglove/*/src/**/*",
"../../packages/*/src/**/*",
"../../packages/electron-socket/*",
"../../packages/velodyne-cloud/src/**/*.json"
],
"compilerOptions": {
"rootDir": "../",
"rootDir": "../..",
"noEmit": true,
"jsx": "react-jsx",
"lib": ["dom", "dom.iterable", "es2020"]
"lib": ["dom", "dom.iterable", "es2020"],

// These paths are added to ensure that fork-ts-checker correctly typechecks changed files.
// Using these resolutions will force TS to give us an error if we forgot to add these files to
// one of our tsconfig "include"s.
// https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/611
"paths": {
"@foxglove-studio/app/*": ["../../app/*"],
"@foxglove/*": ["../../packages/*", "../../packages/foxglove/*"]
}
}
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -51,7 +51,7 @@
"@babel/preset-typescript": "7.13.0",
"@foxglove/electron-socket": "workspace:packages/electron-socket",
"@foxglove/tsconfig": "workspace:packages/@foxglove/tsconfig",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.0-beta.8",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.0-beta.1",
"@sentry/electron": "2.4.0",
"@sentry/webpack-plugin": "1.15.1",
"@types/amplitude-js": "8.0.0",
Expand Down
27 changes: 18 additions & 9 deletions yarn.lock
Expand Up @@ -2984,24 +2984,24 @@ __metadata:
languageName: node
linkType: hard

"@pmmmwh/react-refresh-webpack-plugin@npm:0.5.0-beta.8":
version: 0.5.0-beta.8
resolution: "@pmmmwh/react-refresh-webpack-plugin@npm:0.5.0-beta.8"
"@pmmmwh/react-refresh-webpack-plugin@npm:0.5.0-beta.1":
version: 0.5.0-beta.1
resolution: "@pmmmwh/react-refresh-webpack-plugin@npm:0.5.0-beta.1"
dependencies:
ansi-html: ^0.0.7
core-js-pure: ^3.8.1
error-stack-parser: ^2.0.6
html-entities: ^2.1.0
loader-utils: ^2.0.0
native-url: ^0.3.4
schema-utils: ^3.0.0
source-map: ^0.7.3
peerDependencies:
"@types/webpack": 4.x
react-refresh: ^0.10.0
react-refresh: ">=0.8.3 <0.10.0"
sockjs-client: ^1.4.0
type-fest: ^1.0.2
type-fest: ">=0.13.1 <1.0.0"
webpack: ">=4.43.0 <6.0.0"
webpack-dev-server: 3.x || >=4.0.0-beta.0
webpack-dev-server: 3.x || 4.x
webpack-hot-middleware: 2.x
webpack-plugin-serve: 0.x || 1.x
peerDependenciesMeta:
Expand All @@ -3017,7 +3017,7 @@ __metadata:
optional: true
webpack-plugin-serve:
optional: true
checksum: 282ea202f070330732c94413c3759a6205d82df18fa4f90eff327359c9d86d077149839c19f992de511f7b165ffd718032d3eb8ef0b93afbb3f1422f872f6260
checksum: 5773e41360e99c965979e81888ec5cb22e46efa5ed77879de58bd4ca0d5e59a70f34556053c053f2bca5753edaed0263670e6ba04b18e6aaaa036c60df320935
languageName: node
linkType: hard

Expand Down Expand Up @@ -12769,7 +12769,7 @@ __metadata:
"@babel/preset-typescript": 7.13.0
"@foxglove/electron-socket": "workspace:packages/electron-socket"
"@foxglove/tsconfig": "workspace:packages/@foxglove/tsconfig"
"@pmmmwh/react-refresh-webpack-plugin": 0.5.0-beta.8
"@pmmmwh/react-refresh-webpack-plugin": 0.5.0-beta.1
"@sentry/electron": 2.4.0
"@sentry/webpack-plugin": 1.15.1
"@types/amplitude-js": 8.0.0
Expand Down Expand Up @@ -18201,6 +18201,15 @@ __metadata:
languageName: node
linkType: hard

"native-url@npm:^0.3.4":
version: 0.3.4
resolution: "native-url@npm:0.3.4"
dependencies:
querystring: ^0.2.0
checksum: 26a3716a257db5d88d2678691175144d4732cb1b12d35925f939f837b7bb9d98ce18f1d7750409fb8988f190ad075b4b72310b0e212d61fd3d832e6d073ab89b
languageName: node
linkType: hard

"natsort@npm:2.0.2":
version: 2.0.2
resolution: "natsort@npm:2.0.2"
Expand Down

0 comments on commit bf1887a

Please sign in to comment.