import React, { useState } from 'react'; import type { DatePickerProps, TimePickerProps } from 'antd'; import { DatePicker, Select, Space, TimePicker } from 'antd'; const { Option } = Select; type PickerType = 'time' | 'date'; const PickerWithType = ({ type, onChange, }: { type: PickerType; onChange: TimePickerProps['onChange'] | DatePickerProps['onChange']; }) => { if (type === 'time') return ; if (type === 'date') return ; return ; }; const App: React.FC = () => { const [type, setType] = useState('time'); return ( console.log(value)} /> ); }; export default App;