Skip to content

Commit 2b1d115

Browse files
committed
fix(ts): typing errors
1 parent 01ddb19 commit 2b1d115

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/model/workbench/explorer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import { ITreeNodeItem } from 'mo/components/tree';
1111
* @param id match by ID
1212
*/
1313
export const findParentNodeId = (treeData, id) => {
14-
const parentIds = [];
14+
const parentIds: Array<string> = [];
1515
let isContinue = true;
1616
const traverse = function (treeData, id) {
1717
treeData.forEach((item: ITreeNodeItem) => {
1818
if (!isContinue) return;
19-
parentIds.push(item.id);
19+
if (item.id) parentIds.push(item.id);
2020
if (item.id == id) {
2121
isContinue = false;
2222
} else if (item.children) {

src/services/workbench/explorerService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class ExplorerService
5353
*/
5454
public newFileItem(fileData: ITreeNodeItem, type: FileType) {
5555
const original = this.state.treeData;
56-
const loop = (data: ITreeNodeItem) => {
56+
const loop = (data: ITreeNodeItem[]) => {
5757
for (const item of data) {
5858
if (item.id === fileData.id) {
5959
if (!item.children) item.children = [];

stories/components/4-Tree.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ stories.add('Basic Usage', () => {
6060
},
6161
];
6262

63-
const [treeData, setTreeData] = useState<ITreeNodeItem[]>(data);
63+
const [treeData] = useState<ITreeNodeItem[]>(data);
6464
return (
6565
<div>
6666
<h2>简述</h2>

0 commit comments

Comments
 (0)