I am trying to use a js date with Ts and seemingly unable to .
Usage
<Date variant="body2">on {format(new Date(), 'dd/MM/yyyy')}</Date>
Error
Expected 1-2 arguments, but got 0. TS2554
> 162 | <Date variant="body2">on {format(new Date(), 'dd/MM/yyyy')}</Date>
| ^
163 | </>
164 | )}
165 | </UploadBox>
CodePudding user response:
The issue is that you have imported a React component named Date into scope and shadowed the built-in Date object. Your code probably looks like this:
import { Date } from 'some/ui/library';
// ... snip ...
function MyCoolComponent(props) {
return <Date>{format(...)}</Date>;
}
If you want access to the global Date object you need to either:
- Import the component in another way (e. g.
import { Date as DateElement } from 'some/ui/library';) or - Access the global
Dateobject off of the global (usingwindoworglobalThis) -<Date>{format(new window.Date())}</Date>;

