Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Upgrade to TypeScript 4.1 #16449

Closed
wants to merge 1 commit into from
Closed

Conversation

ecraig12345
Copy link
Member

@ecraig12345 ecraig12345 commented Jan 12, 2021

Pull request checklist

Description of changes

Upgrade to TypeScript 4.1.3.

So far I didn't include an upgrade of TS in the @fluentui/web-components package--need to discuss with that team.

@DustyTheBot
Copy link

DustyTheBot commented Jan 12, 2021

Warnings
⚠️ There are no updates provided to CHANGELOG. Ensure there are no publicly visible changes introduced by this PR.

Generated by 🚫 dangerJS against c48d44f

@@ -35,7 +35,7 @@
"@types/react-dom": "16.8.4",
"@types/react": "16.8.25",
"@types/webpack-env": "1.15.1",
"awesome-typescript-loader": "^3.2.3",
"awesome-typescript-loader": "^5.2.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBD whether this upgrade is necessary/desirable and whether it necessitates other changes

package.json Outdated
"packages/web-components/typescript/**",
"packages/web-components/ts-loader",
"packages/web-components/ts-loader/**",
"packages/web-components/@microsoft/api-extractor",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we leave web-components on a different TS version, it also needs its own API Extractor version (which shouldn't be hoisted to avoid interference from API Extractor's additional separate TS version)

"packages/web-components/ts-loader/**",
"packages/web-components/@microsoft/api-extractor",
"packages/web-components/@microsoft/api-extractor/**",
"packages/web-components/@microsoft/eslint-config-fast-dna",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eslint-config-fast-dna also has a dep on typescript, so hopefully not hoisting it will help prevent issues.

ts-loader is tentatively using the same version now and doesn't need nohoist config.

package.json Show resolved Hide resolved
package.json Outdated
@@ -104,7 +104,8 @@
"resolutions": {
"eslint": "^7.1.0",
"autoprefixer": "9.7.6",
"copy-to-clipboard": "3.2.0"
"copy-to-clipboard": "3.2.0",
"**/@fluentui/scripts/**/typescript": "4.1.3"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this line is to force API Extractor to use TS 4.1.3 rather than 4.0.5. After MUCH fighting with yarn resolutions I finally figured out that you need the leading ** to prevent hoisting from something under a monorepo package.

Resolutions docs: https://classic.yarnpkg.com/en/docs/selective-version-resolutions/
Full spec: https://github.com/yarnpkg/rfcs/blob/master/implemented/0000-selective-versions-resolutions.md

@@ -9,7 +9,7 @@
},
"devDependencies": {
"ability-attributes-generator": "^0.0.8",
"typescript": "3.7.2"
"typescript": "4.1.3"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible that with the improvements I made to the root nohoist config, this won't be necessary now. (The other possibility would be adding a nohoist line for packages/web-components/**/typescript.) But might be better to do that separately. ref #14371

@@ -63,7 +63,7 @@ export const createContext = <Value>(defaultValue: Value, options: CreateContext
context.Provider = createProvider<Value>(context.Provider) as any;

// We don't support Consumer API
delete context.Consumer;
delete (context as any).Consumer;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete of required members is no longer allowed

@size-auditor
Copy link

size-auditor bot commented Jan 13, 2021

Asset size changes

Project Bundle Baseline Size New Size Difference
office-ui-fabric-react react-compose 6.002 kB 6.003 kB ExceedsBaseline     1 bytes
office-ui-fabric-react fluentui-react-SelectableOption 1.256 kB 1.257 kB ExceedsBaseline     1 bytes
office-ui-fabric-react fluentui-react-Color 9.186 kB 9.187 kB ExceedsBaseline     1 bytes
office-ui-fabric-react fluentui-react-DragDrop 8.865 kB 8.866 kB ExceedsBaseline     1 bytes
office-ui-fabric-react fluentui-react-ThemeGenerator 12.447 kB 12.448 kB ExceedsBaseline     1 bytes
office-ui-fabric-react fluentui-react-List 37.086 kB 37.065 kB BelowBaseline     -21 bytes
office-ui-fabric-react fluentui-react-Positioning 19.529 kB 19.506 kB BelowBaseline     -23 bytes
office-ui-fabric-react fluentui-react-ResizeGroup 13.714 kB 13.689 kB BelowBaseline     -25 bytes
office-ui-fabric-react fluentui-react-Selection 38.089 kB 38.048 kB BelowBaseline     -41 bytes
office-ui-fabric-react fluentui-react-Popup 11.648 kB 11.605 kB BelowBaseline     -43 bytes
office-ui-fabric-react fluentui-react-Autofill 15.715 kB 15.659 kB BelowBaseline     -56 bytes
office-ui-fabric-react fluentui-react-KeytipData 12.966 kB 12.906 kB BelowBaseline     -60 bytes
office-ui-fabric-react fluentui-react-Separator 18.428 kB 18.356 kB BelowBaseline     -72 bytes
office-ui-fabric-react fluentui-react-Divider 16.943 kB 16.871 kB BelowBaseline     -72 bytes
office-ui-fabric-react fluentui-react-MarqueeSelection 69.862 kB 69.76 kB BelowBaseline     -102 bytes
office-ui-fabric-react fluentui-react-Icons 66.271 kB 66.154 kB BelowBaseline     -117 bytes
office-ui-fabric-react fluentui-react-Sticky 33.067 kB 32.948 kB BelowBaseline     -119 bytes
office-ui-fabric-react fluentui-react-Utilities 70.025 kB 69.901 kB BelowBaseline     -124 bytes
office-ui-fabric-react fluentui-react-FocusTrapZone 15.576 kB 15.443 kB BelowBaseline     -133 bytes
office-ui-fabric-react fluentui-react-Text 36.63 kB 36.495 kB BelowBaseline     -135 bytes
office-ui-fabric-react fluentui-react-FocusZone 53.733 kB 53.596 kB BelowBaseline     -137 bytes
office-ui-fabric-react fluentui-react-Stack 40.253 kB 40.115 kB BelowBaseline     -138 bytes
office-ui-fabric-react fluentui-react-ExtendedPicker 91.035 kB 90.88 kB BelowBaseline     -155 bytes
office-ui-fabric-react fluentui-react-Styling 45.661 kB 45.505 kB BelowBaseline     -156 bytes
office-ui-fabric-react fluentui-react-OverflowSet 29.717 kB 29.55 kB BelowBaseline     -167 bytes
office-ui-fabric-react fluentui-react-ProgressIndicator 38.401 kB 38.232 kB BelowBaseline     -169 bytes
office-ui-fabric-react fluentui-react-Spinner 41.14 kB 40.952 kB BelowBaseline     -188 bytes
office-ui-fabric-react fluentui-react-Label 37.887 kB 37.699 kB BelowBaseline     -188 bytes
office-ui-fabric-react fluentui-react-ScrollablePane 54.731 kB 54.543 kB BelowBaseline     -188 bytes
office-ui-fabric-react fluentui-react-Link 37.48 kB 37.292 kB BelowBaseline     -188 bytes
office-ui-fabric-react fluentui-react-Announced 37.96 kB 37.772 kB BelowBaseline     -188 bytes
office-ui-fabric-react fluentui-react-Overlay 40.241 kB 40.053 kB BelowBaseline     -188 bytes
office-ui-fabric-react fluentui-react-Shimmer 48.404 kB 48.216 kB BelowBaseline     -188 bytes
office-ui-fabric-react fluentui-react-Slider 53.268 kB 53.062 kB BelowBaseline     -206 bytes
office-ui-fabric-react fluentui-react-Toggle 44.472 kB 44.265 kB BelowBaseline     -207 bytes
office-ui-fabric-react fluentui-react-Fabric 41.676 kB 41.469 kB BelowBaseline     -207 bytes
office-ui-fabric-react fluentui-react-GroupedList 120.724 kB 120.469 kB BelowBaseline     -255 bytes
office-ui-fabric-react fluentui-react-Image 45.206 kB 44.949 kB BelowBaseline     -257 bytes
office-ui-fabric-react fluentui-react-Icon 50.19 kB 49.933 kB BelowBaseline     -257 bytes
office-ui-fabric-react fluentui-react-PersonaPresence 56.424 kB 56.167 kB BelowBaseline     -257 bytes
office-ui-fabric-react fluentui-react-Check 51.511 kB 51.254 kB BelowBaseline     -257 bytes
office-ui-fabric-react fluentui-react-Layer 45.332 kB 45.064 kB BelowBaseline     -268 bytes
office-ui-fabric-react fluentui-react-ChoiceGroupOption 57.025 kB 56.75 kB BelowBaseline     -275 bytes
office-ui-fabric-react fluentui-react-Rating 75.865 kB 75.589 kB BelowBaseline     -276 bytes
office-ui-fabric-react fluentui-react-Checkbox 57.234 kB 56.958 kB BelowBaseline     -276 bytes
office-ui-fabric-react fluentui-react-ActivityItem 69.03 kB 68.75 kB BelowBaseline     -280 bytes
office-ui-fabric-react fluentui-react-ColorPicker 88.248 kB 87.964 kB BelowBaseline     -284 bytes
office-ui-fabric-react fluentui-react-Theme 48.779 kB 48.455 kB BelowBaseline     -324 bytes
office-ui-fabric-react fluentui-react-ChoiceGroup 61.104 kB 60.773 kB BelowBaseline     -331 bytes
office-ui-fabric-react fluentui-react-DetailsList 211.179 kB 210.82 kB BelowBaseline     -359 bytes
office-ui-fabric-react fluentui-react-ShimmeredDetailsList 221.49 kB 221.13 kB BelowBaseline     -360 bytes
office-ui-fabric-react fluentui-react-PositioningContainer 69.062 kB 68.693 kB BelowBaseline     -369 bytes
office-ui-fabric-react fluentui-react-WeeklyDayPicker 96.942 kB 96.533 kB BelowBaseline     -409 bytes
office-ui-fabric-react fluentui-react-TextField 77.365 kB 76.918 kB BelowBaseline     -447 bytes
office-ui-fabric-react fluentui-react-Keytip 75.174 kB 74.718 kB BelowBaseline     -456 bytes
office-ui-fabric-react fluentui-react-Tooltip 80.124 kB 79.667 kB BelowBaseline     -457 bytes
office-ui-fabric-react fluentui-react-KeytipLayer 95.598 kB 95.141 kB BelowBaseline     -457 bytes
office-ui-fabric-react fluentui-react-Keytips 98.596 kB 98.102 kB BelowBaseline     -494 bytes
office-ui-fabric-react fluentui-react-Modal 90.278 kB 89.747 kB BelowBaseline     -531 bytes
office-ui-fabric-react fluentui-react-Callout 79.236 kB 78.688 kB BelowBaseline     -548 bytes
office-ui-fabric-react fluentui-react-PersonaCoin 106.79 kB 106.241 kB BelowBaseline     -549 bytes
office-ui-fabric-react fluentui-react-Persona 106.79 kB 106.241 kB BelowBaseline     -549 bytes
office-ui-fabric-react fluentui-react-HoverCard 91.867 kB 91.318 kB BelowBaseline     -549 bytes
office-ui-fabric-react fluentui-react-Coachmark 87.889 kB 87.339 kB BelowBaseline     -550 bytes
office-ui-fabric-react fluentui-react-Calendar 115.515 kB 114.96 kB BelowBaseline     -555 bytes
office-ui-fabric-react fluentui-react-ContextualMenu 146.595 kB 145.995 kB BelowBaseline     -600 bytes
office-ui-fabric-react fluentui-react-Pivot 177.963 kB 177.362 kB BelowBaseline     -601 bytes
office-ui-fabric-react fluentui-react-Button 183.507 kB 182.906 kB BelowBaseline     -601 bytes
office-ui-fabric-react fluentui-react-MessageBar 177.453 kB 176.852 kB BelowBaseline     -601 bytes
office-ui-fabric-react fluentui-react-Grid 170.089 kB 169.488 kB BelowBaseline     -601 bytes
office-ui-fabric-react fluentui-react-Nav 178.06 kB 177.459 kB BelowBaseline     -601 bytes
office-ui-fabric-react fluentui-react-Breadcrumb 188.207 kB 187.6 kB BelowBaseline     -607 bytes
office-ui-fabric-react fluentui-react-SelectedItemsList 217.895 kB 217.284 kB BelowBaseline     -611 bytes
office-ui-fabric-react fluentui-react-SpinButton 180.607 kB 179.994 kB BelowBaseline     -613 bytes
office-ui-fabric-react fluentui-react-FloatingPicker 228.639 kB 228.016 kB BelowBaseline     -623 bytes
office-ui-fabric-react fluentui-react-Facepile 198.567 kB 197.943 kB BelowBaseline     -624 bytes
office-ui-fabric-react fluentui-react-DocumentCard 203.816 kB 203.192 kB BelowBaseline     -624 bytes
office-ui-fabric-react fluentui-react-ComboBox 234.028 kB 233.373 kB BelowBaseline     -655 bytes
office-ui-fabric-react fluentui-react-Pickers 271.676 kB 271.014 kB BelowBaseline     -662 bytes
office-ui-fabric-react fluentui-react-SwatchColorPicker 179.602 kB 178.926 kB BelowBaseline     -676 bytes
office-ui-fabric-react fluentui-react-CommandBar 189.778 kB 189.095 kB BelowBaseline     -683 bytes
office-ui-fabric-react fluentui-react-TeachingBubble 193.486 kB 192.793 kB BelowBaseline     -693 bytes
office-ui-fabric-react fluentui-react-Dropdown 220.002 kB 219.309 kB BelowBaseline     -693 bytes
office-ui-fabric-react fluentui-react-Panel 189.279 kB 188.586 kB BelowBaseline     -693 bytes
office-ui-fabric-react fluentui-react-SearchBox 176.515 kB 175.801 kB BelowBaseline     -714 bytes
office-ui-fabric-react fluentui-react-Dialog 198.563 kB 197.798 kB BelowBaseline     -765 bytes
office-ui-fabric-react fluentui-react-DatePicker 170.91 kB 169.883 kB BelowBaseline     -1.027 kB

ExceedsTolerance Over Tolerance (1024 B) ExceedsBaseline Over Baseline BelowBaseline Below Baseline New New Deleted  Removed 1 kB = 1000 B

Baseline commit: eca0330d791682031d691cdd8fe6fb0a65c159ab (build)

@@ -71,7 +71,7 @@ export class RefFindNode extends React.Component<RefProps> {
componentWillUnmount() {
handleRef(this.props.innerRef, null);

delete this.prevNode;
this.prevNode = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miroslavstastny this part was a fix of memory leak. Is this change safe?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @ecraig12345 - memory-leak wise, the two should be equal.

@@ -20,7 +20,7 @@ export class RefForward extends React.Component<RefProps> {
}

componentWillUnmount() {
delete this.currentNode;
this.currentNode = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miroslavstastny this part was a fix of memory leak. Is this change safe?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless there's some nuance that I'm not aware of, I thought that removing the reference by either deleting or setting to another value should work to address memory leaks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @ecraig12345 - memory-leak wise, the two should be equal.

@microsoft microsoft deleted a comment from ecraig12345 Jan 14, 2021
@microsoft microsoft deleted a comment from ling1726 Jan 14, 2021
@microsoft microsoft deleted a comment from ling1726 Jan 14, 2021
@@ -24,7 +24,7 @@ describe('useTriggerElement', () => {
});

it('"trigger" can be null', () => {
const wrapper = mount(<TestComponent trigger={null} />);
const wrapper = mount(<TestComponent trigger={null as any} />);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const wrapper = mount(<TestComponent trigger={null as any} />);
const wrapper = mount(<TestComponent />);

@@ -24,7 +24,7 @@ describe('useTriggerElement', () => {
});

it('"trigger" can be null', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('"trigger" can be null', () => {
it('"trigger" can be undefined', () => {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 will update this shortly--I'd considered this change before but I wasn't sure if null was special and specifically needed to be supported for some reason.

Copy link
Member Author

@ecraig12345 ecraig12345 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explanatory comments for some things now that @joschect is taking over the upgrade

Comment on lines 130 to +132
"packages/web-components/typescript",
"packages/web-components/typescript/**",
"packages/web-components/**/typescript",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This very thoroughly prevents web-components' different versions of typescript from being hoisted.

  • First line: don't hoist direct dep
  • Second line: don't hoist deps of typescript (actually not needed since typescript has no deps)
  • Third line: don't hoist nested deps on typescript
    • This is important because at least two web-components deps have deps on typescript: @microsoft/api-extractor (TS 3.7.2) and @microsoft/eslint-config-fast-dna (TS 3.9.7)

@@ -154,19 +156,12 @@
"scripts/package.json"
],
"versionGroups": [
{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly related but this is no longer needed; as of some previous PR test-bundles now has the same webpack version as everything else

@@ -31,8 +31,8 @@
"@fluentui/style-utilities": "^8.0.2",
"@fluentui/theme": "^2.0.2",
"@fluentui/utilities": "^8.0.2",
"@microsoft/api-extractor-model": "7.7.1",
"@microsoft/tsdoc": "0.12.14",
"@microsoft/api-extractor-model": "7.12.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Must be upgraded due to dep on typescript

@@ -34,7 +34,7 @@ export type ComponentWithAs<TElementType extends keyof JSX.IntrinsicElements = '

/**
* A hack to simplify the resolution for ComponentWithAs.
* @see https://github.com/microsoft/fluentui/pull/13841
* See https://github.com/microsoft/fluentui/pull/13841
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might have been needed due to the new API Extractor version complaining about unrecognized tags


export const CalendarDay = styled(CalendarDayBase, styles, undefined, { scope: 'CalendarDay' });
export const CalendarDay: React.FunctionComponent<ICalendarDayProps> = styled(CalendarDayBase, styles, undefined, {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required to prevent inferred imports in the .d.ts, which API Extractor now complains about.

I think I'm going to separate out this and the other date-time stuff into another PR, because it also included some general types cleanup to more accurately reflect actual usage.

@@ -27,7 +27,7 @@
"@babel/standalone": "^7.10.4",
"@fluentui/eslint-plugin": "^1.0.1",
"@mdx-js/loader": "^1.5.5",
"@microsoft/api-extractor": "7.7.1",
"@microsoft/api-extractor": "7.13.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is tied to a specific TS version

Comment on lines +231 to 234
if (requestedIndexIsInPage && this._scrollElement) {
// We have found the page. If the user provided a way to measure an individual item, we will try to scroll in
// just the given item, otherwise we'll only bring the page into view
if (measureItem && this._scrollElement) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By testing this._scrollElement in the parent if we can avoid duplication to avoid confusion on this one, right?

@jdhuntington
Copy link
Contributor

Thanks all! @joschect is working on this in a separate branch; closing after talking to @ecraig12345 offline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeScript 4 upgrade
7 participants