@alloy-js/typescript 0.14.0 → 0.16.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 (57) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/src/components/FunctionBase.d.ts.map +1 -1
  3. package/dist/src/components/FunctionBase.js +6 -1
  4. package/dist/src/components/ImportStatement.d.ts.map +1 -1
  5. package/dist/src/components/ImportStatement.js +8 -2
  6. package/dist/src/components/MemberExpression.d.ts +21 -4
  7. package/dist/src/components/MemberExpression.d.ts.map +1 -1
  8. package/dist/src/components/MemberExpression.js +302 -88
  9. package/dist/src/components/ObjectExpression.d.ts +6 -0
  10. package/dist/src/components/ObjectExpression.d.ts.map +1 -1
  11. package/dist/src/components/ObjectExpression.js +17 -1
  12. package/dist/src/components/index.d.ts +0 -1
  13. package/dist/src/components/index.d.ts.map +1 -1
  14. package/dist/src/components/index.js +0 -1
  15. package/dist/src/components/stc/index.d.ts +0 -1
  16. package/dist/src/components/stc/index.d.ts.map +1 -1
  17. package/dist/src/components/stc/index.js +0 -1
  18. package/dist/src/parameter-descriptor.d.ts +9 -0
  19. package/dist/src/parameter-descriptor.d.ts.map +1 -1
  20. package/dist/test/arrow-function.test.js +17 -0
  21. package/dist/test/basic.test.js +1 -1
  22. package/dist/test/externals.test.js +3 -3
  23. package/dist/test/function-declaration.test.js +18 -0
  24. package/dist/test/function-expression.test.js +17 -0
  25. package/dist/test/function-type.test.js +14 -0
  26. package/dist/test/imports.test.js +114 -4
  27. package/dist/test/member-expression.test.js +285 -5
  28. package/dist/test/object.test.d.ts +2 -0
  29. package/dist/test/object.test.d.ts.map +1 -0
  30. package/dist/test/object.test.js +57 -0
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +3 -3
  33. package/src/components/FunctionBase.tsx +1 -0
  34. package/src/components/ImportStatement.tsx +12 -2
  35. package/src/components/MemberExpression.tsx +364 -103
  36. package/src/components/ObjectExpression.tsx +21 -1
  37. package/src/components/index.ts +0 -1
  38. package/src/components/stc/index.ts +0 -1
  39. package/src/parameter-descriptor.ts +10 -0
  40. package/temp/api.json +231 -94
  41. package/test/arrow-function.test.tsx +22 -0
  42. package/test/basic.test.tsx +1 -1
  43. package/test/externals.test.tsx +3 -3
  44. package/test/function-declaration.test.tsx +22 -0
  45. package/test/function-expression.test.tsx +22 -0
  46. package/test/function-type.test.tsx +17 -0
  47. package/test/imports.test.tsx +75 -4
  48. package/test/member-expression.test.tsx +221 -8
  49. package/test/object.test.tsx +48 -0
  50. package/dist/src/components/MemberChainExpression.d.ts +0 -11
  51. package/dist/src/components/MemberChainExpression.d.ts.map +0 -1
  52. package/dist/src/components/MemberChainExpression.js +0 -98
  53. package/dist/test/member-chain.test.d.ts +0 -2
  54. package/dist/test/member-chain.test.d.ts.map +0 -1
  55. package/dist/test/member-chain.test.js +0 -141
  56. package/src/components/MemberChainExpression.tsx +0 -91
  57. package/test/member-chain.test.tsx +0 -124
package/temp/api.json CHANGED
@@ -7863,103 +7863,10 @@
7863
7863
  ],
7864
7864
  "extendsTokenRanges": []
7865
7865
  },
7866
- {
7867
- "kind": "Function",
7868
- "canonicalReference": "@alloy-js/typescript!MemberChainExpression:function(1)",
7869
- "docComment": "/**\n * Create a member chain expression, which is a member expression comprised of\n * either children, {@link FunctionCallExpression} components, or nested member\n * chain expression components. Other component types are ignored.\n */\n",
7870
- "excerptTokens": [
7871
- {
7872
- "kind": "Content",
7873
- "text": "export declare function MemberChainExpression(props: "
7874
- },
7875
- {
7876
- "kind": "Reference",
7877
- "text": "MemberChainExpressionProps",
7878
- "canonicalReference": "@alloy-js/typescript!MemberChainExpressionProps:interface"
7879
- },
7880
- {
7881
- "kind": "Content",
7882
- "text": "): "
7883
- },
7884
- {
7885
- "kind": "Reference",
7886
- "text": "Children",
7887
- "canonicalReference": "@alloy-js/core!Children:type"
7888
- },
7889
- {
7890
- "kind": "Content",
7891
- "text": ";"
7892
- }
7893
- ],
7894
- "fileUrlPath": "src/components/MemberChainExpression.tsx",
7895
- "returnTypeTokenRange": {
7896
- "startIndex": 3,
7897
- "endIndex": 4
7898
- },
7899
- "releaseTag": "Public",
7900
- "overloadIndex": 1,
7901
- "parameters": [
7902
- {
7903
- "parameterName": "props",
7904
- "parameterTypeTokenRange": {
7905
- "startIndex": 1,
7906
- "endIndex": 2
7907
- },
7908
- "isOptional": false
7909
- }
7910
- ],
7911
- "name": "MemberChainExpression"
7912
- },
7913
- {
7914
- "kind": "Interface",
7915
- "canonicalReference": "@alloy-js/typescript!MemberChainExpressionProps:interface",
7916
- "docComment": "",
7917
- "excerptTokens": [
7918
- {
7919
- "kind": "Content",
7920
- "text": "export interface MemberChainExpressionProps "
7921
- }
7922
- ],
7923
- "fileUrlPath": "src/components/MemberChainExpression.tsx",
7924
- "releaseTag": "Public",
7925
- "name": "MemberChainExpressionProps",
7926
- "preserveMemberOrder": false,
7927
- "members": [
7928
- {
7929
- "kind": "PropertySignature",
7930
- "canonicalReference": "@alloy-js/typescript!MemberChainExpressionProps#children:member",
7931
- "docComment": "",
7932
- "excerptTokens": [
7933
- {
7934
- "kind": "Content",
7935
- "text": "children: "
7936
- },
7937
- {
7938
- "kind": "Reference",
7939
- "text": "Children",
7940
- "canonicalReference": "@alloy-js/core!Children:type"
7941
- },
7942
- {
7943
- "kind": "Content",
7944
- "text": ";"
7945
- }
7946
- ],
7947
- "isReadonly": false,
7948
- "isOptional": false,
7949
- "releaseTag": "Public",
7950
- "name": "children",
7951
- "propertyTypeTokenRange": {
7952
- "startIndex": 1,
7953
- "endIndex": 2
7954
- }
7955
- }
7956
- ],
7957
- "extendsTokenRanges": []
7958
- },
7959
7866
  {
7960
7867
  "kind": "Function",
7961
7868
  "canonicalReference": "@alloy-js/typescript!MemberExpression:function(1)",
7962
- "docComment": "/**\n * Create a member expression from parts. Each part can provide one of\n * the following:\n *\n * * **id**: The identifier for the member expression part\n * * **refkey**: A refkey for a symbol whose name becomes the identifier\n * * **symbol**: a symbol whose name becomes the identifier part\n * * **args**: create a method call with the given args\n *\n * Additionally, a part can be `nullish`, which means subsequent parts\n * will use the appropriate conditional access operator e.g. `?.`.\n *\n * @example\n *\n *\n *\n * ```tsx\n * <MemberExpression>\n * <MemberExpression.Part id=\"base\" />\n * <MemberExpression.Part refkey={rk} nullish />\n * <MemberExpression.Part symbol={sym} />\n * <MemberExpression.Part args={[\"hello\", \"world\"]} />\n * </MemberExpression>\n * ```\n *\n *\n * Assuming `rk` is a refkey to a symbol name \"prop1\", and `sym` is a symbol\n * with a name of \"prop2\", this will render:\n *\n * ```ts\n * base.prop1?.prop2(\"hello\", \"world\")\n * ```\n *\n */\n",
7869
+ "docComment": "/**\n * Create a member expression from parts. Each part can provide one of\n * the following:\n *\n * * **id**: The identifier for the member expression part\n * * **refkey**: a refkey for a symbol whose name becomes the identifier\n * * **symbol**: a symbol whose name becomes the identifier part\n * * **args**: create a method call with the given args\n * * **children**: arbitrary contents for the identifier part.\n *\n * Each part can have a nullish prop, which indicates that the part may be null\n * or undefined.\n *\n * Each part can also have a quoteId prop, which indicates that the identifier\n * of the part should be quoted (i.e. `[\"foo\"]` instead of `.foo`). This is only\n * necessary when providing the children prop, otherwise it is determined\n * automatically.\n *\n * @example\n *\n *\n *\n * ```tsx\n * <MemberExpression>\n * <MemberExpression.Part id=\"base\" />\n * <MemberExpression.Part refkey={rk} nullish />\n * <MemberExpression.Part symbol={sym} />\n * <MemberExpression.Part args={[\"hello\", \"world\"]} />\n * <MemberExpression.Part>SomeValue</MemberExpression.Part>\n * </MemberExpression>\n * ```\n *\n *\n * Assuming `rk` is a refkey to a symbol name \"prop1\", and `sym` is a symbol\n * with a name of \"prop2\", this will render:\n *\n * ```ts\n * base.prop1?.prop2(\"hello\", \"world\").SomeValue\n * ```\n *\n */\n",
7963
7870
  "excerptTokens": [
7964
7871
  {
7965
7872
  "kind": "Content",
@@ -8108,6 +8015,34 @@
8108
8015
  "endIndex": 3
8109
8016
  }
8110
8017
  },
8018
+ {
8019
+ "kind": "PropertySignature",
8020
+ "canonicalReference": "@alloy-js/typescript!MemberExpressionPartProps#children:member",
8021
+ "docComment": "/**\n * The contents of this part. When passed, overrides the other props except\n * nullish.\n */\n",
8022
+ "excerptTokens": [
8023
+ {
8024
+ "kind": "Content",
8025
+ "text": "children?: "
8026
+ },
8027
+ {
8028
+ "kind": "Reference",
8029
+ "text": "Children",
8030
+ "canonicalReference": "@alloy-js/core!Children:type"
8031
+ },
8032
+ {
8033
+ "kind": "Content",
8034
+ "text": ";"
8035
+ }
8036
+ ],
8037
+ "isReadonly": false,
8038
+ "isOptional": true,
8039
+ "releaseTag": "Public",
8040
+ "name": "children",
8041
+ "propertyTypeTokenRange": {
8042
+ "startIndex": 1,
8043
+ "endIndex": 2
8044
+ }
8045
+ },
8111
8046
  {
8112
8047
  "kind": "PropertySignature",
8113
8048
  "canonicalReference": "@alloy-js/typescript!MemberExpressionPartProps#id:member",
@@ -8162,6 +8097,33 @@
8162
8097
  "endIndex": 2
8163
8098
  }
8164
8099
  },
8100
+ {
8101
+ "kind": "PropertySignature",
8102
+ "canonicalReference": "@alloy-js/typescript!MemberExpressionPartProps#quoteId:member",
8103
+ "docComment": "/**\n * Whether the identifier should be quoted or not. Only needed when\n * providing the `children` prop, otherwise it is determined automatically.\n */\n",
8104
+ "excerptTokens": [
8105
+ {
8106
+ "kind": "Content",
8107
+ "text": "quoteId?: "
8108
+ },
8109
+ {
8110
+ "kind": "Content",
8111
+ "text": "boolean"
8112
+ },
8113
+ {
8114
+ "kind": "Content",
8115
+ "text": ";"
8116
+ }
8117
+ ],
8118
+ "isReadonly": false,
8119
+ "isOptional": true,
8120
+ "releaseTag": "Public",
8121
+ "name": "quoteId",
8122
+ "propertyTypeTokenRange": {
8123
+ "startIndex": 1,
8124
+ "endIndex": 2
8125
+ }
8126
+ },
8165
8127
  {
8166
8128
  "kind": "PropertySignature",
8167
8129
  "canonicalReference": "@alloy-js/typescript!MemberExpressionPartProps#refkey:member",
@@ -10338,6 +10300,154 @@
10338
10300
  ],
10339
10301
  "extendsTokenRanges": []
10340
10302
  },
10303
+ {
10304
+ "kind": "Function",
10305
+ "canonicalReference": "@alloy-js/typescript!ObjectSpreadProperty:function(1)",
10306
+ "docComment": "",
10307
+ "excerptTokens": [
10308
+ {
10309
+ "kind": "Content",
10310
+ "text": "export declare function ObjectSpreadProperty(props: "
10311
+ },
10312
+ {
10313
+ "kind": "Reference",
10314
+ "text": "ObjectSpreadPropertyProps",
10315
+ "canonicalReference": "@alloy-js/typescript!ObjectSpreadPropertyProps:interface"
10316
+ },
10317
+ {
10318
+ "kind": "Content",
10319
+ "text": "): "
10320
+ },
10321
+ {
10322
+ "kind": "Reference",
10323
+ "text": "Children",
10324
+ "canonicalReference": "@alloy-js/core!Children:type"
10325
+ },
10326
+ {
10327
+ "kind": "Content",
10328
+ "text": ";"
10329
+ }
10330
+ ],
10331
+ "fileUrlPath": "src/components/ObjectExpression.tsx",
10332
+ "returnTypeTokenRange": {
10333
+ "startIndex": 3,
10334
+ "endIndex": 4
10335
+ },
10336
+ "releaseTag": "Public",
10337
+ "overloadIndex": 1,
10338
+ "parameters": [
10339
+ {
10340
+ "parameterName": "props",
10341
+ "parameterTypeTokenRange": {
10342
+ "startIndex": 1,
10343
+ "endIndex": 2
10344
+ },
10345
+ "isOptional": false
10346
+ }
10347
+ ],
10348
+ "name": "ObjectSpreadProperty"
10349
+ },
10350
+ {
10351
+ "kind": "Interface",
10352
+ "canonicalReference": "@alloy-js/typescript!ObjectSpreadPropertyProps:interface",
10353
+ "docComment": "",
10354
+ "excerptTokens": [
10355
+ {
10356
+ "kind": "Content",
10357
+ "text": "export interface ObjectSpreadPropertyProps "
10358
+ }
10359
+ ],
10360
+ "fileUrlPath": "src/components/ObjectExpression.tsx",
10361
+ "releaseTag": "Public",
10362
+ "name": "ObjectSpreadPropertyProps",
10363
+ "preserveMemberOrder": false,
10364
+ "members": [
10365
+ {
10366
+ "kind": "PropertySignature",
10367
+ "canonicalReference": "@alloy-js/typescript!ObjectSpreadPropertyProps#children:member",
10368
+ "docComment": "",
10369
+ "excerptTokens": [
10370
+ {
10371
+ "kind": "Content",
10372
+ "text": "children?: "
10373
+ },
10374
+ {
10375
+ "kind": "Reference",
10376
+ "text": "Children",
10377
+ "canonicalReference": "@alloy-js/core!Children:type"
10378
+ },
10379
+ {
10380
+ "kind": "Content",
10381
+ "text": ";"
10382
+ }
10383
+ ],
10384
+ "isReadonly": false,
10385
+ "isOptional": true,
10386
+ "releaseTag": "Public",
10387
+ "name": "children",
10388
+ "propertyTypeTokenRange": {
10389
+ "startIndex": 1,
10390
+ "endIndex": 2
10391
+ }
10392
+ },
10393
+ {
10394
+ "kind": "PropertySignature",
10395
+ "canonicalReference": "@alloy-js/typescript!ObjectSpreadPropertyProps#jsValue:member",
10396
+ "docComment": "",
10397
+ "excerptTokens": [
10398
+ {
10399
+ "kind": "Content",
10400
+ "text": "jsValue?: "
10401
+ },
10402
+ {
10403
+ "kind": "Content",
10404
+ "text": "unknown"
10405
+ },
10406
+ {
10407
+ "kind": "Content",
10408
+ "text": ";"
10409
+ }
10410
+ ],
10411
+ "isReadonly": false,
10412
+ "isOptional": true,
10413
+ "releaseTag": "Public",
10414
+ "name": "jsValue",
10415
+ "propertyTypeTokenRange": {
10416
+ "startIndex": 1,
10417
+ "endIndex": 2
10418
+ }
10419
+ },
10420
+ {
10421
+ "kind": "PropertySignature",
10422
+ "canonicalReference": "@alloy-js/typescript!ObjectSpreadPropertyProps#value:member",
10423
+ "docComment": "",
10424
+ "excerptTokens": [
10425
+ {
10426
+ "kind": "Content",
10427
+ "text": "value?: "
10428
+ },
10429
+ {
10430
+ "kind": "Reference",
10431
+ "text": "Children",
10432
+ "canonicalReference": "@alloy-js/core!Children:type"
10433
+ },
10434
+ {
10435
+ "kind": "Content",
10436
+ "text": ";"
10437
+ }
10438
+ ],
10439
+ "isReadonly": false,
10440
+ "isOptional": true,
10441
+ "releaseTag": "Public",
10442
+ "name": "value",
10443
+ "propertyTypeTokenRange": {
10444
+ "startIndex": 1,
10445
+ "endIndex": 2
10446
+ }
10447
+ }
10448
+ ],
10449
+ "extendsTokenRanges": []
10450
+ },
10341
10451
  {
10342
10452
  "kind": "Interface",
10343
10453
  "canonicalReference": "@alloy-js/typescript!PackageContext:interface",
@@ -11526,6 +11636,33 @@
11526
11636
  "endIndex": 5
11527
11637
  }
11528
11638
  },
11639
+ {
11640
+ "kind": "PropertySignature",
11641
+ "canonicalReference": "@alloy-js/typescript!ParameterDescriptorBase#rest:member",
11642
+ "docComment": "/**\n * Weather the parameter is rest parameter.\n *\n * @example\n *\n *\n *\n * ```ts\n * ...args: string[]\n * ```\n *\n */\n",
11643
+ "excerptTokens": [
11644
+ {
11645
+ "kind": "Content",
11646
+ "text": "readonly rest?: "
11647
+ },
11648
+ {
11649
+ "kind": "Content",
11650
+ "text": "boolean"
11651
+ },
11652
+ {
11653
+ "kind": "Content",
11654
+ "text": ";"
11655
+ }
11656
+ ],
11657
+ "isReadonly": true,
11658
+ "isOptional": true,
11659
+ "releaseTag": "Public",
11660
+ "name": "rest",
11661
+ "propertyTypeTokenRange": {
11662
+ "startIndex": 1,
11663
+ "endIndex": 2
11664
+ }
11665
+ },
11529
11666
  {
11530
11667
  "kind": "PropertySignature",
11531
11668
  "canonicalReference": "@alloy-js/typescript!ParameterDescriptorBase#type:member",
@@ -185,4 +185,26 @@ describe("symbols", () => {
185
185
  }
186
186
  `);
187
187
  });
188
+
189
+ it("create rest parameters", () => {
190
+ const paramDesc: ParameterDescriptor = {
191
+ name: "foo",
192
+ refkey: refkey(),
193
+ type: "any[]",
194
+ rest: true,
195
+ };
196
+ const decl = (
197
+ <>
198
+ <ArrowFunction parameters={[paramDesc]}>
199
+ console.log(foo);
200
+ </ArrowFunction>
201
+ </>
202
+ );
203
+
204
+ expect(toSourceText(decl)).toBe(d`
205
+ (...foo: any[]) => {
206
+ console.log(foo);
207
+ }
208
+ `);
209
+ });
188
210
  });
@@ -75,7 +75,7 @@ it("works", () => {
75
75
  `);
76
76
 
77
77
  expect(findFile(res, "test2.ts").contents).toEqual(d`
78
- import { sayHello, sayGoodbye } from "./test1.js";
78
+ import { sayGoodbye, sayHello } from "./test1.js";
79
79
 
80
80
  console.log(sayHello("world"));
81
81
  console.log(sayGoodbye("world"));
@@ -50,8 +50,8 @@ it("can import builtins", () => {
50
50
  }
51
51
  `,
52
52
  "index.ts": `
53
- import { nice } from "testLib/subpath";
54
53
  import { readFile } from "node:fs/promises";
54
+ import { nice } from "testLib/subpath";
55
55
 
56
56
  nice;
57
57
  await readFile();
@@ -85,8 +85,8 @@ it("can import builtins without a package", () => {
85
85
 
86
86
  assertFileContents(res, {
87
87
  "index.ts": `
88
- import { nice } from "testLib/subpath";
89
88
  import { readFile } from "node:fs/promises";
89
+ import { nice } from "testLib/subpath";
90
90
 
91
91
  nice;
92
92
  await readFile();
@@ -124,8 +124,8 @@ it("can import builtins without a package", () => {
124
124
 
125
125
  assertFileContents(res, {
126
126
  "index.ts": `
127
- import { nice } from "testLib/subpath";
128
127
  import { readFile } from "node:fs/promises";
128
+ import { nice } from "testLib/subpath";
129
129
 
130
130
  function foo() {
131
131
  function bar() {
@@ -219,4 +219,26 @@ describe("symbols", () => {
219
219
  }
220
220
  `);
221
221
  });
222
+
223
+ it("create optional parameters", () => {
224
+ const paramDesc: ParameterDescriptor = {
225
+ name: "foo",
226
+ refkey: refkey(),
227
+ type: "any[]",
228
+ rest: true,
229
+ };
230
+ const decl = (
231
+ <>
232
+ <FunctionDeclaration name="foo" parameters={[paramDesc]}>
233
+ console.log(foo);
234
+ </FunctionDeclaration>
235
+ </>
236
+ );
237
+
238
+ expect(toSourceText(decl)).toBe(d`
239
+ function foo(...foo: any[]) {
240
+ console.log(foo);
241
+ }
242
+ `);
243
+ });
222
244
  });
@@ -192,4 +192,26 @@ describe("symbols", () => {
192
192
  }
193
193
  `);
194
194
  });
195
+
196
+ it("create rest parameters", () => {
197
+ const paramDesc: ParameterDescriptor = {
198
+ name: "foo",
199
+ refkey: refkey(),
200
+ type: "any[]",
201
+ rest: true,
202
+ };
203
+ const decl = (
204
+ <>
205
+ <FunctionExpression parameters={[paramDesc]}>
206
+ console.log(foo);
207
+ </FunctionExpression>
208
+ </>
209
+ );
210
+
211
+ expect(toSourceText(decl)).toBe(d`
212
+ function (...foo: any[]) {
213
+ console.log(foo);
214
+ }
215
+ `);
216
+ });
195
217
  });
@@ -115,4 +115,21 @@ describe("symbols", () => {
115
115
  (foo?: any) => void
116
116
  `);
117
117
  });
118
+ it("create rest parameters", () => {
119
+ const paramDesc: ParameterDescriptor = {
120
+ name: "foo",
121
+ refkey: refkey(),
122
+ type: "any[]",
123
+ rest: true,
124
+ };
125
+ const decl = (
126
+ <>
127
+ <FunctionType parameters={[paramDesc]}></FunctionType>
128
+ </>
129
+ );
130
+
131
+ expect(toSourceText(decl)).toBe(d`
132
+ (...foo: any[]) => void
133
+ `);
134
+ });
118
135
  });
@@ -70,6 +70,77 @@ it("works with named imports", () => {
70
70
  });
71
71
  });
72
72
 
73
+ it("sort named imports", () => {
74
+ const res = render(
75
+ <Output>
76
+ <ts.SourceFile path="test1.ts">
77
+ <List>
78
+ <>
79
+ <ts.ClassDeclaration export name="B" refkey={refkey("B")} />
80
+ </>
81
+ <>
82
+ <ts.FunctionDeclaration export name="a" refkey={refkey("a")} />
83
+ </>
84
+ </List>
85
+ </ts.SourceFile>
86
+
87
+ <ts.SourceFile path="test2.ts">
88
+ <List>
89
+ <>
90
+ const b = <Reference refkey={refkey("B")} />;
91
+ </>
92
+ <>
93
+ const a = <Reference refkey={refkey("a")} />;
94
+ </>
95
+ </List>
96
+ </ts.SourceFile>
97
+ </Output>,
98
+ );
99
+
100
+ assertFileContents(res, {
101
+ "test2.ts": `
102
+ import { a, B } from "./test1.js";
103
+
104
+ const b = B;
105
+ const a = a;
106
+ `,
107
+ });
108
+ });
109
+
110
+ it("sort statements by import paths", () => {
111
+ const res = render(
112
+ <Output>
113
+ <ts.SourceFile path="a.ts">
114
+ <ts.ClassDeclaration export default name="A" refkey={refkey("A")} />
115
+ </ts.SourceFile>
116
+ <ts.SourceFile path="b.ts">
117
+ <ts.ClassDeclaration export default name="B" refkey={refkey("B")} />
118
+ </ts.SourceFile>
119
+
120
+ <ts.SourceFile path="test2.ts">
121
+ <List>
122
+ <>
123
+ const b = <Reference refkey={refkey("B")} />;
124
+ </>
125
+ <>
126
+ const a = <Reference refkey={refkey("A")} />;
127
+ </>
128
+ </List>
129
+ </ts.SourceFile>
130
+ </Output>,
131
+ );
132
+
133
+ assertFileContents(res, {
134
+ "test2.ts": `
135
+ import A from "./a.js";
136
+ import B from "./b.js";
137
+
138
+ const b = B;
139
+ const a = A;
140
+ `,
141
+ });
142
+ });
143
+
73
144
  it("works with default and named imports", () => {
74
145
  const res = render(
75
146
  <Output>
@@ -214,9 +285,9 @@ it("works with importing the same name many times from different files with the
214
285
 
215
286
  assertFileContents(res, {
216
287
  "test-import.ts": `
217
- import { type MyInterface, conflict } from "./test1.js";
218
- import { type MyInterface as MyInterface_2, conflict as conflict_2 } from "./test2.js";
219
- import { type MyInterface as MyInterface_3, conflict as conflict_3 } from "./test3.js";
288
+ import { conflict, type MyInterface } from "./test1.js";
289
+ import { conflict as conflict_2, type MyInterface as MyInterface_2 } from "./test2.js";
290
+ import { conflict as conflict_3, type MyInterface as MyInterface_3 } from "./test3.js";
220
291
 
221
292
  const one: MyInterface = conflict;
222
293
  const two: MyInterface_2 = conflict_2;
@@ -402,7 +473,7 @@ describe("type imports", () => {
402
473
 
403
474
  assertFileContents(res, {
404
475
  "test2.ts": `
405
- import { type TypeA, ClassA } from "./test1.js";
476
+ import { ClassA, type TypeA } from "./test1.js";
406
477
 
407
478
  type A = TypeA
408
479
  class B extends ClassA {}