Is it possible to tweak this Json data type definition to allow json-compatible types to automatically convert to it?
type JsonValue =
| string
| number
| boolean
| null
| { [property: string]: JsonValue }
| JsonValue[];
Consider the following type:
interface AttachedFile {
id: string
name: string
size: number
type: string
}
Now imagine trying to assign it like this:
const q : JsonValue = someAttachedFile
Unfortunately, an error is thrown:
Type 'AttachedFile' is not assignable to type '{ [property: string]: JsonValue; }'. Index signature is missing in type 'AttachedFile'.