typewriter icon indicating copy to clipboard operation
typewriter copied to clipboard

Add way to remove additionalProperties ([property: string]: any)

Open DylanVann opened this issue 1 year ago • 2 comments

Currently the generated types for TypeScript look like:

export interface MyEventProperties {
  email: string
  [property: string]: any;
}

This means that if a property doesn't exist, or is removed, in Protocols, then it will not be a compile error. I think some users (including myself) would prefer to know about excess/removed properties if possible.

I believe that this could be changed by making the JSON Schema include additionalProperties: false on most definitions. It seems the default for QuickType is to generate [property: string]: any; if it is not set to false.

I tried to use a "Common JSON Schema" set to:

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "context": {},
    "traits": {},
    "properties": {
      "type": "object",
      "additionalProperties": false
    }
  }
}

It did not work though.

DylanVann avatar Aug 29 '23 21:08 DylanVann