JohnWeisz / TypedJSON

Typed JSON parsing and serializing for TypeScript that preserves type information.
MIT License
603 stars 64 forks source link

Export MapShape enum #187

Closed sebastianst closed 3 years ago

sebastianst commented 3 years ago

The enum MapShape is currently not exported in index.ts, so it cannot be used when setting MapOptions for Map fields.

aitchnyu commented 1 year ago

I had been trying to tell typedjson to parse a certain thing as a map.

I tried

import {MapShape} from 'typedjson/lib/types/type-descriptor'
...
@jsonMapMember(String, Boolean, {shape: MapShape.OBJECT})

I got the error message Cannot access ambient const enums when 'isolatedModules' is enabled.ts(2748). Its in a Vue3 + Vite + TS project.

I did this hack which works but feels crazy and will break when internal implementation of MapShape changes:

import type {MapShape} from 'typedjson/lib/types/type-descriptor'
...
  @jsonMapMember(String, Boolean, {shape: 1 as MapShape})

Could you help with correct way to set shape?