Skip to content

Commit

Permalink
Typescript 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
BPScott committed Nov 9, 2019
1 parent 4d28354 commit c9cd99e
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 35 deletions.
2 changes: 1 addition & 1 deletion UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

### Dependency upgrades

- Upgraded to TypeScript `v3.6.4` ([#2237](https://github.com/Shopify/polaris-react/pull/2237))
- Upgraded to TypeScript `v3.7.2` ([#2237](https://github.com/Shopify/polaris-react/pull/2237))

### Code quality

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
"shx": "^0.3.2",
"storybook-chromatic": "^3.1.0",
"svgo": "^1.3.0",
"typescript": "~3.6.4"
"typescript": "~3.7.2"
},
"peerDependencies": {
"react": "^16.8.6",
Expand Down
9 changes: 6 additions & 3 deletions src/components/ContextualSaveBar/ContextualSaveBar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React from 'react';
import {ContextualSaveBarProps, useFrame} from '../../utilities/frame';
import {
ContextualSaveBarProps as ContextualSaveBarProps1,
useFrame,
} from '../../utilities/frame';

// The script in the styleguide that generates the Props Explorer data expects
// a component's props to be found in the Props interface. This silly workaround
// ensures that the Props Explorer table is generated correctly, instead of
// crashing if we write `ContextualSaveBar extends React.Component<ContextualSaveBarProps>`
export interface ContextualSaveBarProps extends ContextualSaveBarProps {}
// crashing
export type ContextualSaveBarProps = ContextualSaveBarProps1;

export const ContextualSaveBar = React.memo(function ContextualSaveBar({
message,
Expand Down
3 changes: 3 additions & 0 deletions src/components/DropZone/tests/DropZone.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,9 @@ function setBoundingClientRect(size: keyof typeof widths) {
left: 0,
bottom: 0,
right: 0,
x: 0,
y: 0,
toJSON() {},
};
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,16 +489,7 @@ describe('<DualThumb />', () => {
});
getBoundingClientRectSpy = jest
.spyOn(Element.prototype, 'getBoundingClientRect')
.mockImplementation(() => {
return {
width: 124,
height: 0,
top: 0,
left: -12,
bottom: 0,
right: 0,
};
});
.mockImplementation(mockGetBoundingClientRect);
});

afterAll(() => {
Expand Down Expand Up @@ -702,16 +693,7 @@ describe('<DualThumb />', () => {
});
getBoundingClientRectSpy = jest
.spyOn(Element.prototype, 'getBoundingClientRect')
.mockImplementation(() => {
return {
width: 124,
height: 0,
top: 0,
left: -12,
bottom: 0,
right: 0,
};
});
.mockImplementation(mockGetBoundingClientRect);
});

afterAll(() => {
Expand Down Expand Up @@ -1042,3 +1024,19 @@ function findThumbUpper(containerComponent: ReactWrapper): ReactWrapper {
function findTrack(containerComponent: ReactWrapper): ReactWrapper {
return findByTestID(containerComponent, 'trackWrapper');
}

function mockGetBoundingClientRect(): ReturnType<
Element['getBoundingClientRect']
> {
return {
width: 124,
height: 0,
top: 0,
left: -12,
bottom: 0,
right: 0,
x: 0,
y: 0,
toJSON() {},
};
}
6 changes: 3 additions & 3 deletions src/components/ThemeProvider/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export function ThemeProvider({
[customProperties, themeConfig, unstableGlobalTheming],
);

// We want these values to be `null` instead of `undefined` when not set.
// We want these values to be empty string instead of `undefined` when not set.
// Otherwise, setting a style property to `undefined` does not remove it from the DOM.
const backgroundColor = customProperties['--p-surface-background'] || null;
const color = customProperties['--p-text-on-surface'] || null;
const backgroundColor = customProperties['--p-surface-background'] || '';
const color = customProperties['--p-text-on-surface'] || '';

useEffect(() => {
document.body.style.backgroundColor = backgroundColor;
Expand Down
6 changes: 3 additions & 3 deletions src/components/Toast/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import React, {useRef} from 'react';
import {Toast as AppBridgeToast} from '@shopify/app-bridge/actions';

import {DEFAULT_TOAST_DURATION} from '../Frame';
import {ToastProps, useFrame} from '../../utilities/frame';
import {ToastProps as ToastProps1, useFrame} from '../../utilities/frame';
import {useUniqueId} from '../../utilities/unique-id';
import {useDeepEffect} from '../../utilities/use-deep-effect';
import {useAppBridge} from '../../utilities/app-bridge';

// The script in the styleguide that generates the Props Explorer data expects
// a component's props to be found in the Props interface. This silly workaround
// ensures that the Props Explorer table is generated correctly, instead of
// crashing if we write `ComposedProps = ToastProps & WithAppProviderProps`
export interface ToastProps extends ToastProps {}
// crashing
export type ToastProps = ToastProps1;

export const Toast = React.memo(function Toast(props: ToastProps) {
const id = useUniqueId('Toast');
Expand Down
3 changes: 3 additions & 0 deletions src/utilities/tests/is-element-in-viewport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,8 @@ function mockGetBoundingClientRect({
right,
height,
width,
x: 0,
y: 0,
toJSON() {},
});
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16886,10 +16886,10 @@ typedarray@^0.0.6:
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=

typescript@~3.6.4:
version "3.6.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.4.tgz#b18752bb3792bc1a0281335f7f6ebf1bbfc5b91d"
integrity sha512-unoCll1+l+YK4i4F8f22TaNVPRHcD9PA3yCuZ8g5e0qGqlVlJ/8FSateOLLSagn+Yg5+ZwuPkL8LFUc0Jcvksg==
typescript@~3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb"
integrity sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==

ua-parser-js@^0.7.18:
version "0.7.19"
Expand Down

0 comments on commit c9cd99e

Please sign in to comment.