Skip to content

GeoJSONSchema.parse doesn't narrow types #9

@GarrisonBates

Description

@GarrisonBates

I'm using zod-geojson as detailed in the readme:

const schema = GeoJSONSchema.parse({
    type: 'Feature',
    geometry: {
      type: 'Point',
      coordinates: [0, 0],
    },
    properties: {
      name: 'Null Island',
    },
  })

But for some reason, schema is typed as any. It's also worth noting that I can call GeoJSONSchema.anything() without getting any type errors. However, GeoJSONSchema appears to be typed correctly (i.e. it isn't any).

Is this a known issue? I anticipated that GeoJSONSchema.parse() would automatically type narrow the same way Zod does.

Thanks for the help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions