Skip to content

Commit

Permalink
chore: migrate to TS 4.5 (#27936)
Browse files Browse the repository at this point in the history
* chore: migrate to TS 4.5

* fix: tweak type errors exposed in ts 4.5

* fix(react-conformance): tweak type errors exposed in ts 4.5

* fix(react-utilities): tweak type errors exposed in ts 4.5

* fix(.storybook): tweak type errors exposed in ts 4.5

* fix(merge-styles): tweak type errors exposed in ts 4.5

* fix(react): tweak type errors exposed in ts 4.5

* fix(eslint-plugin): tweak type errors exposed in ts 4.5

* generate changefiles

* fix(scripts/update-release-notes): tweak type errors exposed in ts 4.5

* fix(scripts/dangerjs): tweak type errors exposed in ts 4.5

* fix(scripts-gulp): tweak type errors exposed in ts 4.5

* fix(codemods): tweak type errors exposed in ts 4.5

* fix(global-context): tweak type errors exposed in ts 4.5

* fix(react-northstar): tweak type errors exposed in ts 4.5

* fix(utilities): tweak type errors exposed in ts 4.5

* fix(react-tabster): tweak type errors exposed in ts 4.5

* fix(api-docs): tweak type errors exposed in ts 4.5

* fix(react-focus): tweak type errors exposed in ts 4.5

* feat(test-bundles): provide better log when bundle task is invoked without pacakgeName

* fix(react-table): tweak type errors exposed in ts 4.5

* fix(ts-minbar-test-react): tweak type errors exposed in ts 4.5

* fix(react-experiments): tweak type errors exposed in ts 4.5

* fix(ts-minbar-test-react-components): tweak type errors exposed in ts 4.5

* fix(scripts-test-ssr): tweak type errors exposed in ts 4.5

* fix(react-monaco-editor): tweak type errors exposed in ts 4.5

* fix(react-experiments): tweak type errors exposed in ts 4.5
  • Loading branch information
Hotell authored May 30, 2023
1 parent 77ae630 commit 4b637ce
Show file tree
Hide file tree
Showing 64 changed files with 331 additions and 271 deletions.
6 changes: 3 additions & 3 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const realSetCurrentStory = window.__setCurrentStory;
window.__setCurrentStory = function (categorization, story) {
try {
realSetCurrentStory(categorization, story);
} catch (e) {
} catch (err) {
// Ignore API removed errors from cypress-storybook's call to forceReRender
// https://github.com/storybookjs/storybook/blob/208d2f930b2b72a48355367d993e65e5b01be655/lib/core-client/src/preview/start.ts#L24
if (!(typeof e.message === 'string' && e.message.includes('was removed in storyStoreV7'))) {
throw e;
if (!(err instanceof Error && err.message.includes('was removed in storyStoreV7'))) {
throw err;
}
}
};
Expand Down
1 change: 1 addition & 0 deletions apps/test-bundles/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if (packageName === '@fluentui/react-northstar') {
entries = buildEntries('@fluentui/react');
entries['keyboard-key'] = buildEntry('@fluentui/keyboard-key');
} else {
console.error('🚨 No packageName provided!');
process.exit(1);
}

Expand Down
4 changes: 2 additions & 2 deletions apps/ts-minbar-test-react-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ async function performTest() {
await shEcho(`yarn --version`);
await shEcho(`yarn tsc --version`);
await shEcho(`yarn tsc --version`, tempPaths.testApp);
} catch (e) {
} catch (err) {
console.error('Something went wrong setting up the test:');
console.error(e?.stack || e);
console.error(err instanceof Error ? err?.stack : err);
process.exit(1);
}

Expand Down
4 changes: 2 additions & 2 deletions apps/ts-minbar-test-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ async function performTest() {
await shEcho(`yarn --version`);
await shEcho(`yarn tsc --version`);
await shEcho(`yarn tsc --version`, tempPaths.testApp);
} catch (e) {
} catch (err) {
console.error('Something went wrong setting up the test:');
console.error(e?.stack || e);
console.error(err instanceof Error ? err?.stack : err);
process.exit(1);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: bump api-extractor and tsdoc which enables us to remove --isolateModules hacks within our code",
"packageName": "@fluentui/api-docs",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: tweak type errors exposed in ts 4.5",
"packageName": "@fluentui/codemods",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: tweak type errors exposed in ts 4.5",
"packageName": "@fluentui/eslint-plugin",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "fix: tweak type errors exposed in ts 4.5",
"packageName": "@fluentui/global-context",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: tweak type errors exposed in ts 4.5",
"packageName": "@fluentui/merge-styles",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: tweak type errors exposed in ts 4.5",
"packageName": "@fluentui/react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: tweak type errors exposed in ts 4.5",
"packageName": "@fluentui/react-conformance",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "fix: tweak type errors exposed in ts 4.5",
"packageName": "@fluentui/react-experiments",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "fix: tweak type errors exposed in ts 4.5",
"packageName": "@fluentui/react-focus",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "fix: tweak type errors exposed in ts 4.5",
"packageName": "@fluentui/react-monaco-editor",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "fix: tweak type errors exposed in ts 4.5",
"packageName": "@fluentui/react-table",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "fix: tweak type errors exposed in ts 4.5",
"packageName": "@fluentui/react-tabster",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: tweak type errors exposed in ts 4.5",
"packageName": "@fluentui/react-utilities",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "fix: tweak type errors exposed in ts 4.5",
"packageName": "@fluentui/utilities",
"email": "[email protected]",
"dependentChangeType": "none"
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@
"@griffel/webpack-loader": "2.1.8",
"@jest/reporters": "28.1.3",
"@mdx-js/loader": "1.6.22",
"@microsoft/api-extractor": "7.18.1",
"@microsoft/api-extractor": "7.22.2",
"@microsoft/api-extractor-model": "7.17.1",
"@microsoft/tsdoc": "0.14.1",
"@microsoft/eslint-plugin-sdl": "0.1.9",
"@microsoft/load-themed-styles": "1.10.26",
"@microsoft/loader-load-themed-styles": "2.0.17",
Expand Down Expand Up @@ -343,7 +345,7 @@
"tsconfig-paths": "4.1.0",
"tsconfig-paths-webpack-plugin": "4.0.0",
"tslib": "2.4.1",
"typescript": "4.3.5",
"typescript": "4.5.5",
"vinyl": "2.2.0",
"vrscreenshotdiff": "0.0.17",
"webpack": "5.83.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/api-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"@fluentui/scripts-tasks": "*"
},
"dependencies": {
"@microsoft/api-extractor-model": "7.13.3",
"@microsoft/tsdoc": "0.13.2",
"@microsoft/api-extractor-model": "7.17.1",
"@microsoft/tsdoc": "0.14.1",
"fs-extra": "^8.1.0"
}
}
101 changes: 0 additions & 101 deletions packages/api-docs/src/const-enum-overrides.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/api-docs/src/pageJson.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ApiItem, ApiDocumentedItem, ApiModel } from '@microsoft/api-extractor-model';
import { ApiItemKind } from './const-enum-overrides';
import { ApiItem, ApiDocumentedItem, ApiModel, ApiItemKind } from '@microsoft/api-extractor-model';
import { findInlineTagByName } from './rendering';
import { ICollectedData } from './types-private';
import { ITableJson, IPageJson, PageGroups } from './types';
Expand Down
2 changes: 1 addition & 1 deletion packages/api-docs/src/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import {
DocNodeContainer,
DocCodeSpan,
DocBlock,
DocNodeKind,
} from '@microsoft/tsdoc';
import { ApiItem, ApiModel, ExcerptToken, IExcerptTokenRange } from '@microsoft/api-extractor-model';
import { DocNodeKind } from './const-enum-overrides';
import { ILinkToken } from './types';
import { ICollectedData } from './types-private';

Expand Down
2 changes: 1 addition & 1 deletion packages/api-docs/src/tableJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
ApiDeclaredItem,
HeritageType,
ApiItem,
ApiItemKind,
} from '@microsoft/api-extractor-model';
import { ApiItemKind } from './const-enum-overrides';
import { ITableJson, ITableRowJson } from './types';
import { renderDocNodeWithoutInlineTag, getTokenHyperlinks, renderNodes } from './rendering';
import { ICollectedData } from './types-private';
Expand Down
2 changes: 1 addition & 1 deletion packages/api-docs/src/tableRowJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
ApiProperty,
ApiConstructor,
ApiMethod,
ApiItemKind,
} from '@microsoft/api-extractor-model';
import { ApiItemKind } from './const-enum-overrides';
import { ICollectedData } from './types-private';
import { ITableRowJson, IEnumTableRowJson } from './types';
import {
Expand Down
15 changes: 10 additions & 5 deletions packages/bundle-size/src/utils/collectLocalReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@ async function readReportForPackage(reportFile) {
);
}

const packageName = path.basename(packageRoot);
const packageReportJSON = await fs.readFile(reportFilePath, 'utf8');

try {
const packageName = path.basename(packageRoot);
const packageReportJSON = await fs.readFile(reportFilePath, 'utf8');
/** @type {BuildResult[]} */
const packageReport = JSON.parse(packageReportJSON);

return { packageName, packageReport };
} catch (e) {
throw new Error([`Failed to read JSON from "${reportFilePath}":`, e.toString()].join('\n'));
} catch (err) {
if (err instanceof SyntaxError) {
throw new Error([`Invalid JSON in "${reportFilePath}"`, err.toString()].join('\n'));
}
if (err instanceof Error) {
throw new Error([`Failed to read JSON from "${reportFilePath}":`, err.toString()].join('\n'));
}
throw new Error(`Unexpected error: ${err}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/bundle-size/src/utils/collectLocalReport.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,6 @@ describe('collectLocalReport', () => {
await fs.writeFile(reportBPath, JSON.stringify(reportB));
await fs.writeFile(reportCPath, JSON.stringify(reportC));

await expect(collectLocalReport({ root: rootDir })).rejects.toThrow(/Failed to read JSON/);
await expect(collectLocalReport({ root: rootDir })).rejects.toThrow(/Invalid JSON/);
});
});
8 changes: 5 additions & 3 deletions packages/bundle-size/src/utils/getRemoteReport.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ module.exports = async function getRemoteReport(branch, attempt = 1) {
const { commitSHA } = result[result.length - 1];

return { commitSHA, remoteReport };
} catch (e) {
console.log([chalk.yellow('[w]'), e.toString()].join(' '));
console.log([chalk.yellow('[w]'), 'Failed to fetch report from the remote. Retrying...'].join(' '));
} catch (err) {
if (err instanceof Error) {
console.log([chalk.yellow('[w]'), err.toString()].join(' '));
console.log([chalk.yellow('[w]'), 'Failed to fetch report from the remote. Retrying...'].join(' '));
}

if (attempt >= MAX_HTTP_ATTEMPT_COUNT) {
console.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ function tryInsertExistingDecomposedProp(oldProp: string, statement: VariableSta
const decompObject = statement.getFirstDescendantByKind(SyntaxKind.ObjectBindingPattern);
if (decompObject) {
let objectText = decompObject.getText();
// eslint-disable-next-line deprecation/deprecation
objectText = objectText.substr(0, 1) + ` ${oldProp},` + objectText.substr(1);
decompObject.replaceWithText(objectText);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const constructorNames = [
'HTMLDataElement',
'HTMLDataListElement',
'HTMLDetailsElement',
// @ts-expect-error - NOTE: dialog is not supported in safari 14, also it was removed from lib-dom starting typescript 4.4
'HTMLDialogElement',
'HTMLDivElement',
'HTMLDListElement',
Expand Down
Loading

0 comments on commit 4b637ce

Please sign in to comment.