@alloy-js/typescript 0.5.0 → 0.6.0

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 (154) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/src/components/ArrayExpression.d.ts +1 -1
  3. package/dist/src/components/ArrayExpression.d.ts.map +1 -1
  4. package/dist/src/components/ArrayExpression.js +18 -28
  5. package/dist/src/components/ArrayExpression.js.map +1 -1
  6. package/dist/src/components/BarrelFile.d.ts.map +1 -1
  7. package/dist/src/components/BarrelFile.js +11 -9
  8. package/dist/src/components/BarrelFile.js.map +1 -1
  9. package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
  10. package/dist/src/components/ClassDeclaration.js +8 -9
  11. package/dist/src/components/ClassDeclaration.js.map +1 -1
  12. package/dist/src/components/CommaList.d.ts +12 -0
  13. package/dist/src/components/CommaList.d.ts.map +1 -0
  14. package/dist/src/components/CommaList.js +19 -0
  15. package/dist/src/components/CommaList.js.map +1 -0
  16. package/dist/src/components/Declaration.d.ts.map +1 -1
  17. package/dist/src/components/Declaration.js.map +1 -1
  18. package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
  19. package/dist/src/components/EnumDeclaration.js +19 -17
  20. package/dist/src/components/EnumDeclaration.js.map +1 -1
  21. package/dist/src/components/EnumMember.d.ts.map +1 -1
  22. package/dist/src/components/EnumMember.js.map +1 -1
  23. package/dist/src/components/ExportStatement.d.ts.map +1 -1
  24. package/dist/src/components/ExportStatement.js.map +1 -1
  25. package/dist/src/components/FunctionCallExpression.d.ts +2 -2
  26. package/dist/src/components/FunctionCallExpression.d.ts.map +1 -1
  27. package/dist/src/components/FunctionCallExpression.js +26 -9
  28. package/dist/src/components/FunctionCallExpression.js.map +1 -1
  29. package/dist/src/components/FunctionDeclaration.d.ts +8 -1
  30. package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
  31. package/dist/src/components/FunctionDeclaration.js +135 -33
  32. package/dist/src/components/FunctionDeclaration.js.map +1 -1
  33. package/dist/src/components/ImportStatement.d.ts.map +1 -1
  34. package/dist/src/components/ImportStatement.js +25 -31
  35. package/dist/src/components/ImportStatement.js.map +1 -1
  36. package/dist/src/components/Interface.d.ts +1 -1
  37. package/dist/src/components/Interface.d.ts.map +1 -1
  38. package/dist/src/components/Interface.js +5 -5
  39. package/dist/src/components/Interface.js.map +1 -1
  40. package/dist/src/components/JSDoc.d.ts +10 -0
  41. package/dist/src/components/JSDoc.d.ts.map +1 -0
  42. package/dist/src/components/JSDoc.js +24 -0
  43. package/dist/src/components/JSDoc.js.map +1 -0
  44. package/dist/src/components/JSDocComment.d.ts +11 -0
  45. package/dist/src/components/JSDocComment.d.ts.map +1 -0
  46. package/dist/src/components/JSDocComment.js +16 -0
  47. package/dist/src/components/JSDocComment.js.map +1 -0
  48. package/dist/src/components/JSDocExample.d.ts +12 -0
  49. package/dist/src/components/JSDocExample.d.ts.map +1 -0
  50. package/dist/src/components/JSDocExample.js +26 -0
  51. package/dist/src/components/JSDocExample.js.map +1 -0
  52. package/dist/src/components/JSDocParagraph.d.ts +10 -0
  53. package/dist/src/components/JSDocParagraph.d.ts.map +1 -0
  54. package/dist/src/components/JSDocParagraph.js +23 -0
  55. package/dist/src/components/JSDocParagraph.js.map +1 -0
  56. package/dist/src/components/MemberChainExpression.d.ts +11 -0
  57. package/dist/src/components/MemberChainExpression.d.ts.map +1 -0
  58. package/dist/src/components/MemberChainExpression.js +64 -0
  59. package/dist/src/components/MemberChainExpression.js.map +1 -0
  60. package/dist/src/components/ObjectExpression.d.ts +1 -1
  61. package/dist/src/components/ObjectExpression.d.ts.map +1 -1
  62. package/dist/src/components/ObjectExpression.js +45 -42
  63. package/dist/src/components/ObjectExpression.js.map +1 -1
  64. package/dist/src/components/PackageDirectory.d.ts.map +1 -1
  65. package/dist/src/components/PackageDirectory.js +1 -1
  66. package/dist/src/components/PackageDirectory.js.map +1 -1
  67. package/dist/src/components/PackageJson.d.ts.map +1 -1
  68. package/dist/src/components/PackageJson.js.map +1 -1
  69. package/dist/src/components/Reference.js +1 -1
  70. package/dist/src/components/Reference.js.map +1 -1
  71. package/dist/src/components/SourceFile.d.ts.map +1 -1
  72. package/dist/src/components/SourceFile.js +13 -6
  73. package/dist/src/components/SourceFile.js.map +1 -1
  74. package/dist/src/components/TsConfigJson.d.ts.map +1 -1
  75. package/dist/src/components/TsConfigJson.js.map +1 -1
  76. package/dist/src/components/TypeDeclaration.d.ts.map +1 -1
  77. package/dist/src/components/TypeDeclaration.js.map +1 -1
  78. package/dist/src/components/ValueExpression.d.ts.map +1 -1
  79. package/dist/src/components/ValueExpression.js.map +1 -1
  80. package/dist/src/components/VarDeclaration.d.ts.map +1 -1
  81. package/dist/src/components/VarDeclaration.js +2 -2
  82. package/dist/src/components/VarDeclaration.js.map +1 -1
  83. package/dist/src/components/index.d.ts +2 -1
  84. package/dist/src/components/index.d.ts.map +1 -1
  85. package/dist/src/components/index.js +2 -1
  86. package/dist/src/components/index.js.map +1 -1
  87. package/dist/src/components/stc/index.d.ts +21 -21
  88. package/dist/src/components/stc/index.d.ts.map +1 -1
  89. package/dist/src/components/stc/index.js +1 -1
  90. package/dist/src/components/stc/index.js.map +1 -1
  91. package/dist/test/imports.test.d.ts.map +1 -1
  92. package/dist/test/jsdoc.test.d.ts +2 -0
  93. package/dist/test/jsdoc.test.d.ts.map +1 -0
  94. package/dist/test/member-chain.test.d.ts +2 -0
  95. package/dist/test/member-chain.test.d.ts.map +1 -0
  96. package/dist/test/utils.d.ts +2 -2
  97. package/dist/test/utils.d.ts.map +1 -1
  98. package/dist/test/values.test.d.ts.map +1 -1
  99. package/dist/tsconfig.tsbuildinfo +1 -1
  100. package/package.json +3 -5
  101. package/src/components/ArrayExpression.tsx +18 -32
  102. package/src/components/BarrelFile.tsx +7 -13
  103. package/src/components/ClassDeclaration.tsx +33 -28
  104. package/src/components/CommaList.tsx +23 -0
  105. package/src/components/Declaration.tsx +7 -3
  106. package/src/components/EnumDeclaration.tsx +21 -14
  107. package/src/components/EnumMember.tsx +7 -4
  108. package/src/components/ExportStatement.tsx +6 -1
  109. package/src/components/FunctionCallExpression.tsx +18 -9
  110. package/src/components/FunctionDeclaration.tsx +170 -55
  111. package/src/components/ImportStatement.tsx +6 -9
  112. package/src/components/Interface.tsx +20 -13
  113. package/src/components/JSDoc.tsx +28 -0
  114. package/src/components/JSDocComment.tsx +23 -0
  115. package/src/components/JSDocExample.tsx +30 -0
  116. package/src/components/JSDocParagraph.tsx +35 -0
  117. package/src/components/MemberChainExpression.tsx +59 -0
  118. package/src/components/ObjectExpression.tsx +53 -48
  119. package/src/components/PackageDirectory.tsx +11 -9
  120. package/src/components/PackageJson.tsx +9 -6
  121. package/src/components/SourceFile.tsx +15 -8
  122. package/src/components/TsConfigJson.tsx +5 -3
  123. package/src/components/TypeDeclaration.tsx +5 -3
  124. package/src/components/ValueExpression.tsx +3 -1
  125. package/src/components/VarDeclaration.tsx +11 -5
  126. package/src/components/index.ts +2 -1
  127. package/src/components/stc/index.ts +1 -1
  128. package/temp/api.json +461 -125
  129. package/test/array.test.tsx +28 -7
  130. package/test/basic.test.tsx +26 -21
  131. package/test/class.test.tsx +65 -53
  132. package/test/enum.test.tsx +18 -13
  133. package/test/externals.test.tsx +6 -7
  134. package/test/function-call-expression.test.tsx +39 -17
  135. package/test/function-declaration.test.tsx +96 -78
  136. package/test/imports.test.tsx +90 -65
  137. package/test/interface.test.tsx +29 -19
  138. package/test/jsdoc.test.tsx +154 -0
  139. package/test/member-chain.test.tsx +47 -0
  140. package/test/name-policy.test.tsx +33 -26
  141. package/test/package-external.test.tsx +8 -4
  142. package/test/package.test.tsx +1 -2
  143. package/test/reference.test.tsx +2 -6
  144. package/test/utils.tsx +3 -1
  145. package/test/value-expression.test.tsx +2 -6
  146. package/test/values.test.tsx +67 -73
  147. package/test/var-declaration.test.tsx +11 -5
  148. package/test/vitest.d.ts +6 -1
  149. package/tsconfig.json +8 -1
  150. package/dist/src/components/Block.d.ts +0 -6
  151. package/dist/src/components/Block.d.ts.map +0 -1
  152. package/dist/src/components/Block.js +0 -11
  153. package/dist/src/components/Block.js.map +0 -1
  154. package/src/components/Block.tsx +0 -12
@@ -20,12 +20,9 @@ export interface ImportStatementsProps {
20
20
  export function ImportStatements(props: ImportStatementsProps) {
21
21
  const pkg = usePackage();
22
22
 
23
- return memo(() => {
24
- // todo: may be able to remove this (was just making sure to trigger
25
- // reactivity based on props.record).
26
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
27
- props.records.size;
28
- return mapJoin(props.records, (module, importedSymbols) => {
23
+ return mapJoin(
24
+ () => props.records,
25
+ (module, importedSymbols) => {
29
26
  let targetPath: string;
30
27
 
31
28
  if (
@@ -60,8 +57,8 @@ export function ImportStatements(props: ImportStatementsProps) {
60
57
  }
61
58
 
62
59
  return <ImportStatement path={targetPath} symbols={importedSymbols} />;
63
- });
64
- });
60
+ },
61
+ );
65
62
  }
66
63
 
67
64
  export interface ImportStatementProps {
@@ -96,7 +93,7 @@ export function ImportStatement(props: ImportStatementProps) {
96
93
  parts.push("{ ");
97
94
  parts.push(
98
95
  mapJoin(
99
- namedImportSymbols,
96
+ () => namedImportSymbols,
100
97
  (nis) => <ImportBinding importedSymbol={nis} />,
101
98
  { joiner: ", " },
102
99
  ),
@@ -1,4 +1,4 @@
1
- import { Children, code, Name } from "@alloy-js/core";
1
+ import { Block, Children, Name } from "@alloy-js/core";
2
2
  import { useTSNamePolicy } from "../name-policy.js";
3
3
  import { BaseDeclarationProps, Declaration } from "./Declaration.js";
4
4
 
@@ -18,11 +18,12 @@ export interface InterfaceDeclarationProps extends BaseDeclarationProps {
18
18
  export function InterfaceDeclaration(props: InterfaceDeclarationProps) {
19
19
  const extendsPart = props.extends ? <> extends {props.extends}</> : "";
20
20
 
21
- return <Declaration {...props} nameKind="interface">
22
- interface <Name />{extendsPart} <InterfaceExpression>
23
- {props.children}
24
- </InterfaceExpression>
25
- </Declaration>;
21
+ return (
22
+ <Declaration {...props} nameKind="interface">
23
+ interface <Name />
24
+ {extendsPart} <InterfaceExpression>{props.children}</InterfaceExpression>
25
+ </Declaration>
26
+ );
26
27
  }
27
28
 
28
29
  export interface InterfaceExpressionProps {
@@ -30,11 +31,7 @@ export interface InterfaceExpressionProps {
30
31
  }
31
32
 
32
33
  export function InterfaceExpression(props: InterfaceExpressionProps) {
33
- return code`
34
- {
35
- ${props.children}
36
- }
37
- `;
34
+ return <Block>{props.children}</Block>;
38
35
  }
39
36
 
40
37
  export interface InterfaceMemberProps {
@@ -55,8 +52,18 @@ export function InterfaceMember(props: InterfaceMemberProps) {
55
52
  const optionality = props.optional ? "?" : "";
56
53
  const readonly = props.readonly ? "readonly " : "";
57
54
  if (props.indexer) {
58
- return <>[{props.indexer}]: {type}</>;
55
+ return (
56
+ <>
57
+ [{props.indexer}]: {type}
58
+ </>
59
+ );
59
60
  } else {
60
- return <>{readonly}{namer.getName(props.name!, "interface-member")}{optionality}: {type}</>;
61
+ return (
62
+ <>
63
+ {readonly}
64
+ {namer.getName(props.name!, "interface-member")}
65
+ {optionality}: {type}
66
+ </>
67
+ );
61
68
  }
62
69
  }
@@ -0,0 +1,28 @@
1
+ import { List, childrenArray } from "@alloy-js/core";
2
+ import { Children } from "@alloy-js/core/jsx-runtime";
3
+ import { JSDocComment } from "./JSDocComment.jsx";
4
+
5
+ export interface JSDocProps {
6
+ children: Children;
7
+ }
8
+
9
+ /**
10
+ * A JSDoc comment. The children of this component are joined with two hard
11
+ * linebreaks. This is useful for creating JSDoc comments with multiple paragraphs.
12
+ */
13
+ export function JSDoc(props: JSDocProps) {
14
+ return (
15
+ <JSDocComment>
16
+ <List
17
+ joiner={
18
+ <>
19
+ <hbr />
20
+ <hbr />
21
+ </>
22
+ }
23
+ >
24
+ {childrenArray(() => props.children)}
25
+ </List>
26
+ </JSDocComment>
27
+ );
28
+ }
@@ -0,0 +1,23 @@
1
+ import { Children } from "@alloy-js/core/jsx-runtime";
2
+
3
+ export interface JSDocCommentProps {
4
+ children: Children;
5
+ }
6
+
7
+ /**
8
+ * A JSDoc comment block. This is a low-level component that merely creates the
9
+ * block. Consider using {@link JSDoc} if you want to create more complex
10
+ * comments.
11
+ */
12
+ export function JSDocComment(props: JSDocCommentProps) {
13
+ return (
14
+ <>
15
+ /**
16
+ <align string=" * ">
17
+ <hbr />
18
+ {props.children}
19
+ </align>
20
+ <hbr /> **/
21
+ </>
22
+ );
23
+ }
@@ -0,0 +1,30 @@
1
+ import { Show } from "@alloy-js/core";
2
+ import { Children } from "@alloy-js/core/jsx-runtime";
3
+
4
+ export interface JSDocExampleProps {
5
+ fenced?: boolean;
6
+ language?: string;
7
+ children: Children;
8
+ }
9
+
10
+ /**
11
+ * Create a JSDoc example set off with `@example`. When the `fenced` prop is true, a `language` prop can
12
+ * also be set.
13
+ */
14
+ export function JSDocExample(props: JSDocExampleProps) {
15
+ return (
16
+ <>
17
+ @example
18
+ <hbr />
19
+ <Show when={props.fenced}>
20
+ ```{props.language}
21
+ <hbr />
22
+ </Show>
23
+ {props.children}
24
+ <Show when={props.fenced}>
25
+ <hbr />
26
+ ```
27
+ </Show>
28
+ </>
29
+ );
30
+ }
@@ -0,0 +1,35 @@
1
+ import { childrenArray, computed } from "@alloy-js/core";
2
+ import { Children } from "@alloy-js/core/jsx-runtime";
3
+
4
+ export interface JSDocParagraphProps {
5
+ children: Children;
6
+ }
7
+
8
+ /**
9
+ * Create a paragraph in a JSDoc comment. The text of this component is word
10
+ * wrapped.
11
+ */
12
+ export function JSDocParagraph(props: JSDocParagraphProps) {
13
+ const brokenChildren = computed(() => {
14
+ const children = childrenArray(() => props.children);
15
+ return children
16
+ .map((child) => {
17
+ if (typeof child === "string") {
18
+ return child
19
+ .trim()
20
+ .split(/\s+/)
21
+ .map((word) => (
22
+ <>
23
+ {word}
24
+ <br />
25
+ </>
26
+ ));
27
+ }
28
+
29
+ return child;
30
+ })
31
+ .flat(2);
32
+ });
33
+
34
+ return <fill>{brokenChildren.value}</fill>;
35
+ }
@@ -0,0 +1,59 @@
1
+ import { childrenArray, computed, For, List, Show } from "@alloy-js/core";
2
+ import { Children, isComponentCreator } from "@alloy-js/core/jsx-runtime";
3
+ import { FunctionCallExpression } from "./FunctionCallExpression.jsx";
4
+
5
+ export interface MemberChainExpressionProps {
6
+ children: Children;
7
+ }
8
+
9
+ /**
10
+ * Create a member chain expression, which is a member expression comprised of
11
+ * either children or {@link FunctionCallExpression} components. It is formatted
12
+ * such that when a linebreak is required, the FunctionCallExpression
13
+ */
14
+ export function MemberChainExpression(props: MemberChainExpressionProps) {
15
+ // chunks are constructed by consuming as many non-call expressions as
16
+ // possible, then placing an indent and soft line break before and after the
17
+ // any subsequent call expressions
18
+
19
+ const chunks = computed(() => {
20
+ const children = childrenArray(() => props.children);
21
+ const chunks: Children[][] = [];
22
+
23
+ let currentChunk: Children[] = [];
24
+
25
+ for (const child of children) {
26
+ if (
27
+ isComponentCreator(child) &&
28
+ child.component === FunctionCallExpression
29
+ ) {
30
+ if (currentChunk.length > 0) {
31
+ chunks.push(currentChunk);
32
+ currentChunk = [];
33
+ }
34
+ chunks.push([child]);
35
+ } else {
36
+ currentChunk.push(child);
37
+ }
38
+ }
39
+
40
+ return [chunks[0], chunks.slice(1)];
41
+ });
42
+
43
+ return (
44
+ <group>
45
+ <List joiner="." children={chunks.value[0]} />
46
+ <Show when={chunks.value[1].length > 0}>
47
+ <indent>
48
+ <For each={chunks.value[1]} softline>
49
+ {(chunk) => (
50
+ <>
51
+ .<List joiner="." children={chunk} />
52
+ </>
53
+ )}
54
+ </For>
55
+ </indent>
56
+ </Show>
57
+ </group>
58
+ );
59
+ }
@@ -1,14 +1,17 @@
1
1
  import {
2
2
  AssignmentContext,
3
+ Block,
3
4
  Children,
4
5
  computed,
5
6
  createAssignmentContext,
7
+ For,
6
8
  getAssignmentSymbol,
7
- mapJoin,
9
+ Match,
8
10
  MemberScope,
9
- memo,
10
11
  OutputSymbolFlags,
11
12
  Refkey,
13
+ Switch,
14
+ Wrap,
12
15
  } from "@alloy-js/core";
13
16
  import { createTSSymbol } from "../symbols/index.js";
14
17
  import { ValueExpression } from "./ValueExpression.js";
@@ -28,7 +31,7 @@ export function ObjectExpression(props: ObjectExpressionProps) {
28
31
  assignmentSymbol.binder.addStaticMembersToSymbol(assignmentSymbol);
29
32
  }
30
33
 
31
- const elements = computed(() => {
34
+ const jsValueProperties = computed(() => {
32
35
  const jsValue = props.jsValue;
33
36
  let properties: [string, unknown][];
34
37
  if (Array.isArray(jsValue)) {
@@ -40,45 +43,45 @@ export function ObjectExpression(props: ObjectExpressionProps) {
40
43
  } else {
41
44
  properties = [];
42
45
  }
43
- const elements = mapJoin(
44
- properties,
45
- ([name, value]) => {
46
- return <ObjectProperty name={name} jsValue={value} />;
47
- },
48
- { joiner: ",\n" },
49
- );
50
-
51
- if (props.children) {
52
- if (elements.length > 0) {
53
- elements.push(",");
54
- }
55
- elements.push(props.children);
56
- }
57
-
58
- return elements;
46
+ return properties;
59
47
  });
60
48
 
61
- return memo(() => {
62
- if (elements.value.length === 0) {
63
- return "{}";
64
- } else {
65
- if (assignmentSymbol) {
66
- return <>
67
- {"{"}
68
- <MemberScope owner={assignmentSymbol}>
69
- {elements.value}
70
- </MemberScope>
71
- {"}"}
72
- </>;
73
- } else {
74
- return <>
75
- {"{"}
76
- {elements.value}
77
- {"}"}
78
- </>;
79
- }
80
- }
81
- });
49
+ return (
50
+ <Switch>
51
+ <Match
52
+ when={jsValueProperties.value.length === 0 && !("children" in props)}
53
+ >
54
+ {"{}"}
55
+ </Match>
56
+ <Match else>
57
+ <group>
58
+ <Wrap
59
+ when={!!assignmentSymbol}
60
+ with={MemberScope}
61
+ props={{ owner: assignmentSymbol! }}
62
+ >
63
+ <Block>
64
+ <For each={jsValueProperties} comma softline enderPunctuation>
65
+ {([name, value]) => (
66
+ <ObjectProperty name={name} jsValue={value} />
67
+ )}
68
+ </For>
69
+ {props.children && (
70
+ <>
71
+ {jsValueProperties.value.length > 0 && (
72
+ <>
73
+ ,<sbr />
74
+ </>
75
+ )}
76
+ {props.children}
77
+ </>
78
+ )}
79
+ </Block>
80
+ </Wrap>
81
+ </group>
82
+ </Match>
83
+ </Switch>
84
+ );
82
85
  }
83
86
 
84
87
  export interface ObjectPropertyProps {
@@ -119,12 +122,14 @@ export function ObjectProperty(props: ObjectPropertyProps) {
119
122
  value = props.children;
120
123
  }
121
124
 
122
- const assignmentContext: AssignmentContext | undefined = sym ?
123
- createAssignmentContext(sym)
124
- : undefined;
125
- return <>
126
- {sym ? sym.name : name}: <AssignmentContext.Provider value={assignmentContext}>
127
- {value}
128
- </AssignmentContext.Provider>
129
- </>;
125
+ const assignmentContext: AssignmentContext | undefined =
126
+ sym ? createAssignmentContext(sym) : undefined;
127
+ return (
128
+ <>
129
+ {sym ? sym.name : name}:{" "}
130
+ <AssignmentContext.Provider value={assignmentContext}>
131
+ {value}
132
+ </AssignmentContext.Provider>
133
+ </>
134
+ );
130
135
  }
@@ -70,15 +70,17 @@ export function PackageDirectory(props: PackageDirectoryProps) {
70
70
  }
71
71
  }
72
72
 
73
- return <SourceDirectory path={props.path ?? "."}>
74
- <PackageContext.Provider value={packageContext}>
75
- <Scope value={packageContext.scope}>
76
- <PackageJsonFile {...props} />
77
- <TSConfigJson {... props.tsConfig} />
78
- {props.children}
79
- </Scope>
80
- </PackageContext.Provider>
81
- </SourceDirectory>;
73
+ return (
74
+ <SourceDirectory path={props.path ?? "."}>
75
+ <PackageContext.Provider value={packageContext}>
76
+ <Scope value={packageContext.scope}>
77
+ <PackageJsonFile {...props} />
78
+ <TSConfigJson {...props.tsConfig} />
79
+ {props.children}
80
+ </Scope>
81
+ </PackageContext.Provider>
82
+ </SourceDirectory>
83
+ );
82
84
  }
83
85
 
84
86
  function createPackageContext(
@@ -56,14 +56,17 @@ export function PackageJsonFile(props: PackageJsonFileProps) {
56
56
  ]);
57
57
  }
58
58
 
59
- pkgJson.exports = exportsEntries.length === 0 ?
60
- undefined
61
- : Object.fromEntries(exportsEntries);
59
+ pkgJson.exports =
60
+ exportsEntries.length === 0 ?
61
+ undefined
62
+ : Object.fromEntries(exportsEntries);
62
63
 
63
64
  return JSON.stringify(pkgJson, null, 2);
64
65
  });
65
66
 
66
- return <SourceFile path="package.json" filetype="json">
67
- {jsonContent}
68
- </SourceFile>;
67
+ return (
68
+ <SourceFile path="package.json" filetype="json">
69
+ {jsonContent}
70
+ </SourceFile>
71
+ );
69
72
  }
@@ -3,6 +3,7 @@ import {
3
3
  SourceFile as CoreSourceFile,
4
4
  createNamedContext,
5
5
  Scope,
6
+ Show,
6
7
  SourceDirectoryContext,
7
8
  useBinder,
8
9
  useContext,
@@ -58,14 +59,20 @@ export function SourceFile(props: SourceFileProps) {
58
59
  }
59
60
  }
60
61
 
61
- return <CoreSourceFile path={props.path} filetype="typescript" reference={Reference}>
62
- {scope.importedModules.size > 0 ? (
63
- <>
64
- <ImportStatements records={scope.importedModules} />
65
- {"\n"}
66
- </>
67
- ) : undefined}<SourceFileContext.Provider value={sfContext}>
62
+ return (
63
+ <CoreSourceFile
64
+ path={props.path}
65
+ filetype="typescript"
66
+ reference={Reference}
67
+ >
68
+ <Show when={scope.importedModules.size > 0}>
69
+ <ImportStatements records={scope.importedModules} />
70
+ <hbr />
71
+ <hbr />
72
+ </Show>
73
+ <SourceFileContext.Provider value={sfContext}>
68
74
  <Scope value={scope}>{props.children}</Scope>
69
75
  </SourceFileContext.Provider>
70
- </CoreSourceFile>;
76
+ </CoreSourceFile>
77
+ );
71
78
  }
@@ -56,7 +56,9 @@ export function TSConfigJson(props: TSConfigJsonProps) {
56
56
  return JSON.stringify(jsonContent, null, 2);
57
57
  });
58
58
 
59
- return <SourceFile path="tsconfig.json" filetype="json">
60
- {jsonContent}
61
- </SourceFile>;
59
+ return (
60
+ <SourceFile path="tsconfig.json" filetype="json">
61
+ {jsonContent}
62
+ </SourceFile>
63
+ );
62
64
  }
@@ -4,7 +4,9 @@ import { BaseDeclarationProps, Declaration } from "./Declaration.js";
4
4
  export interface TypeDeclarationProps extends BaseDeclarationProps {}
5
5
 
6
6
  export function TypeDeclaration(props: TypeDeclarationProps) {
7
- return <Declaration {...props} nameKind="type">
8
- type <Name /> = {props.children};
9
- </Declaration>;
7
+ return (
8
+ <Declaration {...props} nameKind="type">
9
+ type <Name /> = {props.children};
10
+ </Declaration>
11
+ );
10
12
  }
@@ -24,7 +24,9 @@ export function ValueExpression(props: ValueExpressionProps): Children {
24
24
  } else if (Array.isArray(jsValue)) {
25
25
  return <ArrayExpression jsValue={jsValue as unknown[]} />;
26
26
  } else {
27
- return <ObjectExpression jsValue={jsValue as Record<string, unknown>} />;
27
+ return (
28
+ <ObjectExpression jsValue={jsValue as Record<string, unknown>} />
29
+ );
28
30
  }
29
31
  } else if (typeof jsValue === "function") {
30
32
  // functions are inserted as-is.
@@ -34,9 +34,15 @@ export function VarDeclaration(props: VarDeclarationProps) {
34
34
 
35
35
  const assignmentContext = createAssignmentContext(sym);
36
36
 
37
- return <CoreDeclaration symbol={sym}>
38
- {props.export ? "export " : ""}{props.default ? "default " : ""}{keyword} <Name />{type} = <AssignmentContext.Provider value={assignmentContext}>
39
- {props.value ?? props.children};
40
- </AssignmentContext.Provider>
41
- </CoreDeclaration>;
37
+ return (
38
+ <CoreDeclaration symbol={sym}>
39
+ {props.export ? "export " : ""}
40
+ {props.default ? "default " : ""}
41
+ {keyword} <Name />
42
+ {type} ={" "}
43
+ <AssignmentContext.Provider value={assignmentContext}>
44
+ {props.value ?? props.children}
45
+ </AssignmentContext.Provider>
46
+ </CoreDeclaration>
47
+ );
42
48
  }
@@ -1,7 +1,7 @@
1
1
  export * from "./ArrayExpression.js";
2
2
  export * from "./BarrelFile.js";
3
- export * from "./Block.js";
4
3
  export * from "./ClassDeclaration.jsx";
4
+ export * from "./CommaList.jsx";
5
5
  export * from "./Declaration.js";
6
6
  export * from "./EnumDeclaration.js";
7
7
  export * from "./EnumMember.js";
@@ -10,6 +10,7 @@ export * from "./FunctionCallExpression.js";
10
10
  export * from "./FunctionDeclaration.js";
11
11
  export * from "./ImportStatement.js";
12
12
  export * from "./Interface.js";
13
+ export * from "./MemberChainExpression.jsx";
13
14
  export * from "./ObjectExpression.js";
14
15
  export * from "./PackageDirectory.js";
15
16
  export * from "./PackageJson.js";
@@ -3,7 +3,6 @@ import * as base from "../index.js";
3
3
 
4
4
  export const ArrayExpression = stc(base.ArrayExpression);
5
5
  export const BarrelFile = stc(base.BarrelFile);
6
- export const Block = stc(base.Block);
7
6
  export const ClassDeclaration = stc(base.ClassDeclaration);
8
7
  export const ClassField = stc(base.ClassField);
9
8
  export const ClassMember = stc(base.ClassMember);
@@ -19,6 +18,7 @@ export const ImportStatements = stc(base.ImportStatements);
19
18
  export const InterfaceDeclaration = stc(base.InterfaceDeclaration);
20
19
  export const InterfaceExpression = stc(base.InterfaceExpression);
21
20
  export const InterfaceMember = stc(base.InterfaceMember);
21
+ export const MemberchainExpression = stc(base.MemberChainExpression);
22
22
  export const ObjectExpression = stc(base.ObjectExpression);
23
23
  export const ObjectProperty = stc(base.ObjectProperty);
24
24
  export const PackageDirectory = stc(base.PackageDirectory);