Skip to content

Commit eff83e8

Browse files
shaodahongafc163
authored andcommitted
fix: typescript compile error
1 parent 298d34d commit eff83e8

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

examples/multiple-Portal.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import React, { useState } from 'react';
2-
import ReactDOM from 'react-dom';
1+
import * as React from 'react';
2+
import * as ReactDOM from 'react-dom';
33
import Dialog from '../src/DialogWrap';
44
import Drawer from 'rc-drawer';
55
import 'rc-drawer/assets/index.css';
66
import 'rc-dialog/assets/index.less';
77

8+
const { useState } = React;
9+
810
const Demo = () => {
911
const [showDialog, setShowDialog] = useState(false);
1012
const [showDrawer, setShowDrawer] = useState(false);

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"compile": "rc-tools run compile --babel-runtime",
5050
"pub": "rc-tools run pub --babel-runtime",
5151
"lint": "rc-tools run lint --no-js-lint",
52+
"lint:ts": "tsc",
5253
"karma": "rc-test run karma",
5354
"saucelabs": "rc-test run saucelabs",
5455
"test": "rc-test run test",

src/Dialog.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ function offset(el: any) {
4747

4848
// https://github.com/ant-design/ant-design/issues/19340
4949
// https://github.com/ant-design/ant-design/issues/19332
50-
let cacheOverflow = {};
50+
interface ICacheOverflow {
51+
overflowX?: string;
52+
overflowY?: string;
53+
}
54+
let cacheOverflow: ICacheOverflow = {};
5155

5256
export interface IDialogChildProps extends IDialogPropTypes {
5357
getOpenCount: () => number;
@@ -75,7 +79,6 @@ export default class Dialog extends React.Component<IDialogChildProps, any> {
7579
private sentinelEnd: HTMLElement;
7680
private dialogMouseDown: boolean;
7781
private timeoutId: number;
78-
private cacheOverflow: { overflowX: string | null; overflowY: string | null};
7982

8083
constructor(props: IDialogChildProps) {
8184
super(props);
@@ -383,12 +386,14 @@ export default class Dialog extends React.Component<IDialogChildProps, any> {
383386
cacheOverflow = {
384387
overflowX: document.body.style.overflowX,
385388
overflowY: document.body.style.overflowY,
386-
};
389+
} as ICacheOverflow;
387390
document.body.style.overflow = 'hidden';
388391
switchScrollingEffect();
389392
} else if (!openCount) {
390-
if (cacheOverflow.overflowX !== undefined || cacheOverflow.overflowY !== undefined) {
393+
if (cacheOverflow.overflowX !== undefined) {
391394
document.body.style.overflowX = cacheOverflow.overflowX;
395+
}
396+
if (cacheOverflow.overflowY !== undefined) {
392397
document.body.style.overflowY = cacheOverflow.overflowY;
393398
}
394399
cacheOverflow = {};

0 commit comments

Comments
 (0)