Skip to content

Commit

Permalink
[TASK] Use TypeScript tsconfig include instead of exclude
Browse files Browse the repository at this point in the history
This helps to prevent hard-to-discover build failures, that only
happen on clean installs (e.g. CI).
This is because TypeScript will by default scan the entire source
dictionary (Build/ in our case) for possible includes.
We previously excluded /Build/composer in #95046, but it is actually
much better to explicitly include the actually used source paths
to also exclude build output (Build/JavaScript/) from being
reinterpreted by subsequential eslint or tsc compile runs.

Note that we also refactor the types/ directory in order to
be a folder that conforms to the @types/* packages conventions,
by being actually usable in the compilerOptions.types property.

Note that our custom global type definitions (types/) were previously
implicitly loaded as globally available sourcepaths.
With the new `include` option we could add them back, but then we
wouldn't notice if we do not add proper index.d.ts files (like we
did until now). Therefore index.d.ts files are added in here.

Now, with TypeScript being "clean", we need a another small
adjustment in order for eslint to still being able to lint
our types/ folder. Therefore tsconfig.json is extended to
include the types directory. See [1] for more information on
why eslint needs that.

[1] https://typescript-eslint.io/linting/troubleshooting/#i-get-errors-telling-me-eslint-was-configured-to-run--however-that-tsconfig-does-not--none-of-those-tsconfigs-include-this-file

Resolves: #101782
Related: #95046
Releases: main, 12.4
Change-Id: I3ab8b874192d25470bbd5e71cc5d99e853259f89
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80739
Tested-by: Andreas Fernandez <[email protected]>
Reviewed-by: Christian Kuhn <[email protected]>
Reviewed-by: Andreas Fernandez <[email protected]>
Reviewed-by: Benjamin Franzke <[email protected]>
Tested-by: Benjamin Franzke <[email protected]>
Tested-by: Christian Kuhn <[email protected]>
Tested-by: core-ci <[email protected]>
  • Loading branch information
bnf committed Aug 29, 2023
1 parent a77cf0d commit 8016882
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Build/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": true
"project": ["./tsconfig.eslint.json"]
},
"plugins": [
"@typescript-eslint",
Expand Down
7 changes: 7 additions & 0 deletions Build/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"include": [
"Sources/TypeScript/**/*.ts",
"types/**/*.ts"
]
}
8 changes: 5 additions & 3 deletions Build/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,18 @@
"d3-selection",
"jasmine",
"jquery",
"jquery-custom",
"bootstrap",
"nprogress",
"sortablejs"
"sortablejs",
"tablesort"
],
"typeRoots": [
"node_modules/@types",
"types"
]
},
"exclude": [
"composer/"
"include": [
"Sources/TypeScript/**/*.ts"
]
}
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions Build/types/jquery-custom/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import './draguploader';
import './general';
import './paging';
File renamed without changes.
File renamed without changes.

0 comments on commit 8016882

Please sign in to comment.