Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 142327

TypeScript Parameter Defintion Overrides

$
0
0

I am using @types/react-simple-maps, and in one of their type definitions:

interface GeographiesChildrenArgument {
    geographies: object[];
    path: GeoPath;
    projection: GeoProjection;
}

they use object[]

Now, when I try to use these definitions, I have to do something like this:

{({ geographies }): React.ReactNodeArray => geographies.map(
  (geo: object) => (
    ...

is there a way I could make object more specific? If I try:

{({ geographies }: { geographies: GeographyType[] }): React.ReactNodeArray => geographies.map(
  (geo: GeographyType) => (
    ...

but then I get the following error:

Type '({ geographies }: { geographies: GeographyType[]; }) => React.ReactNodeArray' is not assignable to type '((data: GeographiesChildrenArgument) => void) | (((data: GeographiesChildrenArgument) => void) & string) | (((data: GeographiesChildrenArgument) => void) & number) | ... 5 more ... | undefined'.
Type '({ geographies }: { geographies: GeographyType[]; }) => React.ReactNodeArray' is not assignable to type '(data: GeographiesChildrenArgument) => void'.
Types of parameters '__0' and 'data' are incompatible.
Type 'GeographiesChildrenArgument' is not assignable to type '{ geographies: GeographyType[]; }'.
Types of property 'geographies' are incompatible.
Type 'object[]' is not assignable to type 'GeographyType[]'.
Type '{}' is missing the following properties from type 'GeographyType': type, geometry, propertiests (2322)
index.d.ts(95, 5): The expected type comes from property 'children' which is declared here on type 'IntrinsicAttributes & GeographiesProps & { children?: ReactNode; }'

So, is there a way to override object[] to be my object definition: GeographyType[]?


Viewing all articles
Browse latest Browse all 142327

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>