Is there a place where the codes & structure of the --json output are documented?
I need this to create a tool that can consume it.
Ow, that is a great job you're doing. Thanks.
When do you think this will get merged?
I'm just waiting for Anthony to have another look at the most recent changes, should be merged after that. I'm not sure when he'll have the time though.
v0.16.0 has a new export JSONOutput which types the outputted JSON.
The root symbol is JSONOutput.ProjectReflection
Thanks for this @Gerrit0, I've been following it for a few months so I'm happy to see it land.
A couple of questions I have after trying this out.
From what I understand, some reflections like those with kindStrings of "External module" and "Interfaces" have a property called children, but none of the exported reflection types have a property called children.
The DeclarationReflection model has a signatures property, but the exported DeclarationReflection type does not.
Please could you also clarify what type the root of the output JSON is. If I type it as JSONOutput.ProjectReflection I see a type error. Also the children property on the root of the output gets typed to any.
Conversion of type '{ "id": number; "name": string; "kind": number; "flags": {}; "originalName": string; "children": ({ "id": number; "name": string; "kind": number; "kindString": string; "flags": { "isExported": boolean; }; "originalName": string; "children": ({ ...; } | { ...; })[]; "groups": { ...; }[]; "sources": { ...; }[]; } | .....' to type 'ProjectReflection' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
Types of property 'groups' are incompatible.
Type '{ "title": string; "kind": number; "children": number[]; }[]' is not comparable to type 'ReflectionGroup[]'.
Type '{ "title": string; "kind": number; "children": number[]; }' is missing the following properties from type 'ReflectionGroup': flags, name, idts(2352)
Thanks! I believe that was just missed, checking the types now. The error with groups also looks like a bug. I guess I should have added a test to ensure importing the JSON as the serialized type doesn't give an error. Fix later today :)
Most helpful comment
v0.16.0 has a new export
JSONOutputwhich types the outputted JSON.The root symbol is
JSONOutput.ProjectReflection