Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/json-ld.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,21 @@ import { Thing, WithContext } from "schema-dts";
* },
* knowsAbout: ["Compilers", "Computer Science"]
* }}
* space={2}
* />
* ```
*/
export class JsonLd<T extends Thing> extends React.Component<{
item: WithContext<T>;
/** Adds indentation, white space, and line break characters to JSON-LD output. {@link JSON.stringify} */
space?: string | number;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you as a jsdoc above this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pushed a commit, is that what you had in mind or?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad for not elaborating: you can put inline JSDocs above a type declaration (i.e. right above "space:") describing it, and it shows up in IDEs etc when someone's looking at props or seeing the autocomplete for space

Copy link
Contributor Author

@ntucakovic ntucakovic Apr 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

string | number is used as type declaration here instead of JSDoc, no? I don't think we can write JSDoc in inline interface declaration like in this case. IDE is complaining and TS won't compile. Can you check?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's what I mean:

image

image

}> {
render() {
return (
<script
type="application/ld+json"
dangerouslySetInnerHTML={{
__html: JSON.stringify(this.props.item, safeJsonLdReplacer)
__html: JSON.stringify(this.props.item, safeJsonLdReplacer, this.props.space)
}}
/>
);
Expand Down