Skip to content

Commit f88da6c

Browse files
authored
refactor: extract base TS client config + upgrade TS + refactor TS setup (#10065)
1 parent e736dcb commit f88da6c

File tree

56 files changed

+149
-228
lines changed

Some content is hidden

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

56 files changed

+149
-228
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = {
3232
parser: '@typescript-eslint/parser',
3333
parserOptions: {
3434
// tsconfigRootDir: __dirname,
35-
// project: ['./tsconfig.json', './website/tsconfig.json'],
35+
// project: ['./tsconfig.base.json', './website/tsconfig.base.json'],
3636
},
3737
globals: {
3838
JSX: true,

.github/workflows/tests-e2e.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
- yarn.lock
1111
- jest.config.mjs
1212
- packages/**
13-
- tsconfig.json
13+
- tsconfig.*.json
1414
pull_request:
1515
branches:
1616
- main
@@ -20,7 +20,7 @@ on:
2020
- yarn.lock
2121
- jest.config.mjs
2222
- packages/**
23-
- tsconfig.json
23+
- tsconfig.*.json
2424
- admin/verdaccio.yaml
2525
- .github/workflows/tests-e2e.yml
2626

.github/workflows/tests-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
- yarn.lock
1111
- jest.config.mjs
1212
- packages/**
13-
- tsconfig.json
13+
- tsconfig.*.json
1414

1515
concurrency:
1616
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
- yarn.lock
1111
- jest.config.mjs
1212
- packages/**
13-
- tsconfig.json
13+
- tsconfig.*.json
1414

1515
concurrency:
1616
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

__tests__/validate-tsconfig.test.ts

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,37 @@ async function getTsconfigFiles(): Promise<TsconfigFile[]> {
3131
}
3232

3333
const tsconfigSchema = Joi.object({
34-
extends: '../../tsconfig.json',
35-
compilerOptions: Joi.alternatives().conditional(
36-
Joi.object({noEmit: true}).unknown(),
37-
{
38-
then: Joi.object({
39-
noEmit: Joi.valid(true).required(),
40-
incremental: Joi.forbidden(),
41-
tsBuildInfoFile: Joi.forbidden(),
42-
outDir: Joi.forbidden(),
43-
}).unknown(),
44-
otherwise: Joi.object({
45-
noEmit: Joi.valid(false).required(),
46-
incremental: Joi.valid(true).required(),
47-
rootDir: Joi.valid('src').required(),
48-
outDir: Joi.valid('lib').required(),
49-
}).unknown(),
50-
},
34+
extends: Joi.valid(
35+
'../../tsconfig.base.json',
36+
'../../tsconfig.base.client.json',
5137
),
38+
compilerOptions: Joi.object({
39+
rootDir: Joi.valid('src').required(),
40+
outDir: Joi.valid('lib').required(),
41+
tsBuildInfoFile: Joi.valid(
42+
'lib/.tsbuildinfo',
43+
'lib/.tsbuildinfo-client',
44+
'lib/.tsbuildinfo-worker',
45+
),
46+
}).unknown(),
5247
}).unknown();
5348

5449
describe('tsconfig files', () => {
5550
it('contain all required fields', async () => {
5651
const tsconfigFiles = await getTsconfigFiles();
57-
tsconfigFiles.forEach((file) => {
58-
try {
59-
Joi.attempt(file.content, tsconfigSchema);
60-
} catch (e) {
61-
(
62-
e as Error
63-
).message += `\n${file.file} does not match the required schema.`;
64-
throw e;
65-
}
66-
});
52+
53+
tsconfigFiles
54+
// Ignore noEmit configs
55+
.filter((file) => !(file.content.compilerOptions!.noEmit === true))
56+
.forEach((file) => {
57+
try {
58+
Joi.attempt(file.content, tsconfigSchema);
59+
} catch (e) {
60+
(
61+
e as Error
62+
).message += `\n${file.file} does not match the required schema.`;
63+
throw e;
64+
}
65+
});
6766
});
6867
});

packages/create-docusaurus/tsconfig.build.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"noEmit": false,
55
"composite": true,
66
"incremental": true,
7-
"tsBuildInfoFile": "./lib/.tsbuildinfo",
7+
"tsBuildInfoFile": "lib/.tsbuildinfo",
88
"rootDir": "src",
99
"outDir": "lib"
1010
},

packages/create-docusaurus/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../tsconfig.base.json",
33
"references": [{"path": "./tsconfig.build.json"}],
44
"compilerOptions": {
55
"noEmit": true,

packages/docusaurus-cssnano-preset/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"noEmit": false,
55
"incremental": true,
6-
"tsBuildInfoFile": "./lib/.tsbuildinfo",
6+
"tsBuildInfoFile": "lib/.tsbuildinfo",
77
"rootDir": "src",
88
"outDir": "lib"
99
},

packages/docusaurus-logger/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"noEmit": false,
55
"incremental": true,
6-
"tsBuildInfoFile": "./lib/.tsbuildinfo",
6+
"tsBuildInfoFile": "lib/.tsbuildinfo",
77
"sourceMap": true,
88
"declarationMap": true,
99
"rootDir": "src",

packages/docusaurus-mdx-loader/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"noEmit": false,
55
"incremental": true,
6-
"tsBuildInfoFile": "./lib/.tsbuildinfo",
6+
"tsBuildInfoFile": "lib/.tsbuildinfo",
77
"sourceMap": true,
88
"declarationMap": true,
99
"rootDir": "src",

0 commit comments

Comments
 (0)