jy95 / docusaurus-json-schema-plugin

JSON Schema viewer / editor in Docusaurus
https://jy95.github.io/docusaurus-json-schema-plugin/
GNU Affero General Public License v3.0
62 stars 9 forks source link

detectedTypes returns new Set instead of new Array #159

Closed raypatterson closed 1 year ago

raypatterson commented 1 year ago

I hesitate to report this as an issue since it was found while using swizzled source code against the latest Docusaurus beta, so maybe it's not a concern, but I found that the downstream parsing of the return value from this line doesn't work because it is a Set[] instead of an string[] (or whatever is in the original array).

https://github.com/jy95/docusaurus-json-schema-plugin/blob/604908b597014db45841a23715f218e09852552e/src/theme/JSONSchemaViewer/utils/detectTypes.ts#L138-L140

I believe the TypeScript issue is reported, but I've had no luck with configuring TypeScript compile this to be an array, and had to patch with:

- return [...new Set(declaredTypes)];
+ return Array.from(new Set(declaredTypes));
jy95 commented 1 year ago

@raypatterson Hello, not quite sure it is an issue. The used TypeScript version is greater than < 3.6 versions. Could you elaborate a testcase on stackblitz or other ?

If I am not mistaken, target version is ES2018 and downlevelIteration is not used.