Skip to content

Commit 7007bee

Browse files
author
chenyueban
committed
fix(Navigation, Command): Fixed ts errors
1 parent 70a2506 commit 7007bee

3 files changed

Lines changed: 41 additions & 17 deletions

File tree

packages/fluent-ui/src/components/Box/Box.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface BoxProps
1818
as?: keyof JSX.IntrinsicElements
1919
}
2020

21-
const Acrylic = styled.box`
21+
const Acrylic = (styled as any).box`
2222
position: relative;
2323
overflow: hidden;
2424
@supports (backdrop-filter: blur(10px)) {

packages/fluent-ui/src/components/Command/Command.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ interface Container {
3939
}
4040

4141
interface CommandType extends ForwardRefExoticComponent<CommandProps> {
42-
Content?: typeof Content
43-
Secondary?: typeof Secondary
42+
Content: typeof Content
43+
Secondary: typeof Secondary
4444
}
4545

4646
export const CommandContext = createContext(false)
4747

48-
const Command: CommandType = forwardRef<HTMLDivElement, CommandProps>(
48+
const Command = forwardRef<HTMLDivElement, CommandProps>(
4949
({ acrylic, reveal, children, ...rest }: CommandProps, ref): ReactElement => {
5050
const container: Container = {
5151
content: [],
@@ -139,8 +139,16 @@ const Command: CommandType = forwardRef<HTMLDivElement, CommandProps>(
139139
}
140140
)
141141

142-
Command.Secondary = Secondary
143-
Command.Content = Content
142+
Object.defineProperty(Command, 'Secondary', {
143+
get(): typeof Secondary {
144+
return Secondary
145+
}
146+
})
147+
Object.defineProperty(Command, 'Content', {
148+
get(): typeof Content {
149+
return Content
150+
}
151+
})
144152

145153
Command.displayName = 'FCommand'
146154

@@ -150,4 +158,4 @@ Command.defaultProps = {
150158
backgroundColor: '#e6e6e6'
151159
}
152160

153-
export default Command
161+
export default Command as CommandType

packages/fluent-ui/src/components/Navigation/Navigation.tsx

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ interface NavigationProps extends Omit<BoxProps, 'onChange'>, ThemeProps {
3232
}
3333

3434
interface NavigationType extends ForwardRefExoticComponent<NavigationProps> {
35-
Header?: typeof Header
36-
Footer?: typeof Footer
37-
Content?: typeof Content
38-
Item?: typeof Item
35+
Header: typeof Header
36+
Footer: typeof Footer
37+
Content: typeof Content
38+
Item: typeof Item
3939
}
4040

4141
interface Container {
@@ -68,7 +68,7 @@ export const NavigationContext = createContext<{
6868
horizontal: false
6969
})
7070

71-
const Navigation: NavigationType = forwardRef<HTMLDivElement, NavigationProps>(
71+
const Navigation = forwardRef<HTMLDivElement, NavigationProps>(
7272
(
7373
{
7474
horizontal,
@@ -158,10 +158,26 @@ const Navigation: NavigationType = forwardRef<HTMLDivElement, NavigationProps>(
158158
}
159159
)
160160

161-
Navigation.Header = Header
162-
Navigation.Footer = Footer
163-
Navigation.Content = Content
164-
Navigation.Item = Item
161+
Object.defineProperty(Navigation, 'Header', {
162+
get(): typeof Header {
163+
return Header
164+
}
165+
})
166+
Object.defineProperty(Navigation, 'Footer', {
167+
get(): typeof Footer {
168+
return Footer
169+
}
170+
})
171+
Object.defineProperty(Navigation, 'Content', {
172+
get(): typeof Content {
173+
return Content
174+
}
175+
})
176+
Object.defineProperty(Navigation, 'Item', {
177+
get(): typeof Item {
178+
return Item
179+
}
180+
})
165181

166182
Navigation.displayName = 'FNavigation'
167183

@@ -172,4 +188,4 @@ Navigation.defaultProps = {
172188
acrylic: false
173189
}
174190

175-
export default Navigation
191+
export default Navigation as NavigationType

0 commit comments

Comments
 (0)