Skip to content

Commit 39736ac

Browse files
authored
add record type example
closes #247
1 parent 1eafe42 commit 39736ac

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docs/basic/getting-started/basic-type-examples.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ type AppProps = {
1212
names: string[];
1313
/** string literals to specify exact string values, with a union type to join them together */
1414
status: "waiting" | "success";
15-
/** any object as long as you dont use its properties (not common) */
15+
/** any object as long as you dont use its properties (NOT COMMON but useful as placeholder) */
1616
obj: object;
1717
obj2: {}; // almost the same as `object`, exactly the same as `Object`
18-
/** an object with defined properties (preferred) */
18+
/** an object with any number of properties (PREFERRED) */
1919
obj3: {
2020
id: string;
2121
title: string;
@@ -25,6 +25,11 @@ type AppProps = {
2525
id: string;
2626
title: string;
2727
}[];
28+
/** a dict object with any number of properties of the same type */
29+
dict1: {
30+
[key: string]: MyTypeHere;
31+
};
32+
dict2: Record<string, MyTypeHere>; // equivalent to dict1
2833
/** any function as long as you don't invoke it (not recommended) */
2934
onSomething: Function;
3035
/** function that doesn't take or return anything (VERY COMMON) */

0 commit comments

Comments
 (0)