Skip to content

Commit

Permalink
Fix typescript typings for TextField (#1315)
Browse files Browse the repository at this point in the history
* Update packages

* [typescript] Fix extending TextField issue

* Master (#1314)

* Documentation improvements  (#1229)

* [docs] Show DateIOType instead of anys  (#1228)

* Show DateIOType instead of any in prop types tables

* Update patrons list

* Remove unused filter

* Ovveride keyboard datepicker onChange date type

* Update prop-types.json

* Clarify TypeScript instructions for CSS overrides (#1257)

* Fix MuiPickersOverrides import in CSS guide

* Make instructions a little more dummy proof

* Tidyup build config (#1309)

* Tidyup build config

- upgraded babel
- upgraded rollup
- fixed material-ui globals
- replaced babel cli with rollup config with many entries
- auto resolve named exports
- skip non existent export warning
- import correct (esm/cjs) babel helpers
- error when material-ui global is not provided

Here's generated build/esm/. Treeshaking should work fine.

```
Calendar-b9ae6101.js
Calendar.js
Clock-3486e4fb.js
Clock.js
ClockView.js
DatePicker.js
DateTimePicker.js
Day.js
Picker-429246aa.js
Picker.js
TimePicker.js
TimePickerToolbar-e568e280.js
Wrapper-12538b96.js
index.js
makePickerWithState-8a1dec7e.js
useUtils-7fbeb79a.js
```

* Remove object-rest-spread

* Update packages

* Fix typescript compilation errros
  • Loading branch information
dmtrKovalenko authored Sep 13, 2019
1 parent 0fd3094 commit 54bbe73
Show file tree
Hide file tree
Showing 8 changed files with 2,124 additions and 2,764 deletions.
2 changes: 1 addition & 1 deletion docs/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class MyDocument extends Document<{ theme?: ThemeType }> {
// Render app and page and get the context of the page with collected side effects.
let pageContext: PageContext | undefined;

const { theme } = cookies(ctx);
const { theme } = cookies(ctx as any);
const page = ctx.renderPage(Component => {
const WrappedComponent = (props: any) => {
pageContext = props.pageContext;
Expand Down
7 changes: 5 additions & 2 deletions lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
"@types/styled-jsx": "^2.2.8",
"clsx": "^1.0.2",
"react-transition-group": "^4.0.0",
"rifm": "^0.7.0",
"tslib": "^1.9.3"
"rifm": "^0.7.0"
},
"size-limit": [
{
Expand Down Expand Up @@ -93,12 +92,16 @@
"@types/react": "^16.8.2",
"@types/react-dom": "^16.8.0",
"@types/react-transition-group": "^2.0.15",
"@typescript-eslint/eslint-plugin": "^1.6.0",
"@typescript-eslint/parser": "^1.6.0",
"babel-plugin-optimize-clsx": "^2.3.0",
"codecov": "^3.1.0",
"cross-env": "^5.2.0",
"date-fns": "^2.0.0-alpha.27",
"enzyme": "^3.8.0",
"enzyme-adapter-react-16": "^1.9.1",
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-react-hooks": "^1.6.0",
"fs-extra": "^7.0.1",
"full-icu": "^1.2.1",
"glob": "^7.1.3",
Expand Down
1 change: 1 addition & 0 deletions lib/src/__tests__/e2e/DateTimePicker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe('e2e -- Controlling open state', () => {
open
onClose={onCloseMock}
onChange={jest.fn()}
onFocus={console.log}
value={utilsToUse.date('2018-01-01T00:00:00.000Z')}
/>
);
Expand Down
4 changes: 2 additions & 2 deletions lib/src/_shared/KeyboardDateInput.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as React from 'react';
import TextField, { TextFieldProps } from '@material-ui/core/TextField';
import IconButton, { IconButtonProps } from '@material-ui/core/IconButton';
import InputAdornment, { InputAdornmentProps } from '@material-ui/core/InputAdornment';
import TextField, { BaseTextFieldProps, TextFieldProps } from '@material-ui/core/TextField';
import { Rifm } from 'rifm';
import { ExtendMui } from '../typings/extendMui';
import { KeyboardIcon } from './icons/KeyboardIcon';
import { makeMaskFromFormat, maskedDateFormatter } from '../_helpers/text-field-helper';

export interface KeyboardDateInputProps
extends ExtendMui<BaseTextFieldProps, 'variant' | 'onError' | 'onChange' | 'value'> {
extends ExtendMui<TextFieldProps, 'variant' | 'onError' | 'onChange' | 'value'> {
format: string;
onChange: (value: string | null) => void;
openPicker: () => void;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/_shared/PureDateInput.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import TextField, { BaseTextFieldProps, TextFieldProps } from '@material-ui/core/TextField';
import TextField, { TextFieldProps } from '@material-ui/core/TextField';
import { ExtendMui } from '../typings/extendMui';

export type NotOverridableProps =
Expand All @@ -12,7 +12,7 @@ export type NotOverridableProps =
| 'forwardedRef';

export interface PureDateInputProps
extends ExtendMui<BaseTextFieldProps, 'variant' | 'onError' | 'onChange' | 'value'> {
extends ExtendMui<TextFieldProps, 'variant' | 'onError' | 'onChange' | 'value'> {
/** Pass material-ui text field variant down, bypass internal variant prop */
inputVariant?: TextFieldProps['variant'];
/** Override input component */
Expand Down
4 changes: 3 additions & 1 deletion lib/src/views/Clock/Clock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export interface ClockProps extends WithStyles<typeof styles> {

export class Clock extends React.Component<ClockProps> {
public static propTypes: any = {
type: PropTypes.oneOf(Object.keys(ClockType).map(key => ClockType[key as any])).isRequired,
type: PropTypes.oneOf(
Object.keys(ClockType).map(key => ClockType[key as keyof typeof ClockType])
).isRequired,
value: PropTypes.number.isRequired,
onChange: PropTypes.func.isRequired,
children: PropTypes.arrayOf(PropTypes.node).isRequired,
Expand Down
3 changes: 2 additions & 1 deletion lib/src/views/Clock/ClockView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ ClockView.propTypes = {
onSecondsChange: PropTypes.func.isRequired,
ampm: PropTypes.bool,
minutesStep: PropTypes.number,
type: PropTypes.oneOf(Object.keys(ClockType).map(key => ClockType[key as any])).isRequired,
type: PropTypes.oneOf(Object.keys(ClockType).map(key => ClockType[key as keyof typeof ClockType]))
.isRequired,
} as any;

ClockView.defaultProps = {
Expand Down
Loading

0 comments on commit 54bbe73

Please sign in to comment.