Task #101782
closedUse TypeScript tsconfig include instead of exclude
100%
Description
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.
Note that this happened with https://review.typo3.org/c/Packages/TYPO3.CMS/+/80736 where clean installs failed with:
Build/Scripts/runTests.sh -s lintTypescript 00:35 npm WARN deprecated stable@0.1.8: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility added 988 packages, and audited 989 packages in 9s 129 packages are looking for funding run `npm fund` for details found 0 vulnerabilities clean: postcss.plugin was deprecated. Migration guide: https://evilmartians.com/chronicles/postcss-8-plugin-migration Running "eslint:files" (eslint) task Warning: Debug Failure. Unhandled declaration kind! ModuleDeclaration for { name: TYPO3; flags: ExportDoesNotSupportDefaultModifier|Property|ValueModule|ExportHasLocal|NamespaceModule|Module|Namespace|AccessorExcludes|GetAccessorExcludes|SetAccessorExcludes|PropertyOrAccessor|MethodExcludes|ClassMember|ValueModuleExcludes|FunctionExcludes|FunctionScopedVariableExcludes|Value|BlockScopedVariableExcludes|ParameterExcludes|RegularEnumExcludes|ClassExcludes|ConstEnumExcludes|EnumMemberExcludes|ModuleMember|Classifiable|Transient|All|Assignment; declarations: PropertyAccessExpression,Identifier,ModuleDeclaration,ModuleDeclaration,ModuleDeclaration,ModuleDeclaration } Occurred while linting /builds/typo3/CI/cms/Build/Sources/TypeScript/backend/date-time-picker.ts:221 Rule: "@typescript-eslint/prefer-readonly" Use --force to continue.
Note that the error did not happen when the Build output Build/JavaScript
was present. Removing that folder, made the error appear, addeding it back, made it disappear.
That show that eslint plugin (@typescript-eslint/prefer-readonly), which uses the typescript node module underneath, actually took the previous build output into account for the new build – this MUST be avoided.
Updated by Gerrit Code Review about 1 year ago
- Status changed from New to Under Review
Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80739
Updated by Gerrit Code Review about 1 year ago
Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80739
Updated by Gerrit Code Review about 1 year ago
Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80746
Updated by Gerrit Code Review about 1 year ago
Patch set 2 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80746
Updated by Anonymous about 1 year ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 8016882db12d4a40b56b4dbdb02b1494b4a68687.
Updated by Benjamin Franzke about 1 year ago
- Related to Task #101846: Fix eslint execution from TYPO3 source root folder added