Skip to content

Commit 613f784

Browse files
authored
chore: enable proper type checking within all just.config.ts and its dependents (#25852)
* chore: enable strict checking in all just-config files and their dependencies * ci: enable type checking of just.configs * generate change files
1 parent 51764c3 commit 613f784

42 files changed

Lines changed: 152 additions & 90 deletions

File tree

Some content is hidden

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

apps/perf-test-react-components/src/scenarioIterations.js renamed to apps/perf-test-react-components/src/scenarioIterations.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// You don't have to add scenarios to this structure unless you want their iterations to differ from the default.
2-
const scenarioIterations = {
2+
export const scenarioIterations = {
33
MakeStyles: 50000,
44
FluentProviderWithTheme: 10,
55
};
6-
7-
module.exports = scenarioIterations;
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
// You don't have to add scenarios to this structure unless you want their display name to differ
22
// from their scenario name.
3-
const scenarioNames = {};
4-
5-
module.exports = scenarioNames;
3+
export const scenarioNames = {};

apps/perf-test-react-components/src/scenarioRenderTypes.js renamed to apps/perf-test-react-components/src/scenarioRenderTypes.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,8 @@
99
*/
1010

1111
const AllRenderTypes = ['mount', 'virtual-rerender', 'virtual-rerender-with-unmount'];
12-
const DefaultRenderTypes = ['mount'];
12+
export const DefaultRenderTypes = ['mount'];
1313

14-
const scenarioRenderTypes = {
14+
export const scenarioRenderTypes = {
1515
FluentProviderWithTheme: AllRenderTypes,
1616
};
17-
18-
module.exports = {
19-
scenarioRenderTypes,
20-
DefaultRenderTypes,
21-
};

apps/perf-test-react-components/tasks/perf-test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import fs from 'fs';
22
import path from 'path';
33
import flamegrill, { CookResults, Scenarios, ScenarioConfig, CookResult } from 'flamegrill';
4-
import scenarioIterations from '../src/scenarioIterations';
4+
import { scenarioIterations } from '../src/scenarioIterations';
55
import { scenarioRenderTypes, DefaultRenderTypes } from '../src/scenarioRenderTypes';
66
import { argv } from '@fluentui/scripts';
77

8+
type ScenarioSetting = Record<string, { scenarioName: string; iterations: number; renderType: string }>;
9+
810
// TODO: consolidate with newer version of fluent perf-test
911

1012
// A high number of iterations are needed to get visualization of lower level calls that are infrequently hit by ticks.
@@ -145,13 +147,15 @@ export async function getPerfRegressions() {
145147
const scenarioList = scenariosArg.length > 0 ? scenariosArg : scenariosAvailable;
146148

147149
const scenarios: Scenarios = {};
148-
const scenarioSettings = {};
150+
const scenarioSettings: ScenarioSetting = {};
149151
scenarioList.forEach(scenarioName => {
150152
if (!scenariosAvailable.includes(scenarioName)) {
151153
throw new Error(`Invalid scenario: ${scenarioName}.`);
152154
}
153-
const iterations = iterationsArg || scenarioIterations[scenarioName] || iterationsDefault;
154-
const renderTypes = scenarioRenderTypes[scenarioName] || DefaultRenderTypes;
155+
const iterations =
156+
iterationsArg || scenarioIterations[scenarioName as keyof typeof scenarioIterations] || iterationsDefault;
157+
const renderTypes: string[] =
158+
scenarioRenderTypes[scenarioName as keyof typeof scenarioRenderTypes] || DefaultRenderTypes;
155159

156160
renderTypes.forEach(renderType => {
157161
const scenarioKey = `${scenarioName}-${renderType}`;
@@ -221,7 +225,7 @@ export async function getPerfRegressions() {
221225
/**
222226
* Create test summary based on test results.
223227
*/
224-
function createReport(scenarioSettings, testResults: CookResults) {
228+
function createReport(scenarioSettings: ScenarioSetting, testResults: CookResults) {
225229
const report = '## [Perf Analysis (`@fluentui/react-components`)](https://github.com/microsoft/fluentui/wiki/Perf-Testing)\n'
226230

227231
// Show only significant changes by default.
@@ -239,13 +243,9 @@ function createReport(scenarioSettings, testResults: CookResults) {
239243
* Create a table of scenario results.
240244
* @param showAll Show only significant results by default.
241245
*/
242-
function createScenarioTable(scenarioSettings, testResults: CookResults, showAll: boolean) {
246+
function createScenarioTable(scenarioSettings: ScenarioSetting, testResults: CookResults, showAll: boolean) {
243247
const resultsToDisplay = Object.keys(testResults).filter(
244-
key =>
245-
showAll ||
246-
(testResults[key].analysis &&
247-
testResults[key].analysis.regression &&
248-
testResults[key].analysis.regression.isRegression),
248+
key => showAll || testResults[key].analysis?.regression?.isRegression,
249249
);
250250

251251
if (resultsToDisplay.length === 0) {

apps/perf-test-react-components/tsconfig.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,10 @@
66
"module": "commonjs",
77
"jsx": "react",
88
"declaration": true,
9-
"sourceMap": true,
109
"experimentalDecorators": true,
11-
"forceConsistentCasingInFileNames": true,
12-
"moduleResolution": "node",
1310
"preserveConstEnums": true,
14-
"strictNullChecks": true,
15-
"noImplicitAny": true,
16-
"lib": ["es2016", "dom"],
17-
"types": ["webpack-env"],
18-
"skipLibCheck": true
11+
"lib": ["ES2015", "DOM"],
12+
"types": ["webpack-env"]
1913
},
2014
"include": ["src"]
2115
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// You don't have to add scenarios to this structure unless you want their iterations to differ from the default.
2-
const scenarioIterations = {
2+
export const scenarioIterations = {
33
DocumentCardTitle: 1000,
44
Breadcrumb: 1000,
55
CommandBar: 1000,
@@ -17,5 +17,3 @@ const scenarioIterations = {
1717
GroupedList: 2,
1818
GroupedListV2: 2,
1919
};
20-
21-
module.exports = scenarioIterations;
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// You don't have to add scenarios to this structure unless you want their display name to differ
22
// from their scenario name.
3-
const scenarioNames = {
3+
export const scenarioNames = {
44
DetailsRowFast: 'DetailsRow (fast icons)',
55
DetailsRowNoStyles: 'DetailsRow without styles',
66
DocumentCardTitle: 'DocumentCardTitle with truncation',
77
StackWithIntrinsicChildren: 'Stack with Intrinsic children',
88
StackWithTextChildren: 'Stack with Text children',
99
};
10-
11-
module.exports = scenarioNames;
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,10 @@
99
*/
1010

1111
const AllRenderTypes = ['mount', 'virtual-rerender', 'virtual-rerender-with-unmount'];
12-
const DefaultRenderTypes = ['mount'];
12+
export const DefaultRenderTypes = ['mount'];
1313

14-
const scenarioRenderTypes = {
14+
export const scenarioRenderTypes = {
1515
ThemeProvider: AllRenderTypes,
1616
GroupedList: AllRenderTypes,
1717
GroupedListV2: AllRenderTypes,
1818
};
19-
20-
module.exports = {
21-
scenarioRenderTypes,
22-
DefaultRenderTypes,
23-
};

apps/perf-test/tasks/perf-test.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import fs from 'fs';
22
import path from 'path';
33
import flamegrill, { CookResults, Scenarios, ScenarioConfig, CookResult } from 'flamegrill';
4-
import scenarioIterations from '../src/scenarioIterations';
4+
import { scenarioIterations } from '../src/scenarioIterations';
55
import { scenarioRenderTypes, DefaultRenderTypes } from '../src/scenarioRenderTypes';
66
import { argv } from '@fluentui/scripts';
77

8+
type ScenarioSetting = Record<string, { scenarioName: string; iterations: number; renderType: string }>;
89
// TODO: consolidate with newer version of fluent perf-test
910

1011
// A high number of iterations are needed to get visualization of lower level calls that are infrequently hit by ticks.
@@ -143,13 +144,15 @@ export async function getPerfRegressions() {
143144
const scenarioList = scenariosArg.length > 0 ? scenariosArg : scenariosAvailable;
144145

145146
const scenarios: Scenarios = {};
146-
const scenarioSettings = {};
147+
const scenarioSettings: ScenarioSetting = {};
147148
scenarioList.forEach(scenarioName => {
148149
if (!scenariosAvailable.includes(scenarioName)) {
149150
throw new Error(`Invalid scenario: ${scenarioName}.`);
150151
}
151-
const iterations = iterationsArg || scenarioIterations[scenarioName] || iterationsDefault;
152-
const renderTypes = scenarioRenderTypes[scenarioName] || DefaultRenderTypes;
152+
const iterations: number =
153+
iterationsArg || scenarioIterations[scenarioName as keyof typeof scenarioIterations] || iterationsDefault;
154+
const renderTypes: string[] =
155+
scenarioRenderTypes[scenarioName as keyof typeof scenarioRenderTypes] || DefaultRenderTypes;
153156

154157
renderTypes.forEach(renderType => {
155158
const scenarioKey = `${scenarioName}-${renderType}`;
@@ -217,7 +220,7 @@ export async function getPerfRegressions() {
217220
/**
218221
* Create test summary based on test results.
219222
*/
220-
function createReport(scenarioSettings, testResults: CookResults) {
223+
function createReport(scenarioSettings: ScenarioSetting, testResults: CookResults) {
221224
const report = '## [Perf Analysis (`@fluentui/react`)](https://github.com/microsoft/fluentui/wiki/Perf-Testing)\n'
222225

223226
// Show only significant changes by default.
@@ -235,13 +238,9 @@ function createReport(scenarioSettings, testResults: CookResults) {
235238
* Create a table of scenario results.
236239
* @param showAll Show only significant results by default.
237240
*/
238-
function createScenarioTable(scenarioSettings, testResults: CookResults, showAll: boolean) {
241+
function createScenarioTable(scenarioSettings: ScenarioSetting, testResults: CookResults, showAll: boolean) {
239242
const resultsToDisplay = Object.keys(testResults).filter(
240-
key =>
241-
showAll ||
242-
(testResults[key].analysis &&
243-
testResults[key].analysis.regression &&
244-
testResults[key].analysis.regression.isRegression),
243+
key => showAll || testResults[key].analysis?.regression?.isRegression,
245244
);
246245

247246
if (resultsToDisplay.length === 0) {

apps/public-docsite-resources/just.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ preset();
66
task('generate-json', () => generatePageJsonFiles(require('./config/api-docs')));
77

88
// copied from scripts/just.config.js with addition of generate-json
9-
task('build', series('clean', 'copy', 'sass', 'generate-json', 'ts')).cached();
9+
task('build', series('clean', 'copy', 'sass', 'generate-json', 'ts')).cached!();
1010
task('dev', series('copy', 'sass', 'generate-json', 'webpack-dev-server'));

0 commit comments

Comments
 (0)