@alloy-js/typescript 0.23.0-dev.7 → 0.23.0-dev.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/dev/src/components/FunctionBase.js +1 -9
  2. package/dist/dev/src/components/FunctionBase.js.map +1 -1
  3. package/dist/dev/src/name-conflict-resolver.js.map +1 -1
  4. package/dist/dev/test/function-declaration.test.js +65 -7
  5. package/dist/dev/test/function-declaration.test.js.map +1 -1
  6. package/dist/dev/test/name-conflict.test.js.map +1 -1
  7. package/dist/src/components/FunctionBase.js +1 -5
  8. package/dist/src/components/FunctionBase.js.map +1 -1
  9. package/dist/src/name-conflict-resolver.d.ts +2 -2
  10. package/dist/src/name-conflict-resolver.d.ts.map +1 -1
  11. package/dist/src/name-conflict-resolver.js.map +1 -1
  12. package/dist/test/function-declaration.test.js +42 -0
  13. package/dist/test/function-declaration.test.js.map +1 -1
  14. package/dist/test/name-conflict.test.js.map +1 -1
  15. package/dist/tsconfig.tsbuildinfo +1 -1
  16. package/docs/api/components/ArrowFunction.md +71 -0
  17. package/docs/api/components/BarrelFile.md +58 -0
  18. package/docs/api/components/BlockScope.md +97 -0
  19. package/docs/api/components/CallSignature.md +45 -0
  20. package/docs/api/components/CaseClause.md +102 -0
  21. package/docs/api/components/CatchClause.md +50 -0
  22. package/docs/api/components/ClassDeclaration.md +61 -0
  23. package/docs/api/components/ClassField.md +63 -0
  24. package/docs/api/components/ClassMember.md +56 -0
  25. package/docs/api/components/ClassMethod.md +75 -0
  26. package/docs/api/components/CommaList.md +31 -0
  27. package/docs/api/components/Declaration.md +87 -0
  28. package/docs/api/components/ElseClause.md +29 -0
  29. package/docs/api/components/ElseIfClause.md +30 -0
  30. package/docs/api/components/EnumDeclaration.md +29 -0
  31. package/docs/api/components/EnumMember.md +46 -0
  32. package/docs/api/components/ExportStatement.md +26 -0
  33. package/docs/api/components/FinallyClause.md +50 -0
  34. package/docs/api/components/FunctionCallExpression.md +29 -0
  35. package/docs/api/components/FunctionDeclaration.md +57 -0
  36. package/docs/api/components/FunctionExpression.md +71 -0
  37. package/docs/api/components/IfStatement.md +30 -0
  38. package/docs/api/components/ImportStatement.md +29 -0
  39. package/docs/api/components/ImportStatements.md +25 -0
  40. package/docs/api/components/InterfaceDeclaration.md +38 -0
  41. package/docs/api/components/InterfaceMember.md +99 -0
  42. package/docs/api/components/InterfaceMethod.md +74 -0
  43. package/docs/api/components/JSDoc.md +29 -0
  44. package/docs/api/components/JSDocComment.md +29 -0
  45. package/docs/api/components/JSDocExample.md +31 -0
  46. package/docs/api/components/MemberExpression.md +58 -0
  47. package/docs/api/components/NewExpression.md +26 -0
  48. package/docs/api/components/ObjectExpression.md +32 -0
  49. package/docs/api/components/ObjectProperty.md +44 -0
  50. package/docs/api/components/ObjectSpreadProperty.md +29 -0
  51. package/docs/api/components/PackageDirectory.md +102 -0
  52. package/docs/api/components/PackageJsonFile.md +82 -0
  53. package/docs/api/components/Reference.md +26 -0
  54. package/docs/api/components/SingleLineCommentBlock.md +29 -0
  55. package/docs/api/components/SourceFile.md +41 -0
  56. package/docs/api/components/SwitchStatement.md +30 -0
  57. package/docs/api/components/TSConfigJson.md +25 -0
  58. package/docs/api/components/TryStatement.md +50 -0
  59. package/docs/api/components/TypeRefContext.md +35 -0
  60. package/docs/api/components/ValueExpression.md +25 -0
  61. package/docs/api/components/VarDeclaration.md +44 -0
  62. package/docs/api/components/ensureTypeRefContext.md +28 -0
  63. package/docs/api/components/index.md +49 -0
  64. package/docs/api/contexts/Package-context.md +21 -0
  65. package/docs/api/contexts/PackageMetadata-context.md +18 -0
  66. package/docs/api/contexts/SourceFile-context.md +20 -0
  67. package/docs/api/contexts/index.md +5 -0
  68. package/docs/api/functions/createInstanceMemberSymbol.md +38 -0
  69. package/docs/api/functions/createLexicalScope.md +27 -0
  70. package/docs/api/functions/createMemberScope.md +28 -0
  71. package/docs/api/functions/createMemberSymbol.md +42 -0
  72. package/docs/api/functions/createPackage.md +18 -0
  73. package/docs/api/functions/createPrivateInstanceMemberSymbol.md +38 -0
  74. package/docs/api/functions/createPrivateStaticMemberSymbol.md +38 -0
  75. package/docs/api/functions/createStaticMemberSymbol.md +38 -0
  76. package/docs/api/functions/createTSNamePolicy.md +17 -0
  77. package/docs/api/functions/createTransientValueSymbol.md +17 -0
  78. package/docs/api/functions/createTypeAndValueSymbol.md +38 -0
  79. package/docs/api/functions/createTypeSymbol.md +38 -0
  80. package/docs/api/functions/createValueSymbol.md +38 -0
  81. package/docs/api/functions/decl.md +38 -0
  82. package/docs/api/functions/declMember.md +42 -0
  83. package/docs/api/functions/declType.md +38 -0
  84. package/docs/api/functions/getPackageScope.md +20 -0
  85. package/docs/api/functions/getSourceDirectoryData.md +18 -0
  86. package/docs/api/functions/index.md +27 -0
  87. package/docs/api/functions/ref.md +25 -0
  88. package/docs/api/functions/tsNameConflictResolver.md +19 -0
  89. package/docs/api/functions/useTSLexicalScope.md +17 -0
  90. package/docs/api/functions/useTSLexicalScopeIfPresent.md +17 -0
  91. package/docs/api/functions/useTSMemberScope.md +17 -0
  92. package/docs/api/functions/useTSNamePolicy.md +17 -0
  93. package/docs/api/functions/useTSScope.md +17 -0
  94. package/docs/api/index.md +7 -0
  95. package/docs/api/types/AddImportOptions.md +7 -0
  96. package/docs/api/types/BlockScopeProps.md +5 -0
  97. package/docs/api/types/CaseClauseProps.md +5 -0
  98. package/docs/api/types/CaseClausePropsBase.md +9 -0
  99. package/docs/api/types/CommonDeclarationProps.md +7 -0
  100. package/docs/api/types/CreatePackageProps.md +12 -0
  101. package/docs/api/types/CreateTsSymbolOptions.md +12 -0
  102. package/docs/api/types/DeclarationProps.md +5 -0
  103. package/docs/api/types/DeclarationPropsBase.md +8 -0
  104. package/docs/api/types/ExportConditions.md +7 -0
  105. package/docs/api/types/ExportPath.md +5 -0
  106. package/docs/api/types/ExternalPackage.md +7 -0
  107. package/docs/api/types/FunctionBodyProps.md +7 -0
  108. package/docs/api/types/FunctionParametersProps.md +10 -0
  109. package/docs/api/types/FunctionTypeParameterDescriptor.md +10 -0
  110. package/docs/api/types/FunctionTypeParametersProps.md +10 -0
  111. package/docs/api/types/FunctionTypeProps.md +13 -0
  112. package/docs/api/types/ImportRecords.md +5 -0
  113. package/docs/api/types/ImportedSymbol.md +8 -0
  114. package/docs/api/types/InterfaceExpressionProps.md +7 -0
  115. package/docs/api/types/InterfaceMemberProps.md +5 -0
  116. package/docs/api/types/InterfaceMemberPropsBase.md +11 -0
  117. package/docs/api/types/MemberExpressionPartProps.md +15 -0
  118. package/docs/api/types/ModuleExports.md +18 -0
  119. package/docs/api/types/ModuleSymbolsDescriptor.md +10 -0
  120. package/docs/api/types/NamedMap.md +18 -0
  121. package/docs/api/types/NamedModuleDescriptor.md +17 -0
  122. package/docs/api/types/PackageDescriptor.md +7 -0
  123. package/docs/api/types/PackageExports.md +7 -0
  124. package/docs/api/types/PackageRefkeys.md +10 -0
  125. package/docs/api/types/ParameterDescriptor.md +11 -0
  126. package/docs/api/types/ParameterDescriptorBase.md +16 -0
  127. package/docs/api/types/RefOptions.md +7 -0
  128. package/docs/api/types/SourceDirectoryData.md +7 -0
  129. package/docs/api/types/SourceFileHeaderProps.md +8 -0
  130. package/docs/api/types/TSLexicalScope.md +13 -0
  131. package/docs/api/types/TSMemberScope.md +14 -0
  132. package/docs/api/types/TSModuleScope.md +16 -0
  133. package/docs/api/types/TSOutputScope.md +5 -0
  134. package/docs/api/types/TSOutputSymbol.md +28 -0
  135. package/docs/api/types/TSPackageScope.md +21 -0
  136. package/docs/api/types/TSPackageScopeOptions.md +9 -0
  137. package/docs/api/types/TypeDeclarationProps.md +8 -0
  138. package/docs/api/types/TypeParameterDescriptor.md +13 -0
  139. package/docs/api/types/TypeScriptElements.md +5 -0
  140. package/docs/api/types/index.md +47 -0
  141. package/docs/api/variables/FunctionType.md +24 -0
  142. package/docs/api/variables/InterfaceExpression.md +5 -0
  143. package/docs/api/variables/TSSymbolFlags.md +5 -0
  144. package/docs/api/variables/TypeDeclaration.md +5 -0
  145. package/docs/api/variables/index.md +6 -0
  146. package/package.json +4 -4
  147. package/src/components/FunctionBase.tsx +1 -1
  148. package/src/name-conflict-resolver.ts +4 -6
  149. package/temp/api.json +2 -2
  150. package/test/function-declaration.test.tsx +36 -0
  151. package/test/name-conflict.test.tsx +4 -4
@@ -0,0 +1,71 @@
1
+ # ArrowFunction
2
+
3
+ A TypeScript arrow function expression.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { ArrowFunction } from "@alloy-js/typescript";
9
+
10
+
11
+ <ArrowFunction
12
+ async
13
+ parameters={ParameterDescriptor[] | string[]}
14
+ parametersChildren={Children}
15
+ returnType={Children}
16
+ typeParameters={TypeParameterDescriptor[] | string[]}
17
+ typeParametersChildren={Children}
18
+ >
19
+ {children}
20
+ </ArrowFunction>
21
+ ```
22
+
23
+ * stc
24
+
25
+ ```ts
26
+ import { ArrowFunction } from "@alloy-js/typescript/stc";
27
+
28
+
29
+ ArrowFunction({
30
+ async: boolean,
31
+ parameters: ParameterDescriptor[] | string[],
32
+ parametersChildren: Children,
33
+ returnType: Children,
34
+ typeParameters: TypeParameterDescriptor[] | string[],
35
+ typeParametersChildren: Children,
36
+ }).children(children)
37
+ ```
38
+
39
+ ## Props
40
+
41
+ | | | |
42
+ | ---------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
43
+ | async | optional boolean | |
44
+ | children | optional [Children](../../../core/types/children/) | |
45
+ | parameters | optional [ParameterDescriptor](../../types/parameterdescriptor/)\[] \| string\[] | The parameters to the function. Can be an array of strings for parameters which don’t have a type or a default value. Otherwise, it’s an array of [ParameterDescriptor](../../types/parameterdescriptor/)s. |
46
+ | parametersChildren | optional [Children](../../../core/types/children/) | Raw content to be used as the parameter list. |
47
+ | returnType | optional [Children](../../../core/types/children/) | The return type of the function. |
48
+ | typeParameters | optional [TypeParameterDescriptor](../../types/typeparameterdescriptor/)\[] \| string\[] | The type parameters for the function. Can be an array of strings for type parameters which don’t have any constraints or a default type, otherwise it’s an array of [TypeParameterDescriptor](../../types/typeparameterdescriptor/)s. |
49
+ | typeParametersChildren | optional [Children](../../../core/types/children/) | Raw content to be used as the type parameter list. |
50
+
51
+ ## Remarks
52
+
53
+ Providing parameters and type parameters can be accomplished in one of three ways:
54
+
55
+ 1. As an array of [ParameterDescriptor](../../types/parameterdescriptor/)s or [TypeParameterDescriptor](../../types/typeparameterdescriptor/)s.
56
+ 2. As raw content via the `parametersChildren` or `typeParametersChildren` props.
57
+ 3. As a child of this component via the \[unresolved link] or \[unresolved link] components.
58
+
59
+ ## Example
60
+
61
+ ```tsx
62
+ <FunctionExpression async parameters={[{ name: "a", type: "number" }, { name: "b", type: "number" }]}>
63
+ return a + b;
64
+ <FunctionExpression>
65
+ ```
66
+
67
+ renders to
68
+
69
+ ```ts
70
+ async (a, b) => { return a + b; }
71
+ ```
@@ -0,0 +1,58 @@
1
+ # BarrelFile
2
+
3
+ Creates a source file which re-exports the exports in other files and nested barrel files in the source directory its placed in.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { BarrelFile } from "@alloy-js/typescript";
9
+
10
+
11
+ <BarrelFile export={boolean | string} path="string" />
12
+ ```
13
+
14
+ * stc
15
+
16
+ ```ts
17
+ import { BarrelFile } from "@alloy-js/typescript/stc";
18
+
19
+
20
+ BarrelFile({ export: boolean | string, path: string }).children(children)
21
+ ```
22
+
23
+ ## Props
24
+
25
+ | | | |
26
+ | ------ | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
27
+ | export | optional boolean \| string | Whether the source file is exported out of the package. When true, this source file with its source file relative to the project root. Otherwise, it will be exported with the specified path. |
28
+ | path | optional string | The name of the source file |
29
+
30
+ ## Remarks
31
+
32
+ This component must be placed directly inside a [SourceDirectory](../../../core/components/sourcedirectory/) component. It will only discover nested barrel files directly within nested source directories.
33
+
34
+ ## Example
35
+
36
+ Creating a barrel file which exports the two other source files in the same directory
37
+
38
+ ```tsx
39
+ <Output>
40
+ <SourceDirectory path="src">
41
+ <SourceFile path="one.ts" />
42
+ <SourceFile path="two.ts" />
43
+ <BarrelFile />
44
+ </SourceDirectory>
45
+ </Output>
46
+ ```
47
+
48
+ The barrel file will contain the following contents:
49
+
50
+ ```ts
51
+ export * from "./one.js";
52
+ export * from "./two.js";
53
+ ```
54
+
55
+ ## See also
56
+
57
+ * [SourceDirectory](../../../core/components/sourcedirectory/)
58
+ * [SourceFile](../sourcefile/)
@@ -0,0 +1,97 @@
1
+ # BlockScope
2
+
3
+ Create a TypeScript block which includes a scope for any nested declarations. Can either provide the scope directly via the `value` prop, or else provide information about the scope.
4
+
5
+ ## Overload 1
6
+
7
+ * jsx
8
+
9
+ ```tsx
10
+ import { BlockScope } from "@alloy-js/typescript";
11
+
12
+
13
+ <BlockScope
14
+ closer="string"
15
+ inline
16
+ newline
17
+ opener="string"
18
+ value={OutputScope}
19
+ />
20
+ ```
21
+
22
+ * stc
23
+
24
+ ```ts
25
+ import { BlockScope } from "@alloy-js/typescript/stc";
26
+
27
+
28
+ BlockScope({
29
+ closer: string,
30
+ inline: boolean,
31
+ newline: boolean,
32
+ opener: string,
33
+ value: OutputScope,
34
+ }).children(children)
35
+ ```
36
+
37
+ ### Props
38
+
39
+ | | | |
40
+ | -------- | -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
41
+ | children | optional [Children](../../../core/types/children/) | |
42
+ | children | optional [Children](../../../core/types/children/) | The block’s contents |
43
+ | closer | optional string | The closing punctuation of the block. Defaults to ”}“. |
44
+ | inline | optional boolean | If true the block will not indent the content into new lines |
45
+ | newline | optional boolean | Whether the block starts on a new line. When true, a hardline is added prior to the block. If `inline` is true, this will only apply if the block is also split due to breaking. |
46
+ | opener | optional string | The opening punctuation of the block. Defaults to ”{“. |
47
+ | value | [OutputScope](../../../core/types/outputscope/) | The scope to use. If not provided, a new scope will be created. |
48
+
49
+ ## Overload 2
50
+
51
+ * jsx
52
+
53
+ ```tsx
54
+ import { BlockScope } from "@alloy-js/typescript";
55
+
56
+
57
+ <BlockScope
58
+ closer="string"
59
+ inline
60
+ metadata={Record<string, unknown>}
61
+ name="string"
62
+ newline
63
+ opener="string"
64
+ ownerSymbol={OutputSymbol}
65
+ />
66
+ ```
67
+
68
+ * stc
69
+
70
+ ```ts
71
+ import { BlockScope } from "@alloy-js/typescript/stc";
72
+
73
+
74
+ BlockScope({
75
+ closer: string,
76
+ inline: boolean,
77
+ metadata: Record<string, unknown>,
78
+ name: string,
79
+ newline: boolean,
80
+ opener: string,
81
+ ownerSymbol: OutputSymbol,
82
+ }).children(children)
83
+ ```
84
+
85
+ ### Props
86
+
87
+ | | | |
88
+ | ----------- | ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
89
+ | children | optional [Children](../../../core/types/children/) | |
90
+ | children | optional [Children](../../../core/types/children/) | The block’s contents |
91
+ | closer | optional string | The closing punctuation of the block. Defaults to ”}“. |
92
+ | inline | optional boolean | If true the block will not indent the content into new lines |
93
+ | metadata | optional Record\<string, unknown> | Additional metadata for the scope. |
94
+ | name | optional string | The name of this scope. |
95
+ | newline | optional boolean | Whether the block starts on a new line. When true, a hardline is added prior to the block. If `inline` is true, this will only apply if the block is also split due to breaking. |
96
+ | opener | optional string | The opening punctuation of the block. Defaults to ”{“. |
97
+ | ownerSymbol | optional [OutputSymbol](../../../core/types/outputsymbol/) | Create a member scope with the owner symbol providing the in-scope symbols. |
@@ -0,0 +1,45 @@
1
+ # CallSignature
2
+
3
+ A TypeScript call signature, e.g. the part after the `function` keyword in an anonymous function expression, or a call signature in an interface.
4
+
5
+ Any parameters or type parameters declared in this signature will be placed in the current scope. This component does not make a scope to hold its parameters.
6
+
7
+ * jsx
8
+
9
+ ```tsx
10
+ import { CallSignature } from "@alloy-js/typescript";
11
+
12
+
13
+ <CallSignature
14
+ parameters={ParameterDescriptor[] | string[]}
15
+ parametersChildren={Children}
16
+ returnType={Children}
17
+ typeParameters={TypeParameterDescriptor[] | string[]}
18
+ typeParametersChildren={Children}
19
+ />
20
+ ```
21
+
22
+ * stc
23
+
24
+ ```ts
25
+ import { CallSignature } from "@alloy-js/typescript/stc";
26
+
27
+
28
+ CallSignature({
29
+ parameters: ParameterDescriptor[] | string[],
30
+ parametersChildren: Children,
31
+ returnType: Children,
32
+ typeParameters: TypeParameterDescriptor[] | string[],
33
+ typeParametersChildren: Children,
34
+ }).children(children)
35
+ ```
36
+
37
+ ## Props
38
+
39
+ | | | |
40
+ | ---------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
41
+ | parameters | optional [ParameterDescriptor](../../types/parameterdescriptor/)\[] \| string\[] | The parameters to the function. Can be an array of strings for parameters which don’t have a type or a default value. Otherwise, it’s an array of [ParameterDescriptor](../../types/parameterdescriptor/)s. |
42
+ | parametersChildren | optional [Children](../../../core/types/children/) | Raw content to be used as the parameter list. |
43
+ | returnType | optional [Children](../../../core/types/children/) | The return type of the function. |
44
+ | typeParameters | optional [TypeParameterDescriptor](../../types/typeparameterdescriptor/)\[] \| string\[] | The type parameters for the function. Can be an array of strings for type parameters which don’t have any constraints or a default type, otherwise it’s an array of [TypeParameterDescriptor](../../types/typeparameterdescriptor/)s. |
45
+ | typeParametersChildren | optional [Children](../../../core/types/children/) | Raw content to be used as the type parameter list. |
@@ -0,0 +1,102 @@
1
+ # CaseClause
2
+
3
+ A case clause in a switch statement. Provide either an expression or a JS value to compare to the switch expression. Can optionally be wrapped in a block. Pass `break` to finish with a break statement.
4
+
5
+ ## Overload 1
6
+
7
+ * jsx
8
+
9
+ ```tsx
10
+ import { CaseClause } from "@alloy-js/typescript";
11
+
12
+
13
+ <CaseClause block break expression={Children} />
14
+ ```
15
+
16
+ * stc
17
+
18
+ ```ts
19
+ import { CaseClause } from "@alloy-js/typescript/stc";
20
+
21
+
22
+ CaseClause({
23
+ block: boolean,
24
+ break: boolean,
25
+ expression: Children,
26
+ }).children(children)
27
+ ```
28
+
29
+ ### Props
30
+
31
+ | | | |
32
+ | ---------- | ----------------------------------------- | - |
33
+ | block | optional boolean | |
34
+ | break | optional boolean | |
35
+ | children | [Children](../../../core/types/children/) | |
36
+ | expression | [Children](../../../core/types/children/) | |
37
+
38
+ ## Overload 2
39
+
40
+ * jsx
41
+
42
+ ```tsx
43
+ import { CaseClause } from "@alloy-js/typescript";
44
+
45
+
46
+ <CaseClause block break jsValue={unknown} />
47
+ ```
48
+
49
+ * stc
50
+
51
+ ```ts
52
+ import { CaseClause } from "@alloy-js/typescript/stc";
53
+
54
+
55
+ CaseClause({
56
+ block: boolean,
57
+ break: boolean,
58
+ jsValue: unknown,
59
+ }).children(children)
60
+ ```
61
+
62
+ ### Props
63
+
64
+ | | | |
65
+ | -------- | ----------------------------------------- | - |
66
+ | block | optional boolean | |
67
+ | break | optional boolean | |
68
+ | children | [Children](../../../core/types/children/) | |
69
+ | jsValue | unknown | |
70
+
71
+ ## Overload 3
72
+
73
+ * jsx
74
+
75
+ ```tsx
76
+ import { CaseClause } from "@alloy-js/typescript";
77
+
78
+
79
+ <CaseClause block break default={true} />
80
+ ```
81
+
82
+ * stc
83
+
84
+ ```ts
85
+ import { CaseClause } from "@alloy-js/typescript/stc";
86
+
87
+
88
+ CaseClause({
89
+ block: boolean,
90
+ break: boolean,
91
+ default: true,
92
+ }).children(children)
93
+ ```
94
+
95
+ ### Props
96
+
97
+ | | | |
98
+ | -------- | ----------------------------------------- | - |
99
+ | block | optional boolean | |
100
+ | break | optional boolean | |
101
+ | children | [Children](../../../core/types/children/) | |
102
+ | default | true | |
@@ -0,0 +1,50 @@
1
+ # CatchClause
2
+
3
+ A catch clause of a try statement.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { CatchClause } from "@alloy-js/typescript";
9
+
10
+
11
+ <CatchClause parameter={ParameterDescriptor | string}>
12
+ {children}
13
+ </CatchClause>
14
+ ```
15
+
16
+ * stc
17
+
18
+ ```ts
19
+ import { CatchClause } from "@alloy-js/typescript/stc";
20
+
21
+
22
+ CatchClause({ parameter: ParameterDescriptor | string }).children(children)
23
+ ```
24
+
25
+ ## Props
26
+
27
+ | | | |
28
+ | --------- | -------------------------------------------------------------------------- | - |
29
+ | children | [Children](../../../core/types/children/) | |
30
+ | parameter | optional [ParameterDescriptor](../../types/parameterdescriptor/) \| string | |
31
+
32
+ ## Remarks
33
+
34
+ The parameter can be omitted for a catch-all clause, or provided as a string or [ParameterDescriptor](../../types/parameterdescriptor/). When using a descriptor, a refkey can be provided to reference the parameter within the catch block. Note that TypeScript only allows `any` or `unknown` as catch parameter types.
35
+
36
+ ## Example
37
+
38
+ ```tsx
39
+ <CatchClause parameter={{ name: "error", type: "unknown" }}>
40
+ console.error(error);
41
+ </CatchClause>
42
+ ```
43
+
44
+ renders to
45
+
46
+ ```ts
47
+ catch (error: unknown) {
48
+ console.error(error);
49
+ }
50
+ ```
@@ -0,0 +1,61 @@
1
+ # ClassDeclaration
2
+
3
+ Create a TypeScript class declaration.
4
+
5
+ * jsx
6
+
7
+ ```tsx
8
+ import { ClassDeclaration } from "@alloy-js/typescript";
9
+
10
+
11
+ <ClassDeclaration extends={Children} implements={Children[]} />
12
+ ```
13
+
14
+ * stc
15
+
16
+ ```ts
17
+ import { ClassDeclaration } from "@alloy-js/typescript/stc";
18
+
19
+
20
+ ClassDeclaration({
21
+ extends: Children,
22
+ implements: Children[],
23
+ }).children(children)
24
+ ```
25
+
26
+ ## Props
27
+
28
+ | | | |
29
+ | ---------- | ----------------------------------------------------- | - |
30
+ | extends | optional [Children](../../../core/types/children/) | |
31
+ | implements | optional [Children](../../../core/types/children/)\[] | |
32
+
33
+ ## Remarks
34
+
35
+ ## Example
36
+
37
+ ```tsx
38
+ const myPetRefkey = refkey();
39
+ const Animal = refkey();
40
+ const staticMember = refkey();
41
+ const instanceMember = refkey();
42
+
43
+ <ClassDeclaration name="Animal" refkey={Animal}>
44
+ <ClassMember public static name="something" type="string" refkey={staticMember}>
45
+ "hello"
46
+ </ClassMember>
47
+ <ClassMember public name="kind" type="string" />
48
+ <ClassMember public name="name" type="string" refkey={instanceMember} />
49
+ <ClassConstructor parameters="name: string">
50
+ this.name = name;
51
+ </ClassConstructor>
52
+ </ClassDeclaration>
53
+
54
+ <VarDeclaration const name="myPet" refkey={myPetRefkey}>
55
+ new {Animal}();
56
+ </VarDeclaration>
57
+
58
+ {staticMember}; // Animal.something
59
+ <MemberReference path={[myPetRefkey, instanceMember]} /> // myPet.name
60
+ {memberRefkey(myPetRefkey, instanceMember)}
61
+ ```
@@ -0,0 +1,63 @@
1
+ # ClassField
2
+
3
+ * jsx
4
+
5
+ ```tsx
6
+ import { ClassField } from "@alloy-js/typescript";
7
+
8
+
9
+ <ClassField
10
+ doc={Children}
11
+ jsPrivate
12
+ name={string | Namekey}
13
+ nullish
14
+ optional
15
+ private
16
+ protected
17
+ public
18
+ refkey={Refkey}
19
+ static
20
+ type={Children}
21
+ >
22
+ {children}
23
+ </ClassField>
24
+ ```
25
+
26
+ * stc
27
+
28
+ ```ts
29
+ import { ClassField } from "@alloy-js/typescript/stc";
30
+
31
+
32
+ ClassField({
33
+ doc: Children,
34
+ jsPrivate: boolean,
35
+ name: string | Namekey,
36
+ nullish: boolean,
37
+ optional: boolean,
38
+ private: boolean,
39
+ protected: boolean,
40
+ public: boolean,
41
+ refkey: Refkey,
42
+ static: boolean,
43
+ type: Children,
44
+ }).children(children)
45
+ ```
46
+
47
+ ## Props
48
+
49
+ | | | |
50
+ | --------- | -------------------------------------------------- | - |
51
+ | children | optional [Children](../../../core/types/children/) | |
52
+ | children | optional [Children](../../../core/types/children/) | |
53
+ | doc | optional [Children](../../../core/types/children/) | |
54
+ | jsPrivate | optional boolean | |
55
+ | name | string \| [Namekey](../../../core/types/namekey/) | |
56
+ | nullish | optional boolean | |
57
+ | optional | optional boolean | |
58
+ | private | optional boolean | |
59
+ | protected | optional boolean | |
60
+ | public | optional boolean | |
61
+ | refkey | optional [Refkey](../../../core/types/refkey/) | |
62
+ | static | optional boolean | |
63
+ | type | optional [Children](../../../core/types/children/) | |
@@ -0,0 +1,56 @@
1
+ # ClassMember
2
+
3
+ * jsx
4
+
5
+ ```tsx
6
+ import { ClassMember } from "@alloy-js/typescript";
7
+
8
+
9
+ <ClassMember
10
+ doc={Children}
11
+ jsPrivate
12
+ name={string | Namekey}
13
+ nullish
14
+ private
15
+ protected
16
+ public
17
+ refkey={Refkey}
18
+ static
19
+ >
20
+ {children}
21
+ </ClassMember>
22
+ ```
23
+
24
+ * stc
25
+
26
+ ```ts
27
+ import { ClassMember } from "@alloy-js/typescript/stc";
28
+
29
+
30
+ ClassMember({
31
+ doc: Children,
32
+ jsPrivate: boolean,
33
+ name: string | Namekey,
34
+ nullish: boolean,
35
+ private: boolean,
36
+ protected: boolean,
37
+ public: boolean,
38
+ refkey: Refkey,
39
+ static: boolean,
40
+ }).children(children)
41
+ ```
42
+
43
+ ## Props
44
+
45
+ | | | |
46
+ | --------- | -------------------------------------------------- | - |
47
+ | children | optional [Children](../../../core/types/children/) | |
48
+ | doc | optional [Children](../../../core/types/children/) | |
49
+ | jsPrivate | optional boolean | |
50
+ | name | string \| [Namekey](../../../core/types/namekey/) | |
51
+ | nullish | optional boolean | |
52
+ | private | optional boolean | |
53
+ | protected | optional boolean | |
54
+ | public | optional boolean | |
55
+ | refkey | optional [Refkey](../../../core/types/refkey/) | |
56
+ | static | optional boolean | |