diff --git a/apps/fabric-website-resources/tsconfig.json b/apps/fabric-website-resources/tsconfig.json index edce539905e87e..ebdaf0be6185a6 100644 --- a/apps/fabric-website-resources/tsconfig.json +++ b/apps/fabric-website-resources/tsconfig.json @@ -15,16 +15,8 @@ "noImplicitAny": true, "moduleResolution": "node", "preserveConstEnums": true, - "lib": [ - "es2017", - "dom" - ], - "types": [ - "jest", - "webpack-env" - ] + "lib": ["es5", "dom"], + "types": ["jest", "webpack-env"] }, - "include": [ - "src" - ] -} \ No newline at end of file + "include": ["src"] +} diff --git a/apps/todo-app/tsconfig.json b/apps/todo-app/tsconfig.json index e28584c9037f26..1156d63642d069 100644 --- a/apps/todo-app/tsconfig.json +++ b/apps/todo-app/tsconfig.json @@ -11,7 +11,8 @@ "moduleResolution": "node", "preserveConstEnums": true, "strict": true, - "lib": ["es6", "dom"], + "skipLibCheck": true, + "lib": ["es5", "dom"], "types": ["webpack-env"] }, "include": ["src"] diff --git a/common/changes/@uifabric/azure-themes/lib_2019-03-21-17-58.json b/common/changes/@uifabric/azure-themes/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..02406035b4386e --- /dev/null +++ b/common/changes/@uifabric/azure-themes/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/azure-themes", + "type": "none" + } + ], + "packageName": "@uifabric/azure-themes", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/charting/lib_2019-03-21-17-58.json b/common/changes/@uifabric/charting/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..9aaa6ba4add315 --- /dev/null +++ b/common/changes/@uifabric/charting/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@uifabric/charting", + "comment": "Remove IE 11-incompatible constructs", + "type": "patch" + } + ], + "packageName": "@uifabric/charting", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/dashboard/lib_2019-03-21-17-58.json b/common/changes/@uifabric/dashboard/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..39a21e63638612 --- /dev/null +++ b/common/changes/@uifabric/dashboard/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "@uifabric/dashboard", + "comment": "Remove IE 11-incompatible constructs", + "type": "minor" + } + ], + "packageName": "@uifabric/dashboard", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/date-time/lib_2019-03-21-17-58.json b/common/changes/@uifabric/date-time/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..51abef2d4246d6 --- /dev/null +++ b/common/changes/@uifabric/date-time/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/date-time", + "type": "none" + } + ], + "packageName": "@uifabric/date-time", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/example-app-base/lib_2019-03-21-17-58.json b/common/changes/@uifabric/example-app-base/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..fff83c7d7d6328 --- /dev/null +++ b/common/changes/@uifabric/example-app-base/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/example-app-base", + "type": "none" + } + ], + "packageName": "@uifabric/example-app-base", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/experiments/lib_2019-03-21-17-58.json b/common/changes/@uifabric/experiments/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..71d09dc2eea85e --- /dev/null +++ b/common/changes/@uifabric/experiments/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/experiments", + "type": "none" + } + ], + "packageName": "@uifabric/experiments", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/fabric-website-resources/lib_2019-03-21-17-58.json b/common/changes/@uifabric/fabric-website-resources/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..c02296ff0e2b51 --- /dev/null +++ b/common/changes/@uifabric/fabric-website-resources/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/fabric-website-resources", + "type": "none" + } + ], + "packageName": "@uifabric/fabric-website-resources", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/file-type-icons/lib_2019-03-21-17-58.json b/common/changes/@uifabric/file-type-icons/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..c8cd39b961c411 --- /dev/null +++ b/common/changes/@uifabric/file-type-icons/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/file-type-icons", + "type": "none" + } + ], + "packageName": "@uifabric/file-type-icons", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/fluent-theme/lib_2019-03-21-17-58.json b/common/changes/@uifabric/fluent-theme/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..7c6637bc061b6d --- /dev/null +++ b/common/changes/@uifabric/fluent-theme/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/fluent-theme", + "type": "none" + } + ], + "packageName": "@uifabric/fluent-theme", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/foundation/lib_2019-03-21-17-58.json b/common/changes/@uifabric/foundation/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..2625aecd9b6fd1 --- /dev/null +++ b/common/changes/@uifabric/foundation/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/foundation", + "type": "none" + } + ], + "packageName": "@uifabric/foundation", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/icons/lib_2019-03-21-17-58.json b/common/changes/@uifabric/icons/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..c6824c08a7cce4 --- /dev/null +++ b/common/changes/@uifabric/icons/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/icons", + "type": "none" + } + ], + "packageName": "@uifabric/icons", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/jest-serializer-merge-styles/lib_2019-03-21-17-58.json b/common/changes/@uifabric/jest-serializer-merge-styles/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..5fa29435f83762 --- /dev/null +++ b/common/changes/@uifabric/jest-serializer-merge-styles/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/jest-serializer-merge-styles", + "type": "none" + } + ], + "packageName": "@uifabric/jest-serializer-merge-styles", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/merge-styles/lib_2019-03-21-17-58.json b/common/changes/@uifabric/merge-styles/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..f67f481676279a --- /dev/null +++ b/common/changes/@uifabric/merge-styles/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/merge-styles", + "type": "none" + } + ], + "packageName": "@uifabric/merge-styles", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/migration/lib_2019-03-21-17-58.json b/common/changes/@uifabric/migration/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..2b2609a5437a08 --- /dev/null +++ b/common/changes/@uifabric/migration/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/migration", + "type": "none" + } + ], + "packageName": "@uifabric/migration", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/react-cards/lib_2019-03-21-17-58.json b/common/changes/@uifabric/react-cards/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..f1895f19a98bde --- /dev/null +++ b/common/changes/@uifabric/react-cards/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "Remove IE 11-incompatible constructs", + "packageName": "@uifabric/react-cards", + "type": "patch" + } + ], + "packageName": "@uifabric/react-cards", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/styling/lib_2019-03-21-17-58.json b/common/changes/@uifabric/styling/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..495be6e7c088a0 --- /dev/null +++ b/common/changes/@uifabric/styling/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/styling", + "type": "none" + } + ], + "packageName": "@uifabric/styling", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/theme-samples/lib_2019-03-21-17-58.json b/common/changes/@uifabric/theme-samples/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..76b2552a14f31d --- /dev/null +++ b/common/changes/@uifabric/theme-samples/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/theme-samples", + "type": "none" + } + ], + "packageName": "@uifabric/theme-samples", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/utilities/lib_2019-03-21-17-58.json b/common/changes/@uifabric/utilities/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..8f02a726245590 --- /dev/null +++ b/common/changes/@uifabric/utilities/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/utilities", + "type": "none" + } + ], + "packageName": "@uifabric/utilities", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/variants/lib_2019-03-21-17-58.json b/common/changes/@uifabric/variants/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..4db7f1fea17954 --- /dev/null +++ b/common/changes/@uifabric/variants/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/variants", + "type": "none" + } + ], + "packageName": "@uifabric/variants", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/@uifabric/webpack-utils/lib_2019-03-21-17-58.json b/common/changes/@uifabric/webpack-utils/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..6d54724eb2c2ce --- /dev/null +++ b/common/changes/@uifabric/webpack-utils/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "comment": "", + "packageName": "@uifabric/webpack-utils", + "type": "none" + } + ], + "packageName": "@uifabric/webpack-utils", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/common/changes/office-ui-fabric-react/lib_2019-03-21-17-58.json b/common/changes/office-ui-fabric-react/lib_2019-03-21-17-58.json new file mode 100644 index 00000000000000..169972b463ea9a --- /dev/null +++ b/common/changes/office-ui-fabric-react/lib_2019-03-21-17-58.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "packageName": "office-ui-fabric-react", + "comment": "Remove IE 11-incompatible constructs", + "type": "minor" + } + ], + "packageName": "office-ui-fabric-react", + "email": "elcraig@microsoft.com" +} \ No newline at end of file diff --git a/packages/azure-themes/tsconfig.json b/packages/azure-themes/tsconfig.json index 7e66cf93221c1b..bafcae72a57ad4 100644 --- a/packages/azure-themes/tsconfig.json +++ b/packages/azure-themes/tsconfig.json @@ -15,20 +15,11 @@ "noImplicitAny": true, "moduleResolution": "node", "preserveConstEnums": true, - "lib": [ - "es2017", - "dom" - ], + "lib": ["es5", "dom"], "paths": { - "@uifabric/azure-themes/lib/*": [ - "./src/*" - ], - "@uifabric/azure-themes": [ - "./src" - ] + "@uifabric/azure-themes/lib/*": ["./src/*"], + "@uifabric/azure-themes": ["./src"] } }, - "include": [ - "src" - ] + "include": ["src"] } diff --git a/packages/charting/src/components/HorizontalBarChart/HorizontalBarChart.base.tsx b/packages/charting/src/components/HorizontalBarChart/HorizontalBarChart.base.tsx index 839d0ea6263e56..5b432cc27f134e 100644 --- a/packages/charting/src/components/HorizontalBarChart/HorizontalBarChart.base.tsx +++ b/packages/charting/src/components/HorizontalBarChart/HorizontalBarChart.base.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { classNamesFunction } from 'office-ui-fabric-react/lib/Utilities'; +import { classNamesFunction, find } from 'office-ui-fabric-react/lib/Utilities'; import { IProcessedStyleSet, IPalette } from 'office-ui-fabric-react/lib/Styling'; import { IChartProps, IHorizontalBarChartProps, IHorizontalBarChartStyles, IChartDataPoint } from './index'; import { Callout, DirectionalHint } from 'office-ui-fabric-react/lib/Callout'; @@ -129,7 +129,7 @@ export class HorizontalBarChartBase extends React.Component currentElement.legendText === legend); + const currentHoveredElement = find(refArray, (currentElement: IRefArrayData) => currentElement.legendText === legend); this.setState({ isCalloutVisible: true, hoverValue: hoverValue, diff --git a/packages/charting/src/components/Legends/Legends.base.tsx b/packages/charting/src/components/Legends/Legends.base.tsx index 9bfd45f2db6da2..6f36fe623a9fd6 100644 --- a/packages/charting/src/components/Legends/Legends.base.tsx +++ b/packages/charting/src/components/Legends/Legends.base.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { IContextualMenuItem } from 'office-ui-fabric-react/lib/ContextualMenu'; import { HoverCard, HoverCardType, IExpandingCardProps } from 'office-ui-fabric-react/lib/HoverCard'; -import { classNamesFunction } from 'office-ui-fabric-react/lib/Utilities'; +import { classNamesFunction, find } from 'office-ui-fabric-react/lib/Utilities'; import { ResizeGroup } from 'office-ui-fabric-react/lib/ResizeGroup'; import { IProcessedStyleSet } from 'office-ui-fabric-react/lib/Styling'; import { OverflowSet, IOverflowSetItemProps } from 'office-ui-fabric-react/lib/OverflowSet'; @@ -154,7 +154,7 @@ export class LegendsBase extends React.Component { // execute similar to "_onClick" and "_onLeave" logic at HoverCard onCardHide event const onHoverCardHideHandler = () => { if (this.state.selectedState) { - const selectedOverflowItem = legends.find((legend: ILegend) => legend.title === this.state.selectedLegend); + const selectedOverflowItem = find(legends, (legend: ILegend) => legend.title === this.state.selectedLegend); if (selectedOverflowItem) { this.setState({ selectedLegend: 'none', selectedState: false }, () => { if (selectedOverflowItem.action) { diff --git a/packages/charting/tsconfig.json b/packages/charting/tsconfig.json index af436b9c8cd8b2..6fccdfb61ff682 100644 --- a/packages/charting/tsconfig.json +++ b/packages/charting/tsconfig.json @@ -15,7 +15,7 @@ "noImplicitAny": true, "moduleResolution": "node", "preserveConstEnums": true, - "lib": ["es2017", "dom"], + "lib": ["es5", "dom"], "types": ["jest", "webpack-env"], "paths": { "@uifabric/charting/lib/*": ["./src/*"], diff --git a/packages/dashboard/src/components/Card/Chart/Chart.tsx b/packages/dashboard/src/components/Card/Chart/Chart.tsx index 46151a2740174b..93fb8ab0ae6cea 100644 --- a/packages/dashboard/src/components/Card/Chart/Chart.tsx +++ b/packages/dashboard/src/components/Card/Chart/Chart.tsx @@ -187,28 +187,28 @@ export class Chart extends React.Component -1 && currentLayout[lastCardIndex].i!.startsWith('n')) { + if (lastCardIndex > -1 && currentLayout[lastCardIndex].i![0] === 'n') { const newlyAddedCardId = currentLayout[lastCardIndex].i!.substring(1); const newlyAddedCard = currentLayout[lastCardIndex]; const addCardPanelCards = this.state.cardsForAddCardPanel; diff --git a/packages/dashboard/src/components/DashboardGridLayout/DashboardGridSectionLayout.tsx b/packages/dashboard/src/components/DashboardGridLayout/DashboardGridSectionLayout.tsx index e66c51fc8cdff5..60bba48b82fd9c 100644 --- a/packages/dashboard/src/components/DashboardGridLayout/DashboardGridSectionLayout.tsx +++ b/packages/dashboard/src/components/DashboardGridLayout/DashboardGridSectionLayout.tsx @@ -4,7 +4,8 @@ import { IDashboardGridLayoutStyles, IDashboardCardLayout, DashboardSectionMapping, - IDashboardGridLayoutProps + IDashboardGridLayoutProps, + DashboardGridBreakpointLayouts } from './DashboardGridLayout.types'; import { DashboardGridLayoutBase } from './DashboardGridLayoutBase'; import { ICard, CardSize } from '../Card/Card.types'; @@ -225,7 +226,8 @@ export class DashboardGridSectionLayout extends React.Component { const layouts: Layouts = {}; if (this.props.layout) { - for (const [breakpoint, value] of Object.entries(this.props.layout)) { + for (const breakpoint of Object.keys(this.props.layout)) { + const value = this.props.layout[breakpoint as keyof DashboardGridBreakpointLayouts]; if (value === undefined) { continue; } diff --git a/packages/dashboard/src/components/DetailPanel/Body/Loading.tsx b/packages/dashboard/src/components/DetailPanel/Body/Loading.tsx index 39ce57cff316dc..a20f7584c247f8 100644 --- a/packages/dashboard/src/components/DetailPanel/Body/Loading.tsx +++ b/packages/dashboard/src/components/DetailPanel/Body/Loading.tsx @@ -31,7 +31,7 @@ const loading: React.SFC = (props: IDetailPanelLoading {/* group 1 */} {title && } {/* group 2 */} - {Array.from({ length: count }).map((_: number, i: number) => { + {Array.apply(null, Array(count)).map((_: number, i: number) => { return (
diff --git a/packages/dashboard/src/components/DetailPanel/DetailPanel.Base.tsx b/packages/dashboard/src/components/DetailPanel/DetailPanel.Base.tsx index c65d26f88a8abd..05d3f19ee18b08 100644 --- a/packages/dashboard/src/components/DetailPanel/DetailPanel.Base.tsx +++ b/packages/dashboard/src/components/DetailPanel/DetailPanel.Base.tsx @@ -147,7 +147,7 @@ class DetailPanelBase extends React.PureComponent { // set message bar if (err && err.messageBannerSetting) { - const messageBannerSetting = Object.assign({}, err.messageBannerSetting); + const messageBannerSetting = { ...err.messageBannerSetting }; if (messageBannerSetting.messageType === undefined) { messageBannerSetting.messageType = MessageBarType.error; } diff --git a/packages/dashboard/src/components/DetailPanel/Footer/ActionBar.tsx b/packages/dashboard/src/components/DetailPanel/Footer/ActionBar.tsx index 319200df06ddd7..1eb24b1fcbbdcb 100644 --- a/packages/dashboard/src/components/DetailPanel/Footer/ActionBar.tsx +++ b/packages/dashboard/src/components/DetailPanel/Footer/ActionBar.tsx @@ -54,7 +54,7 @@ const actionBar: React.SFC = (props: DetailPanelActio .catch((err: IDetailPanelErrorResult) => { if (err) { // set message banner - const messageBannerSetting = Object.assign({}, err.messageBannerSetting); + const messageBannerSetting = { ...err.messageBannerSetting }; if (messageBannerSetting.messageType === undefined) { messageBannerSetting.messageType = MessageBarType.error; } diff --git a/packages/dashboard/src/components/Section/examples/EditSections.Customization.Example.tsx b/packages/dashboard/src/components/Section/examples/EditSections.Customization.Example.tsx index b78bc06f412623..41fe0277e8db5f 100644 --- a/packages/dashboard/src/components/Section/examples/EditSections.Customization.Example.tsx +++ b/packages/dashboard/src/components/Section/examples/EditSections.Customization.Example.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { Layout, Layouts } from 'react-grid-layout-fabric'; import { EditSections } from '../EditSections'; import { CardSize, DashboardGridBreakpointLayouts, ISection, IDashboardCardLayout, CardSizeToWidthHeight } from '@uifabric/dashboard'; +import { findIndex } from 'office-ui-fabric-react/lib/Utilities'; export interface IEditSectionsExampleState { saveButtonDisabled: boolean; @@ -149,7 +150,7 @@ export class EditSectionsCustomizationExample extends React.Component<{}, IEditS * Example handler for onRenameSectionClick */ private _onRenameSectionClick = (id: string): void => { - const index = this.state.sections.findIndex((section: ISection) => section.id === id); + const index = findIndex(this.state.sections, (section: ISection) => section.id === id); const newSections = JSON.parse(JSON.stringify(this.state.sections)); // deep clone newSections[index].isRenaming = true; @@ -163,7 +164,7 @@ export class EditSectionsCustomizationExample extends React.Component<{}, IEditS * Example handler for onUpdateSectionTitle */ private _onUpdateSectionTitle = (id: string, title: string) => { - const index = this.state.sections.findIndex((section: ISection) => section.id === id); + const index = findIndex(this.state.sections, (section: ISection) => section.id === id); const newSections = JSON.parse(JSON.stringify(this.state.sections)); // deep clone newSections[index].isRenaming = false; newSections[index].title = title; @@ -190,7 +191,8 @@ export class EditSectionsCustomizationExample extends React.Component<{}, IEditS private _addLayoutForNewSection(id: string): DashboardGridBreakpointLayouts { const newLayout: DashboardGridBreakpointLayouts = JSON.parse(JSON.stringify(this.state.layout)); - for (const [_, value] of Object.entries(newLayout)) { + for (const key of Object.keys(newLayout)) { + const value = newLayout[key as keyof DashboardGridBreakpointLayouts]; if (value === undefined) { continue; } @@ -234,7 +236,8 @@ export class EditSectionsCustomizationExample extends React.Component<{}, IEditS private _generateDashboardLayoutFromRGLLayout(allLayouts: Layouts): DashboardGridBreakpointLayouts { const newLayout: DashboardGridBreakpointLayouts = {}; - for (const [breakPoint, value] of Object.entries(allLayouts)) { + for (const breakPoint of Object.keys(allLayouts)) { + const value = allLayouts[breakPoint as keyof DashboardGridBreakpointLayouts]; if (value === undefined) { continue; } diff --git a/packages/dashboard/src/components/Section/examples/EditSections.Example.tsx b/packages/dashboard/src/components/Section/examples/EditSections.Example.tsx index aa72d14caa3385..307b1a362c82c7 100644 --- a/packages/dashboard/src/components/Section/examples/EditSections.Example.tsx +++ b/packages/dashboard/src/components/Section/examples/EditSections.Example.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { Layout, Layouts } from 'react-grid-layout-fabric'; import { EditSections } from '../EditSections'; import { CardSize, DashboardGridBreakpointLayouts, ISection, IDashboardCardLayout, CardSizeToWidthHeight } from '@uifabric/dashboard'; +import { findIndex } from 'office-ui-fabric-react/lib/Utilities'; export interface IEditSectionsExampleState { saveButtonDisabled: boolean; @@ -144,7 +145,7 @@ export class EditSectionsExample extends React.Component<{}, IEditSectionsExampl * Example handler for onRenameSectionClick */ private _onRenameSectionClick = (id: string): void => { - const index = this.state.sections.findIndex((section: ISection) => section.id === id); + const index = findIndex(this.state.sections, (section: ISection) => section.id === id); const newSections = JSON.parse(JSON.stringify(this.state.sections)); // deep clone newSections[index].isRenaming = true; @@ -158,7 +159,7 @@ export class EditSectionsExample extends React.Component<{}, IEditSectionsExampl * Example handler for onUpdateSectionTitle */ private _onUpdateSectionTitle = (id: string, title: string) => { - const index = this.state.sections.findIndex((section: ISection) => section.id === id); + const index = findIndex(this.state.sections, (section: ISection) => section.id === id); const newSections = JSON.parse(JSON.stringify(this.state.sections)); // deep clone newSections[index].isRenaming = false; newSections[index].title = title; @@ -185,7 +186,8 @@ export class EditSectionsExample extends React.Component<{}, IEditSectionsExampl private _addLayoutForNewSection(id: string): DashboardGridBreakpointLayouts { const newLayout: DashboardGridBreakpointLayouts = JSON.parse(JSON.stringify(this.state.layout)); - for (const [_, value] of Object.entries(newLayout)) { + for (const key of Object.keys(newLayout)) { + const value = newLayout[key as keyof DashboardGridBreakpointLayouts]; if (value === undefined) { continue; } @@ -229,7 +231,8 @@ export class EditSectionsExample extends React.Component<{}, IEditSectionsExampl private _generateDashboardLayoutFromRGLLayout(allLayouts: Layouts): DashboardGridBreakpointLayouts { const newLayout: DashboardGridBreakpointLayouts = {}; - for (const [breakPoint, value] of Object.entries(allLayouts)) { + for (const breakPoint of Object.keys(allLayouts)) { + const value = allLayouts[breakPoint as keyof DashboardGridBreakpointLayouts]; if (value === undefined) { continue; } diff --git a/packages/dashboard/tsconfig.json b/packages/dashboard/tsconfig.json index 6d25c494812462..08cdcb0b880d63 100644 --- a/packages/dashboard/tsconfig.json +++ b/packages/dashboard/tsconfig.json @@ -15,7 +15,8 @@ "noImplicitAny": true, "moduleResolution": "node", "preserveConstEnums": true, - "lib": ["es2017", "dom"], + "skipLibCheck": true, + "lib": ["es5", "es2015.promise", "dom"], "types": ["jest", "webpack-env"], "paths": { "@uifabric/dashboard/lib/*": ["./src/*"], diff --git a/packages/date-time/src/components/Calendar/CalendarDay/CalendarDay.base.tsx b/packages/date-time/src/components/Calendar/CalendarDay/CalendarDay.base.tsx index 37222de6b2f7b1..cf220077975b98 100644 --- a/packages/date-time/src/components/Calendar/CalendarDay/CalendarDay.base.tsx +++ b/packages/date-time/src/components/Calendar/CalendarDay/CalendarDay.base.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { BaseComponent, KeyCodes, css, getId, getRTL, getRTLSafeKeyCode, format, classNamesFunction } from '@uifabric/utilities'; +import { BaseComponent, KeyCodes, css, getId, getRTL, getRTLSafeKeyCode, format, classNamesFunction, find } from '@uifabric/utilities'; import { FocusZone } from 'office-ui-fabric-react/lib/FocusZone'; import { Icon } from 'office-ui-fabric-react/lib/Icon'; import { @@ -509,7 +509,7 @@ export class CalendarDayBase extends BaseComponent { + const inRestrictedDates = !!find(restrictedDates, (rd: Date) => { return compareDates(rd, date); }); return inRestrictedDates && !this._getIsBeforeMinDate(date) && !this._getIsAfterMaxDate(date); @@ -643,7 +643,7 @@ export class CalendarDayBase extends BaseComponent { - return accumulatedValue.concat(currentWeek.filter((weekDay: IDayInfo) => dateRange.includes(weekDay.originalDate.getTime()))); + return accumulatedValue.concat(currentWeek.filter((weekDay: IDayInfo) => dateRange.indexOf(weekDay.originalDate.getTime()) !== -1)); }, []); let dayRefs: (HTMLElement | null)[] = []; diff --git a/packages/date-time/src/utilities/dateMath/DateMath.ts b/packages/date-time/src/utilities/dateMath/DateMath.ts index 4838da72db6fd0..f18d7a47ccaf88 100644 --- a/packages/date-time/src/utilities/dateMath/DateMath.ts +++ b/packages/date-time/src/utilities/dateMath/DateMath.ts @@ -189,7 +189,7 @@ export function getDateRangeArray(date: Date, dateRangeType: DateRangeType, firs if (dateRangeType !== DateRangeType.WorkWeek) { // push all days not in work week view datesArray.push(nextDate); - } else if (workWeekDays.includes(nextDate.getDay())) { + } else if (workWeekDays.indexOf(nextDate.getDay()) !== -1) { datesArray.push(nextDate); } nextDate = addDays(nextDate, 1); diff --git a/packages/date-time/tsconfig.json b/packages/date-time/tsconfig.json index c73d0babc91b23..1d40d7279bab79 100644 --- a/packages/date-time/tsconfig.json +++ b/packages/date-time/tsconfig.json @@ -15,7 +15,7 @@ "noImplicitAny": true, "moduleResolution": "node", "preserveConstEnums": true, - "lib": ["es2017", "dom"], + "lib": ["es5", "dom"], "types": ["jest", "webpack-env"], "paths": { "@uifabric/date-time/lib/*": ["./src/*"], diff --git a/packages/example-app-base/tsconfig.json b/packages/example-app-base/tsconfig.json index fdd2fd99268cdc..dd457fddfe1eaa 100644 --- a/packages/example-app-base/tsconfig.json +++ b/packages/example-app-base/tsconfig.json @@ -13,8 +13,8 @@ "moduleResolution": "node", "preserveConstEnums": true, "outDir": "lib", - "lib": ["es2017", "dom"], - "types": ["webpack-env", "jest"] + "lib": ["es5", "dom"], + "types": ["webpack-env", "jest", "es6-promise"] }, "include": ["src"] } diff --git a/packages/experiments/tsconfig.json b/packages/experiments/tsconfig.json index ac9258e2dd28fb..f4ae45f211ed3b 100644 --- a/packages/experiments/tsconfig.json +++ b/packages/experiments/tsconfig.json @@ -15,8 +15,10 @@ "noImplicitAny": true, "moduleResolution": "node", "preserveConstEnums": true, - "lib": ["es2017", "dom"], - "types": ["jest", "webpack-env"], + "skipLibCheck": true, + "lib": ["es5", "dom"], + "typeRoots": ["node_modules/@types", "../../typings"], + "types": ["jest", "webpack-env", "custom-global"], "paths": { "@uifabric/experiments/lib/*": ["./src/*"], "@uifabric/experiments": ["./src"] diff --git a/packages/file-type-icons/tsconfig.json b/packages/file-type-icons/tsconfig.json index c321cce75ef464..6ff382d20f1751 100644 --- a/packages/file-type-icons/tsconfig.json +++ b/packages/file-type-icons/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "target": "es5", "module": "commonjs", - "lib": ["es2017", "dom"], + "lib": ["es5", "dom"], "jsx": "react", "declaration": true, "sourceMap": true, diff --git a/packages/fluent-theme/tsconfig.json b/packages/fluent-theme/tsconfig.json index 6f7a50357091cf..97446e585e02db 100644 --- a/packages/fluent-theme/tsconfig.json +++ b/packages/fluent-theme/tsconfig.json @@ -15,20 +15,11 @@ "noImplicitAny": true, "moduleResolution": "node", "preserveConstEnums": true, - "lib": [ - "es2017", - "dom" - ], + "lib": ["es5", "dom"], "paths": { - "@uifabric/fluent-theme/lib/*": [ - "./src/*" - ], - "@uifabric/fluent-theme": [ - "./src" - ] + "@uifabric/fluent-theme/lib/*": ["./src/*"], + "@uifabric/fluent-theme": ["./src"] } }, - "include": [ - "src" - ] -} \ No newline at end of file + "include": ["src"] +} diff --git a/packages/foundation-scenarios/tsconfig.json b/packages/foundation-scenarios/tsconfig.json index 7655318c6fc4bf..55f81f9e54954a 100644 --- a/packages/foundation-scenarios/tsconfig.json +++ b/packages/foundation-scenarios/tsconfig.json @@ -15,7 +15,7 @@ "noImplicitAny": true, "moduleResolution": "node", "preserveConstEnums": true, - "lib": ["es2017", "dom"], + "lib": ["es5", "dom"], "types": ["jest", "webpack-env"], "paths": { "@uifabric/foundation-scenarios/lib/*": ["./src/*"], diff --git a/packages/foundation/tsconfig.json b/packages/foundation/tsconfig.json index 3758c6c261a8af..a3fc0c002bf5be 100644 --- a/packages/foundation/tsconfig.json +++ b/packages/foundation/tsconfig.json @@ -15,15 +15,8 @@ "noImplicitAny": true, "moduleResolution": "node", "preserveConstEnums": true, - "lib": [ - "es2017", - "dom" - ], - "types": [ - "jest" - ] + "lib": ["es5", "dom"], + "types": ["jest"] }, - "include": [ - "src" - ] -} \ No newline at end of file + "include": ["src"] +} diff --git a/packages/icons/tsconfig.json b/packages/icons/tsconfig.json index c321cce75ef464..6ff382d20f1751 100644 --- a/packages/icons/tsconfig.json +++ b/packages/icons/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "target": "es5", "module": "commonjs", - "lib": ["es2017", "dom"], + "lib": ["es5", "dom"], "jsx": "react", "declaration": true, "sourceMap": true, diff --git a/packages/jest-serializer-merge-styles/tsconfig.json b/packages/jest-serializer-merge-styles/tsconfig.json index ce2630918d097a..1ac6eeabdbfda9 100644 --- a/packages/jest-serializer-merge-styles/tsconfig.json +++ b/packages/jest-serializer-merge-styles/tsconfig.json @@ -3,7 +3,7 @@ "target": "es5", "outDir": "lib", "module": "commonjs", - "lib": ["es2017", "dom"], + "lib": ["es2017"], "jsx": "react", "declaration": true, "sourceMap": true, diff --git a/packages/merge-styles/tsconfig.json b/packages/merge-styles/tsconfig.json index ce2630918d097a..f4544ef012d4b6 100644 --- a/packages/merge-styles/tsconfig.json +++ b/packages/merge-styles/tsconfig.json @@ -3,7 +3,7 @@ "target": "es5", "outDir": "lib", "module": "commonjs", - "lib": ["es2017", "dom"], + "lib": ["es5", "dom"], "jsx": "react", "declaration": true, "sourceMap": true, diff --git a/packages/migration/tsconfig.json b/packages/migration/tsconfig.json index 8d104d150c332b..00f5f9d4494e4a 100644 --- a/packages/migration/tsconfig.json +++ b/packages/migration/tsconfig.json @@ -17,7 +17,7 @@ "preserveConstEnums": true, "allowSyntheticDefaultImports": true, "esModuleInterop": true, - "lib": ["es2017", "dom"], + "lib": ["es2017"], "types": ["jest", "node"], "paths": { "@uifabric/migration/lib/*": ["./src/*"], diff --git a/packages/office-ui-fabric-react/src/common/shallowUntilTarget.ts b/packages/office-ui-fabric-react/src/common/shallowUntilTarget.ts index d220925fe85bb1..88445fd1ff1104 100644 --- a/packages/office-ui-fabric-react/src/common/shallowUntilTarget.ts +++ b/packages/office-ui-fabric-react/src/common/shallowUntilTarget.ts @@ -39,14 +39,9 @@ export function shallowUntilTarget( const { maxTries, shallowOptions } = options; let root = shallow(componentInstance, shallowOptions); + let rootType = root.type(); - if ( - typeof root.type() === 'string' || - root - .type() - .toString() - .includes(TargetComponent) - ) { + if (typeof rootType === 'string' || rootType.toString().indexOf(TargetComponent) !== -1) { // Default shallow() // If type() is a string then it's a DOM Node. // If it were wrapped, it would be a React component. @@ -56,17 +51,13 @@ export function shallowUntilTarget( for (let tries = 1; tries <= maxTries; tries++) { // Check for target as a string to avoid conflicts // with decoratored components name - if ( - root - .type() - .toString() - .includes(TargetComponent) - ) { + if (rootType.toString().indexOf(TargetComponent) !== -1) { // Now that we found the target component, render it. return root.first().shallow(shallowOptions); } // Unwrap the next component in the hierarchy. root = root.first().shallow(shallowOptions); + rootType = root.type(); } throw new Error( diff --git a/packages/office-ui-fabric-react/src/components/Calendar/CalendarDay.tsx b/packages/office-ui-fabric-react/src/components/Calendar/CalendarDay.tsx index 151aa8c78d879b..7d34c29565d002 100644 --- a/packages/office-ui-fabric-react/src/components/Calendar/CalendarDay.tsx +++ b/packages/office-ui-fabric-react/src/components/Calendar/CalendarDay.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { BaseComponent, KeyCodes, css, getId, getRTL, getRTLSafeKeyCode, format, IRefObject, findIndex } from '../../Utilities'; +import { BaseComponent, KeyCodes, css, getId, getRTL, getRTLSafeKeyCode, format, IRefObject, findIndex, find } from '../../Utilities'; import { ICalendarStrings, ICalendarIconStrings, ICalendarFormatDateCallbacks } from './Calendar.types'; import { DayOfWeek, FirstWeekOfYear, DateRangeType } from '../../utilities/dateValues/DateValues'; import { FocusZone } from '../../FocusZone'; @@ -815,7 +815,7 @@ export class CalendarDay extends BaseComponent { + const restrictedDate = find(restrictedDates, rd => { return compareDates(rd, date); }); return restrictedDate ? true : false; diff --git a/packages/office-ui-fabric-react/src/components/ComponentConformance.test.tsx b/packages/office-ui-fabric-react/src/components/ComponentConformance.test.tsx index 301bd3594ae439..b5a68f380905a6 100644 --- a/packages/office-ui-fabric-react/src/components/ComponentConformance.test.tsx +++ b/packages/office-ui-fabric-react/src/components/ComponentConformance.test.tsx @@ -4,7 +4,7 @@ import * as glob from 'glob'; import * as path from 'path'; import * as fs from 'fs'; -/** +/* * These tests verify that Fabric components fulfill the following conditions: * * 1) The component accepts a className prop. @@ -238,7 +238,8 @@ describe('Component File Conformance', () => { }); describe('Top Level Component File Conformance', () => { - const privateComponents = new Set(['ContextualMenuItemWrapper']); + const privateComponents = new Set(); + privateComponents.add('ContextualMenuItemWrapper'); const components: string[] = glob .sync(path.resolve(process.cwd(), 'src/components/**/index.ts*')) diff --git a/packages/office-ui-fabric-react/src/components/ComponentExamples.test.tsx b/packages/office-ui-fabric-react/src/components/ComponentExamples.test.tsx index f193a2667c068e..1ec8dbe6657702 100644 --- a/packages/office-ui-fabric-react/src/components/ComponentExamples.test.tsx +++ b/packages/office-ui-fabric-react/src/components/ComponentExamples.test.tsx @@ -11,7 +11,7 @@ import * as mergeStylesSerializer from '@uifabric/jest-serializer-merge-styles'; const ReactDOM = require('react-dom'); // Extend Jest Expect to allow us to map each component example to its own snapshot file. -const snapshotsStateMap = new Map(); +const snapshotsStateMap = new Map(); const jestSnapshot = require('jest-snapshot'); // jest-snapshot currently has no DefinitelyTyped or module defs so type the one object we care about for now here @@ -21,6 +21,9 @@ interface ISnapshotState { matched: number; updated: number; added: number; + getUncheckedCount(): number; + removeUncheckedKeys(): void; + save(): void; } let globalSnapshotState: ISnapshotState; @@ -46,10 +49,10 @@ expect.extend({ updateSnapshot: globalSnapshotState._updateSnapshot }); // and save it to the map for tracking - snapshotsStateMap.set(absoluteSnapshotFile, snapshotState); + snapshotsStateMap.set(absoluteSnapshotFile, snapshotState!); } - const newThis = Object.assign({}, this, { snapshotState }); + const newThis = { ...this, snapshotState }; const patchedToMatchSnapshot = jestSnapshot.toMatchSnapshot.bind(newThis); return patchedToMatchSnapshot(received); @@ -171,7 +174,7 @@ describe('Component Examples', () => { files .filter((componentFile: string) => { - return excludedExampleFiles.find(excludedFile => componentFile.endsWith(excludedFile)) === undefined; + return !excludedExampleFiles.some(excludedFile => componentFile.indexOf('/' + excludedFile) !== -1); }) .forEach((componentFile: string) => { const componentFileName = componentFile.substring(componentFile.lastIndexOf('/') + 1); diff --git a/packages/office-ui-fabric-react/src/components/ContextualMenu/examples/ContextualMenu.CustomMenuList.Example.tsx b/packages/office-ui-fabric-react/src/components/ContextualMenu/examples/ContextualMenu.CustomMenuList.Example.tsx index fbde603f796a83..195a732650e98f 100644 --- a/packages/office-ui-fabric-react/src/components/ContextualMenu/examples/ContextualMenu.CustomMenuList.Example.tsx +++ b/packages/office-ui-fabric-react/src/components/ContextualMenu/examples/ContextualMenu.CustomMenuList.Example.tsx @@ -65,10 +65,6 @@ export class ContextualMenuWithCustomMenuListExample extends React.Component< constructor(props: {}) { super(props); - this._renderMenuList = this._renderMenuList.bind(this); - this._onAbort = this._onAbort.bind(this); - this._onChange = this._onChange.bind(this); - this.state = { items: ITEMS }; @@ -90,12 +86,12 @@ export class ContextualMenuWithCustomMenuListExample extends React.Component< ); } - private _onAbort() { + private _onAbort = () => { this.setState({ items: ITEMS }); - } + }; - private _onChange(newValue: any) { - const filteredItems = ITEMS.filter(item => item.text && item.text.toLowerCase().includes(newValue.toLowerCase())); + private _onChange = (newValue: string) => { + const filteredItems = ITEMS.filter(item => item.text && item.text.toLowerCase().indexOf(newValue.toLowerCase()) !== -1); if (!filteredItems || !filteredItems.length) { filteredItems.push({ @@ -121,9 +117,9 @@ export class ContextualMenuWithCustomMenuListExample extends React.Component< this.setState((prevState, props) => ({ items: filteredItems })); - } + }; - private _renderMenuList(menuListProps: IContextualMenuListProps, defaultRender: IRenderFunction) { + private _renderMenuList = (menuListProps: IContextualMenuListProps, defaultRender: IRenderFunction) => { return (
@@ -140,5 +136,5 @@ export class ContextualMenuWithCustomMenuListExample extends React.Component< {defaultRender(menuListProps)}
); - } + }; } diff --git a/packages/office-ui-fabric-react/src/components/DetailsList/DetailsHeader.base.tsx b/packages/office-ui-fabric-react/src/components/DetailsList/DetailsHeader.base.tsx index 6664e5ecda9176..ce87d74b0c01d7 100644 --- a/packages/office-ui-fabric-react/src/components/DetailsList/DetailsHeader.base.tsx +++ b/packages/office-ui-fabric-react/src/components/DetailsList/DetailsHeader.base.tsx @@ -97,11 +97,11 @@ export class DetailsHeaderBase extends BaseComponent= 0; + return this._currentDropHintIndex >= 0; } private _onDragOver(item: any, event: DragEvent): void { @@ -363,15 +363,13 @@ export class DetailsHeaderBase extends BaseComponent= 0 && event) { const targetIndex = - this._draggedColumnIndex > this._currentDropHintIndex! ? this._currentDropHintIndex! : this._currentDropHintIndex! - 1; - let isValidDrop = false; + this._draggedColumnIndex > this._currentDropHintIndex ? this._currentDropHintIndex : this._currentDropHintIndex - 1; + const isValidDrop = this._isValidCurrentDropHintIndex(); event.stopPropagation(); - if (this._isValidCurrentDropHintIndex()) { - isValidDrop = true; + if (isValidDrop) { this._onDropIndexInfo.sourceIndex = this._draggedColumnIndex; this._onDropIndexInfo.targetIndex = targetIndex; - } - if (isValidDrop) { + if (columnReorderProps && columnReorderProps.onColumnDrop) { const dragDropDetails: IColumnDragDropDetails = { draggedIndex: this._draggedColumnIndex, @@ -422,7 +420,7 @@ export class DetailsHeaderBase extends BaseComponent= 0) { this._updateDropHintElement(this._dropHintDetails[this._currentDropHintIndex].dropHintElementRef, 'none'); - this._currentDropHintIndex = Number.MIN_SAFE_INTEGER; + this._currentDropHintIndex = -1; } } @@ -494,7 +492,7 @@ export class DetailsHeaderBase extends BaseComponent { // dragover b/w b&c and c&d -> dead zone b/w 370 and 810 _RaiseEvent(detailsColSourceC, _DRAGOVER, 400); expect(header._draggedColumnIndex).toBe(2); - expect(header._currentDropHintIndex).toBe(Number.MIN_SAFE_INTEGER); + expect(header._currentDropHintIndex).toBe(-1); _RaiseEvent(detailsColTargetD, _DRAGOVER, 710); expect(header._draggedColumnIndex).toBe(2); - expect(header._currentDropHintIndex).toBe(Number.MIN_SAFE_INTEGER); + expect(header._currentDropHintIndex).toBe(-1); // dead zone : idx 2 and 3 -> no hint shown dropHintElement = component.find('#columnDropHint_2').getDOMNode(); @@ -694,7 +694,7 @@ describe('DetailsHeader', () => { // drop on source column itself -> drophintindex should not be set and hence target index not updated _RaiseEvent(detailsColTarget, _DROP, 500); - expect(header._currentDropHintIndex).toBe(Number.MIN_SAFE_INTEGER); + expect(header._currentDropHintIndex).toBe(-1); expect(_sourceIndex).toBe(2); }); diff --git a/packages/office-ui-fabric-react/src/components/__snapshots__/DetailsList.Basic.Example.tsx.shot b/packages/office-ui-fabric-react/src/components/__snapshots__/DetailsList.Basic.Example.tsx.shot new file mode 100644 index 00000000000000..151b95ed167d0b --- /dev/null +++ b/packages/office-ui-fabric-react/src/components/__snapshots__/DetailsList.Basic.Example.tsx.shot @@ -0,0 +1,213 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Component Examples renders DetailsList.Basic.Example.tsx correctly 1`] = ` +
+
+ No items selected +
+
+
+ +
+ +
+
+
+
+
+
+
+`; diff --git a/packages/office-ui-fabric-react/src/components/pickers/PeoplePicker/examples/PeoplePicker.Types.Example.tsx b/packages/office-ui-fabric-react/src/components/pickers/PeoplePicker/examples/PeoplePicker.Types.Example.tsx index 28e86089f3fa51..0ba7c4d39be116 100644 --- a/packages/office-ui-fabric-react/src/components/pickers/PeoplePicker/examples/PeoplePicker.Types.Example.tsx +++ b/packages/office-ui-fabric-react/src/components/pickers/PeoplePicker/examples/PeoplePicker.Types.Example.tsx @@ -347,7 +347,7 @@ export class PeoplePickerTypesExample extends BaseComponent => { - const processedItem = Object.assign({}, item); + const processedItem = { ...item }; processedItem.text = `${item.text} (selected)`; return new Promise((resolve, reject) => setTimeout(() => resolve(processedItem), 250)); }; diff --git a/packages/office-ui-fabric-react/src/utilities/dateMath/DateMath.ts b/packages/office-ui-fabric-react/src/utilities/dateMath/DateMath.ts index b5163391a09206..61dc6da1ec8f6a 100644 --- a/packages/office-ui-fabric-react/src/utilities/dateMath/DateMath.ts +++ b/packages/office-ui-fabric-react/src/utilities/dateMath/DateMath.ts @@ -189,7 +189,7 @@ export function getDateRangeArray(date: Date, dateRangeType: DateRangeType, firs if (dateRangeType !== DateRangeType.WorkWeek) { // push all days not in work week view datesArray.push(nextDate); - } else if (workWeekDays.includes(nextDate.getDay())) { + } else if (workWeekDays.indexOf(nextDate.getDay()) !== -1) { datesArray.push(nextDate); } nextDate = addDays(nextDate, 1); diff --git a/packages/office-ui-fabric-react/tsconfig.json b/packages/office-ui-fabric-react/tsconfig.json index 6798f3a0a81eb6..247696be2ca959 100644 --- a/packages/office-ui-fabric-react/tsconfig.json +++ b/packages/office-ui-fabric-react/tsconfig.json @@ -15,8 +15,10 @@ "noImplicitAny": true, "moduleResolution": "node", "preserveConstEnums": true, - "lib": ["es2017", "dom"], - "types": ["jest", "webpack-env"], + "lib": ["es5", "dom", "es2015.promise"], + "skipLibCheck": true, + "typeRoots": ["node_modules/@types", "../../typings"], + "types": ["jest", "webpack-env", "custom-global"], "paths": { "office-ui-fabric-react/lib/*": ["./src/*"] } diff --git a/packages/react-cards/src/components/Card/CardItem/CardItem.test.tsx b/packages/react-cards/src/components/Card/CardItem/CardItem.test.tsx index b6487d6b5f5049..0bd146388dd803 100644 --- a/packages/react-cards/src/components/Card/CardItem/CardItem.test.tsx +++ b/packages/react-cards/src/components/Card/CardItem/CardItem.test.tsx @@ -9,7 +9,7 @@ import { CardItemStyles } from './CardItem.styles'; import { ICardItemProps, ICardItemTokens, ICardItemStyles } from './CardItem.types'; import { IStylesFunction } from '@uifabric/foundation'; -import { createTheme } from 'office-ui-fabric-react'; +import { createTheme, find } from 'office-ui-fabric-react'; const testTheme = createTheme({}); @@ -67,9 +67,9 @@ describe('Card Item', () => { expect(cardStyles).toBeInstanceOf(Array); expect(cardItemStylesArray).toBeInstanceOf(Array); - const cardPadding = (cardStyles as Array).find(style => style.padding).padding; + const cardPadding = find(cardStyles as Array, style => style.padding).padding; - const cardItemStyles = (cardItemStylesArray as Array).find(style => style.marginLeft || style.marginRight); + const cardItemStyles = find(cardItemStylesArray as Array, style => style.marginLeft || style.marginRight); const cardItemMarginLeft = cardItemStyles.marginLeft; const cardItemMarginRight = cardItemStyles.marginRight; diff --git a/packages/react-cards/tsconfig.json b/packages/react-cards/tsconfig.json index 7c0cf23852de44..20e6511d44ad1e 100644 --- a/packages/react-cards/tsconfig.json +++ b/packages/react-cards/tsconfig.json @@ -15,7 +15,7 @@ "noImplicitAny": true, "moduleResolution": "node", "preserveConstEnums": true, - "lib": ["es2017", "dom"], + "lib": ["es5", "dom"], "types": ["jest", "webpack-env"], "paths": { "@uifabric/react-cards/lib/*": ["./src/*"], diff --git a/packages/set-version/tsconfig.json b/packages/set-version/tsconfig.json index 89dc5b21b002f4..c6d6b9960dc493 100644 --- a/packages/set-version/tsconfig.json +++ b/packages/set-version/tsconfig.json @@ -3,7 +3,7 @@ "target": "es5", "outDir": "lib", "module": "commonjs", - "lib": ["es2017", "dom"], + "lib": ["es5", "dom"], "declaration": true, "sourceMap": true, "importHelpers": true, diff --git a/packages/styling/tsconfig.json b/packages/styling/tsconfig.json index e7c65fcc929e62..2fc39fe686a4a3 100644 --- a/packages/styling/tsconfig.json +++ b/packages/styling/tsconfig.json @@ -14,7 +14,7 @@ "strictNullChecks": true, "forceConsistentCasingInFileNames": true, "preserveConstEnums": true, - "lib": ["es2017", "dom"], + "lib": ["es5", "dom"], "types": ["jest", "webpack-env", "react"], "paths": { "@uifabric/styling": ["./src"] diff --git a/packages/theme-samples/tsconfig.json b/packages/theme-samples/tsconfig.json index f33fa0c8eb36a5..74b2e760b2d5bd 100644 --- a/packages/theme-samples/tsconfig.json +++ b/packages/theme-samples/tsconfig.json @@ -15,20 +15,11 @@ "noImplicitAny": true, "moduleResolution": "node", "preserveConstEnums": true, - "lib": [ - "es2017", - "dom" - ], + "lib": ["es5", "dom"], "paths": { - "@uifabric/theme-samples/lib/*": [ - "./src/*" - ], - "@uifabric/theme-samples": [ - "./src" - ] + "@uifabric/theme-samples/lib/*": ["./src/*"], + "@uifabric/theme-samples": ["./src"] } }, - "include": [ - "src" - ] -} \ No newline at end of file + "include": ["src"] +} diff --git a/packages/utilities/src/styled.tsx b/packages/utilities/src/styled.tsx index fd090b2db1b38c..cfbba851bbbd1f 100644 --- a/packages/utilities/src/styled.tsx +++ b/packages/utilities/src/styled.tsx @@ -53,7 +53,10 @@ export function styled< const { scope, fields = DefaultFields } = customizable; class Wrapped extends React.Component { - public static displayName = `Styled${Component.displayName || Component.name}`; + // Function.prototype.name is an ES6 feature, so the cast to any is required until we're + // able to drop IE 11 support and compile with ES6 libs + // tslint:disable-next-line:no-any + public static displayName = `Styled${Component.displayName || (Component as any).name}`; private _inCustomizerContext = false; diff --git a/packages/utilities/tsconfig.json b/packages/utilities/tsconfig.json index 304dbaa65391df..9bc817d44f0ad3 100644 --- a/packages/utilities/tsconfig.json +++ b/packages/utilities/tsconfig.json @@ -3,7 +3,7 @@ "target": "es5", "outDir": "lib", "module": "commonjs", - "lib": ["es2017", "dom"], + "lib": ["es5", "es2015.promise", "dom"], "jsx": "react", "declaration": true, "sourceMap": true, @@ -14,7 +14,9 @@ "forceConsistentCasingInFileNames": true, "moduleResolution": "node", "preserveConstEnums": true, - "types": ["jest"] + "skipLibCheck": true, + "typeRoots": ["node_modules/@types", "../../typings"], + "types": ["jest", "custom-global"] }, "include": ["src"] } diff --git a/packages/variants/tsconfig.json b/packages/variants/tsconfig.json index ce2630918d097a..f4544ef012d4b6 100644 --- a/packages/variants/tsconfig.json +++ b/packages/variants/tsconfig.json @@ -3,7 +3,7 @@ "target": "es5", "outDir": "lib", "module": "commonjs", - "lib": ["es2017", "dom"], + "lib": ["es5", "dom"], "jsx": "react", "declaration": true, "sourceMap": true, diff --git a/packages/webpack-utils/tsconfig.json b/packages/webpack-utils/tsconfig.json index 7aa46f4437b8f3..a97b4f9a23f141 100644 --- a/packages/webpack-utils/tsconfig.json +++ b/packages/webpack-utils/tsconfig.json @@ -3,10 +3,7 @@ "target": "es5", "outDir": "lib", "module": "commonjs", - "lib": [ - "es2017", - "dom" - ], + "lib": ["es2017"], "jsx": "react", "declaration": true, "sourceMap": true, @@ -16,9 +13,7 @@ "strictNullChecks": true, "forceConsistentCasingInFileNames": true, "moduleResolution": "node", - "preserveConstEnums": true, + "preserveConstEnums": true }, - "include": [ - "src" - ] -} \ No newline at end of file + "include": ["src"] +} diff --git a/scripts/lint-staged/tslint.js b/scripts/lint-staged/tslint.js index aed58ef7ef3bce..231249dfc8fe1a 100644 --- a/scripts/lint-staged/tslint.js +++ b/scripts/lint-staged/tslint.js @@ -1,3 +1,5 @@ +// @ts-check + const execSync = require('../exec-sync'); const path = require('path'); const fs = require('fs'); @@ -16,7 +18,7 @@ runTsLintOnFilesGroupedPerPackage(groupFilesByPackage(files)); * in that package as the value. * * @param {string[]} files - * @returns {[packageName: string]: string[]} + * @returns {{[packageName: string]: string[]}} */ function groupFilesByPackage(files) { const rootDirectory = path.join(path.resolve(__dirname, '..', '..'), path.sep); @@ -28,12 +30,15 @@ function groupFilesByPackage(files) { return [packageRoot, fileName]; }) - .reduce((acc, [package, file]) => { - if (!acc[package]) { - acc[package] = []; + .reduce((filesByPackage, [package, file]) => { + if (path.dirname(package) === 'typings') { + return filesByPackage; // ignore custom typings package + } + if (!filesByPackage[package]) { + filesByPackage[package] = []; } - acc[package].push(file); - return acc; + filesByPackage[package].push(file); + return filesByPackage; }, {}); } @@ -41,22 +46,20 @@ function groupFilesByPackage(files) { * Runs tslint for the staged files in the packages that require it. * Excludes all API extractor files. * - * @param {[packageName: string]: string[]} filesGroupedByPackage + * @param {{[packageName: string]: string[]}} filesGroupedByPackage */ function runTsLintOnFilesGroupedPerPackage(filesGroupedByPackage) { // Log an empty line on error to make the tslint output look better console.log(''); - const fileEntries = Object.keys(filesGroupedByPackage).reduce((entries, package) => { - entries.push([package, filesGroupedByPackage[package]]); - return entries; - }, []); + /** @type {[string, string[]][]} */ + // prettier-ignore + const fileEntries = (/** @type {any} */ Object.keys(filesGroupedByPackage) + .map(package => [package, filesGroupedByPackage[package]])); for (let [package, files] of fileEntries) { const tslintConfig = path.join(path.resolve(__dirname, '..', '..'), package, 'tslint.json'); - let filteredFiles = files.filter(f => { - return !f.endsWith('.api.ts'); - }); + const filteredFiles = files.filter(f => !f.endsWith('.api.ts')); if (filteredFiles.length === 0) { continue; diff --git a/scripts/templates/create-package/EmptyTsConfig.mustache b/scripts/templates/create-package/EmptyTsConfig.mustache index 879d1729f9640b..048a7d2bb5c17c 100644 --- a/scripts/templates/create-package/EmptyTsConfig.mustache +++ b/scripts/templates/create-package/EmptyTsConfig.mustache @@ -15,7 +15,7 @@ "noImplicitAny": true, "moduleResolution": "node", "preserveConstEnums": true, - "lib": ["es2017", "dom"], + "lib": ["es5", "dom"], "types": ["jest", "webpack-env"], "paths": { "{{{packageNpmName}}}/lib/*": ["./src/*"], diff --git a/typings/custom-global/index.d.ts b/typings/custom-global/index.d.ts new file mode 100644 index 00000000000000..971865a4fe641d --- /dev/null +++ b/typings/custom-global/index.d.ts @@ -0,0 +1,54 @@ +// These declarations are meant to represent the parts of Map/WeakMap/Set that exist in IE 11. +// Therefore, some functionality (such as constructor parameters) is intentionally missing. + +/** Partial Map interface representing what's available in IE 11 */ +declare interface Map { + readonly size: number; + clear(): void; + delete(key: K): boolean; + forEach(callbackfn: (value: V, key: K, map: Map) => void, thisArg?: any): void; + get(key: K): V | undefined; + has(key: K): boolean; + /** WARNING: In IE 11, this method returns undefined rather than `this` */ + set(key: K, value: V): this; +} +declare interface MapConstructor { + /** Map constructor. Does not accept parameters in IE 11. */ + new (): Map; +} +/** Partial Map constructor representing what's available in IE 11 */ +declare var Map: MapConstructor; + +/** Partial WeakMap interface representing what's available in IE 11 */ +declare interface WeakMap { + delete(key: K): boolean; + get(key: K): V | undefined; + has(key: K): boolean; + /** WARNING: In IE 11, this method returns undefined rather than `this` */ + set(key: K, value: V): this; +} + +declare interface WeakMapConstructor { + /** WeakMap constructor. Does not accept parameters in IE 11. */ + new (): WeakMap; +} +/** Partial WeakMap constructor representing what's available in IE 11 */ +declare var WeakMap: WeakMapConstructor; + +/** Partial Set interface representing what's available in IE 11 */ +declare interface Set { + readonly size: number; + /** WARNING: In IE 11, this method returns undefined rather than `this` */ + add(value: T): this; + clear(): void; + delete(value: T): boolean; + forEach(callbackfn: (value: T, value2: T, set: Set) => void, thisArg?: any): void; + has(value: T): boolean; +} + +declare interface SetConstructor { + /** Set constructor. Does not accept parameters in IE 11. */ + new (): Set; +} +/** Partial Set constructor representing what's available in IE 11 */ +declare var Set: SetConstructor;