The collection to iterate over.
Returns the new sorted array.
Calculates the square root of a number.
the number to calculate the root of.
the square root if x
is non-negative or NaN
if x
is negative.
Calculates the square root of a number.
sqrtArrowFunction
is defined using a variable declaration:
export const sqrtArrowFunction = (x: number): number => Math.sqrt(x);
TypeDoc is smart and documents sqrtArrowFunction
as a function rather than a variable.
the number do calculate the root of.
the square root if x
is non-negative or NaN
if x
is negative.
A simple generic function that concatenates two arrays.
Use @typeParam <param name>
to document generic type parameters, e.g.
@typeParam T the element type of the arrays
the element type of the arrays
A function that takes in an options object that is defined as a separate interface and makes an HTTP call.
Make sure to export the options type when using this pattern. Otherwise, TypeDoc will not document the options.
A function that takes in an options object and makes an HTTP call.
The options type is written directly in the function definition.
e.g. GET, POST, PUT, DELETE
e.g. { 'Authorization': 'Bearer <access token>' }
Stringifies and concatenates two numbers into a single string.
The documentation site allows you to toggle between the different overloads of a function. The implementation signature of the overloaded function is not included in the documentation.
Concatenates two strings.
The documentation site allows you to toggle between the different overloads of a function. The implementation signature of the overloaded function is not included in the documentation.
Renders a card around some content.
<CardA variant="secondary">
<h5>My Title</h5>
<p>My content</p>
</CardA>
The props type is defined as a separate interface which must be exported!
export interface CardAProps {
// ...
}
export function CardA({
children,
variant = "primary",
}: PropsWithChildren<CardAProps>): ReactElement {
// ...
}
This is our recommended way to define React components as it makes your code
more readable. The minor drawback is you must click the CardAProps
link to
see the component's props.
Renders a card around some content.
<CardB variant="secondary">
<h5>My Title</h5>
<p>My content</p>
</CardB>
The props type is written directly in the function definition:
export function CardB({
children,
variant = "primary",
}: PropsWithChildren<{
variant: "primary" | "secondary" | "success" | "danger" | "light" | "dark";
}>): ReactElement {
// ...
}
This can make the TypeDoc documentation a bit cleaner for very simple components, but it makes your code less readable.
An example of a complex React component.
A wrapper around ActionDialog
that removes a lot of the boilerplate needed
for dialogs that contain a form.
interface ExampleProps {
onSuccess(responseData: number): Promise<void>
onClose(): void
}
export function Example({
onSuccess,
onClose,
}: ExampleProps): ReactElement {
const { onChildValidChange, allFieldsValid } = useFieldValidity()
const [showValidation, setShowValidation] = useState(false)
const vProps = { showValidation, onValidChange: onChildValidChange }
const [myNumber, setMyNumber] = useState('')
async function submit() {
await api.product.performOperation()
return {
responseData: parseInt(myNumber),
}
}
return (
<EasyFormDialog
title="Enter a Number"
submitButtonText="Submit"
formIsValid={allFieldsValid}
showValidation={showValidation}
onShowValidationChange={setShowValidation}
onSubmit={submit}
onSuccess={onSuccess}
onClose={onClose}
>
<FormGroup label="My number">
{(id) => (
<ValidatedInput
id={id}
name="myNumber"
validators={[Validators.required(), Validators.integer()]}
value={myNumber}
onChange={setMyNumber}
{...vProps}
/>
)}
</FormGroup>
</EasyFormDialog>
)
}
All comments are parsed as Markdown. TypeDoc uses the Marked markdown parser to convert comments to HTML.
You can link to other classes, members or functions using double square brackets or an inline link tag. See the TypeDoc documentation for details.
Some inline code: npm install --save-dev typedoc
A TypeScript code block:
// A fabulous variable
const x: number | string = 12
See syntaxHighlightingShowcase
for more code blocks.
Package | Version |
---|---|
lodash | 4.17.21 |
react | 17.0.2 |
typedoc | 0.22.4 |
Rebellious subjects, enemies to peace, Profaners of this neighbour-stained steel,-- Will they not hear? What, ho! you men, you beasts, That quench the fire of your pernicious rage With purple fountains issuing from your veins
This requires the media option to be set.
TypeDoc supports code blocks in Markdown and uses Shiki to provide syntax highlighting.
If no language is specified, the code block is assumed to be TypeScript:
// A fabulous variable
const x: number | string = 12
You can specify the language at the start of your code block like this:
```rust
Use the tsx
language to get JSX support:
function BasicComponent(): ReactElement {
return <div>Test</div>
}
You might want to write code in the language your backend uses. Here's some Python:
for i in range(30):
print(i + 1)
And some CSS:
.card {
background-color: white;
padding: 1rem;
border: 1px solid lightgray;
}
If you don't want syntax highlighting, use the text
language:
package.json
src/
index.ts
__tests__/
index.test.ts
View the full list of supported
languages.
You can also get this list by running typedoc --help
.
A simple type alias defined using the type
keyword.
A complex generic type.
A simple numeric constant.
A simple string constant.
An plain JavaScript object using as const
.
An exported variable defined with let
.
This pattern should generally be avoided because the variable can be reassigned.
Generated using TypeDoc
Creates an array of elements, sorted in ascending order by the results of running each element in a collection through each iteratee. This method performs a stable sort, that is, it preserves the original sort order of equal elements. The iteratees are invoked with one argument: (value).
var users = [ { 'user': 'fred', 'age': 48 }, { 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 42 }, { 'user': 'barney', 'age': 34 } ];
_.sortBy(users, function(o) { return o.user; }); // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]
_.sortBy(users, ['user', 'age']); // => objects for [['barney', 34], ['barney', 36], ['fred', 42], ['fred', 48]]
_.sortBy(users, 'user', function(o) { return Math.floor(o.age / 10); }); // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]