@alloy-js/typescript 0.11.0 → 0.12.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 (95) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/src/components/ClassDeclaration.d.ts +2 -0
  3. package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
  4. package/dist/src/components/ClassDeclaration.js +14 -2
  5. package/dist/src/components/FunctionBase.d.ts.map +1 -1
  6. package/dist/src/components/FunctionBase.js +13 -3
  7. package/dist/src/components/FunctionType.d.ts +7 -8
  8. package/dist/src/components/FunctionType.d.ts.map +1 -1
  9. package/dist/src/components/FunctionType.js +29 -25
  10. package/dist/src/components/ImportStatement.d.ts.map +1 -1
  11. package/dist/src/components/ImportStatement.js +9 -2
  12. package/dist/src/components/Interface.d.ts +3 -2
  13. package/dist/src/components/Interface.d.ts.map +1 -1
  14. package/dist/src/components/Interface.js +8 -4
  15. package/dist/src/components/JSDocComment.js +1 -1
  16. package/dist/src/components/MemberDeclaration.d.ts +4 -0
  17. package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
  18. package/dist/src/components/MemberDeclaration.js +1 -1
  19. package/dist/src/components/MemberExpression.d.ts.map +1 -1
  20. package/dist/src/components/MemberExpression.js +3 -2
  21. package/dist/src/components/Reference.d.ts +8 -1
  22. package/dist/src/components/Reference.d.ts.map +1 -1
  23. package/dist/src/components/Reference.js +7 -2
  24. package/dist/src/components/TypeDeclaration.d.ts +1 -1
  25. package/dist/src/components/TypeDeclaration.d.ts.map +1 -1
  26. package/dist/src/components/TypeDeclaration.js +3 -2
  27. package/dist/src/components/TypeRefContext.d.ts +22 -0
  28. package/dist/src/components/TypeRefContext.d.ts.map +1 -0
  29. package/dist/src/components/TypeRefContext.js +41 -0
  30. package/dist/src/components/VarDeclaration.d.ts +1 -0
  31. package/dist/src/components/VarDeclaration.d.ts.map +1 -1
  32. package/dist/src/components/VarDeclaration.js +9 -3
  33. package/dist/src/components/index.d.ts +1 -0
  34. package/dist/src/components/index.d.ts.map +1 -1
  35. package/dist/src/components/index.js +1 -0
  36. package/dist/src/components/stc/index.d.ts +1 -0
  37. package/dist/src/components/stc/index.d.ts.map +1 -1
  38. package/dist/src/components/stc/index.js +1 -0
  39. package/dist/src/context/type-ref-context.d.ts +15 -0
  40. package/dist/src/context/type-ref-context.d.ts.map +1 -0
  41. package/dist/src/context/type-ref-context.js +12 -0
  42. package/dist/src/parameter-descriptor.d.ts +6 -0
  43. package/dist/src/parameter-descriptor.d.ts.map +1 -1
  44. package/dist/src/symbols/reference.d.ts +4 -1
  45. package/dist/src/symbols/reference.d.ts.map +1 -1
  46. package/dist/src/symbols/reference.js +11 -5
  47. package/dist/src/symbols/ts-module-scope.d.ts +4 -1
  48. package/dist/src/symbols/ts-module-scope.d.ts.map +1 -1
  49. package/dist/src/symbols/ts-module-scope.js +10 -3
  50. package/dist/src/symbols/ts-output-symbol.d.ts +2 -1
  51. package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
  52. package/dist/src/symbols/ts-output-symbol.js +1 -0
  53. package/dist/test/class.test.js +4 -4
  54. package/dist/test/enum-jsdoc.test.js +6 -6
  55. package/dist/test/function-declaration-jsdoc.test.js +3 -3
  56. package/dist/test/imports.test.d.ts.map +1 -1
  57. package/dist/test/imports.test.js +208 -2
  58. package/dist/test/interface-jsdoc.test.js +9 -9
  59. package/dist/test/jsdoc.test.js +5 -5
  60. package/dist/test/jsdocparam.test.js +8 -8
  61. package/dist/test/member-expression.test.js +218 -2
  62. package/dist/test/var-declaration-jsdoc.test.js +3 -3
  63. package/dist/test/var-declaration.test.js +1 -1
  64. package/dist/tsconfig.tsbuildinfo +1 -1
  65. package/package.json +4 -4
  66. package/src/components/ClassDeclaration.tsx +19 -3
  67. package/src/components/FunctionBase.tsx +14 -3
  68. package/src/components/FunctionType.tsx +45 -40
  69. package/src/components/ImportStatement.tsx +30 -3
  70. package/src/components/Interface.tsx +41 -34
  71. package/src/components/JSDocComment.tsx +1 -1
  72. package/src/components/MemberDeclaration.tsx +7 -1
  73. package/src/components/MemberExpression.tsx +7 -2
  74. package/src/components/Reference.tsx +12 -2
  75. package/src/components/TypeDeclaration.tsx +16 -13
  76. package/src/components/TypeRefContext.tsx +49 -0
  77. package/src/components/VarDeclaration.tsx +6 -2
  78. package/src/components/index.ts +1 -0
  79. package/src/components/stc/index.ts +1 -0
  80. package/src/context/type-ref-context.tsx +19 -0
  81. package/src/parameter-descriptor.ts +7 -0
  82. package/src/symbols/reference.ts +17 -5
  83. package/src/symbols/ts-module-scope.ts +19 -4
  84. package/src/symbols/ts-output-symbol.ts +1 -0
  85. package/temp/api.json +613 -220
  86. package/test/class.test.tsx +4 -4
  87. package/test/enum-jsdoc.test.tsx +6 -6
  88. package/test/function-declaration-jsdoc.test.tsx +3 -3
  89. package/test/imports.test.tsx +165 -1
  90. package/test/interface-jsdoc.test.tsx +9 -9
  91. package/test/jsdoc.test.tsx +5 -5
  92. package/test/jsdocparam.test.tsx +8 -8
  93. package/test/member-expression.test.tsx +171 -2
  94. package/test/var-declaration-jsdoc.test.tsx +3 -3
  95. package/test/var-declaration.test.tsx +1 -1
@@ -31,6 +31,7 @@ export * from "./SourceFile.js";
31
31
  export * from "./SwitchStatement.js";
32
32
  export * from "./TsConfigJson.js";
33
33
  export * from "./TypeDeclaration.js";
34
+ export * from "./TypeRefContext.js";
34
35
  export * from "./ValueExpression.js";
35
36
  export * from "./VarDeclaration.js";
36
37
  export {};
@@ -40,6 +40,7 @@ export declare const CaseClause: import("@alloy-js/core").StcSignature<base.Case
40
40
  export declare const TSConfigJson: import("@alloy-js/core").StcSignature<base.TSConfigJsonProps>;
41
41
  export declare const FunctionType: import("@alloy-js/core").StcSignature<base.FunctionTypeProps>;
42
42
  export declare const TypeDeclaration: import("@alloy-js/core").StcSignature<base.TypeDeclarationProps>;
43
+ export declare const TypeRefContext: import("@alloy-js/core").StcSignature<base.TypeRefContextProps>;
43
44
  export declare const ValueExpression: import("@alloy-js/core").StcSignature<base.ValueExpressionProps>;
44
45
  export declare const VarDeclaration: import("@alloy-js/core").StcSignature<base.VarDeclarationProps>;
45
46
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/stc/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AAEpC,eAAO,MAAM,eAAe,kEAA4B,CAAC;AACzD,eAAO,MAAM,aAAa,gEAA0B,CAAC;AACrD,eAAO,MAAM,UAAU,6DAAuB,CAAC;AAC/C,eAAO,MAAM,aAAa,gEAA0B,CAAC;AACrD,eAAO,MAAM,gBAAgB,mEAA6B,CAAC;AAC3D,eAAO,MAAM,UAAU,6DAAuB,CAAC;AAC/C,eAAO,MAAM,WAAW,8DAAwB,CAAC;AACjD,eAAO,MAAM,WAAW,8DAAwB,CAAC;AACjD,eAAO,MAAM,SAAS,4DAAsB,CAAC;AAC7C,eAAO,MAAM,WAAW,8DAAwB,CAAC;AACjD,eAAO,MAAM,eAAe,kEAA4B,CAAC;AACzD,eAAO,MAAM,UAAU,6DAAuB,CAAC;AAC/C,eAAO,MAAM,eAAe,kEAA4B,CAAC;AACzD,eAAO,MAAM,sBAAsB,yEAAmC,CAAC;AACvE,eAAO,MAAM,mBAAmB,sEAAgC,CAAC;AACjE,eAAO,MAAM,kBAAkB,qEAA+B,CAAC;AAC/D,eAAO,MAAM,WAAW,8DAAwB,CAAC;AACjD,eAAO,MAAM,UAAU,6DAAuB,CAAC;AAC/C,eAAO,MAAM,YAAY,+DAAyB,CAAC;AACnD,eAAO,MAAM,eAAe,kEAA4B,CAAC;AACzD,eAAO,MAAM,gBAAgB,mEAA6B,CAAC;AAC3D,eAAO,MAAM,oBAAoB,uEAAiC,CAAC;AACnE,eAAO,MAAM,mBAAmB,sEAAgC,CAAC;AACjE,eAAO,MAAM,eAAe,kEAA4B,CAAC;AACzD,eAAO,MAAM,eAAe,kEAA4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,eAAO,MAAM,cAAc,iEAA2B,CAAC;AACvD,eAAO,MAAM,eAAe,kEAA4B,CAAC;AACzD,eAAO,MAAM,cAAc,iEAA2B,CAAC"}
@@ -41,5 +41,6 @@ export const CaseClause = stc(base.CaseClause);
41
41
  export const TSConfigJson = stc(base.TSConfigJson);
42
42
  export const FunctionType = stc(base.FunctionType);
43
43
  export const TypeDeclaration = stc(base.TypeDeclaration);
44
+ export const TypeRefContext = stc(base.TypeRefContext);
44
45
  export const ValueExpression = stc(base.ValueExpression);
45
46
  export const VarDeclaration = stc(base.VarDeclaration);
@@ -0,0 +1,15 @@
1
+ import { ComponentContext } from "@alloy-js/core";
2
+ interface TypeRefContext {
3
+ /** If in a type context */
4
+ type?: boolean;
5
+ }
6
+ /**
7
+ * Provides scopes for instance and static private members.
8
+ */
9
+ export declare const TypeRefContext: ComponentContext<TypeRefContext>;
10
+ /**
11
+ * @returns 'true' if in a type context, 'false' if in a value context.
12
+ */
13
+ export declare function isTypeRefContext(): boolean;
14
+ export {};
15
+ //# sourceMappingURL=type-ref-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-ref-context.d.ts","sourceRoot":"","sources":["../../../src/context/type-ref-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA6B,MAAM,gBAAgB,CAAC;AAE7E,UAAU,cAAc;IACtB,2BAA2B;IAC3B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,cAAc,CAC3B,CAAC;AAElC;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAE1C"}
@@ -0,0 +1,12 @@
1
+ import { createContext, useContext } from "@alloy-js/core";
2
+ /**
3
+ * Provides scopes for instance and static private members.
4
+ */
5
+ export const TypeRefContext = createContext();
6
+
7
+ /**
8
+ * @returns 'true' if in a type context, 'false' if in a value context.
9
+ */
10
+ export function isTypeRefContext() {
11
+ return useContext(TypeRefContext)?.type ?? false;
12
+ }
@@ -19,6 +19,12 @@ export interface ParameterDescriptorBase {
19
19
  * Whether the parameter is optional.
20
20
  */
21
21
  readonly optional?: boolean;
22
+ /**
23
+ * Whether the parameter is can be null or undefined.
24
+ * when optional is true, this will be set to true by default,
25
+ * but explicitly setting this to false will override that.
26
+ */
27
+ readonly nullish?: boolean;
22
28
  /**
23
29
  * Arbitrary metadata for the parameter symbol.
24
30
  */
@@ -1 +1 @@
1
- {"version":3,"file":"parameter-descriptor.d.ts","sourceRoot":"","sources":["../../src/parameter-descriptor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE5C;;OAEG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,uBAAuB;IAClE;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,+BACf,SAAQ,uBAAuB;CAAG;AAEpC;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,C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AAC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C"}
@@ -1,3 +1,6 @@
1
1
  import { Refkey } from "@alloy-js/core";
2
- export declare function ref(refkey: Refkey): () => string;
2
+ export interface RefOptions {
3
+ type?: boolean;
4
+ }
5
+ export declare function ref(refkey: Refkey, options?: RefOptions): () => string;
3
6
  //# sourceMappingURL=reference.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/symbols/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAcxB,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,MAAM,CAkGhD"}
1
+ {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/symbols/reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAKP,MAAM,gBAAgB,CAAC;AAcxB,MAAM,WAAW,UAAU;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AACD,wBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,MAAM,MAAM,CAuGtE"}
@@ -4,7 +4,7 @@ import { SourceFileContext } from "../components/SourceFile.js";
4
4
  import { usePrivateScope } from "../context/private-scope.js";
5
5
  import { isValidJSIdentifier } from "../utils.js";
6
6
  import { TSSymbolFlags } from "./ts-output-symbol.js";
7
- export function ref(refkey) {
7
+ export function ref(refkey, options) {
8
8
  const sourceFile = useContext(SourceFileContext);
9
9
  const resolveResult = resolve(refkey);
10
10
  const currentScope = useMemberScope();
@@ -65,7 +65,9 @@ export function ref(refkey) {
65
65
  } else if (targetLocation === "module") {
66
66
  const symbolPath = [...pathDown.slice(1).map(s => s.owner), targetDeclaration];
67
67
  const importSymbol = symbolPath[0];
68
- localSymbol = untrack(() => sourceFile.scope.addImport(importSymbol, pathDown[0]));
68
+ localSymbol = untrack(() => sourceFile.scope.addImport(importSymbol, pathDown[0], {
69
+ type: options?.type
70
+ }));
69
71
  }
70
72
  if (memberPath && memberPath.length > 0) {
71
73
  if (localSymbol) {
@@ -86,14 +88,18 @@ function buildMemberExpression(path) {
86
88
  memberExpr += base.name;
87
89
  path = path.slice(1);
88
90
  }
91
+ let prevNullish = base.tsFlags & TSSymbolFlags.Nullish;
89
92
  for (const sym of path) {
93
+ const optional = prevNullish ? "?" : "";
90
94
  if (sym.tsFlags & TSSymbolFlags.PrivateMember) {
91
- memberExpr += `.#${sym.name}`;
95
+ memberExpr += `${optional}.#${sym.name}`;
92
96
  } else if (isValidJSIdentifier(sym.name) && !(sym.tsFlags & TSSymbolFlags.TypeSymbol)) {
93
- memberExpr += `.${sym.name}`;
97
+ memberExpr += `${optional}.${sym.name}`;
94
98
  } else {
95
- memberExpr += `[${JSON.stringify(sym.name)}]`;
99
+ const joiner = sym.tsFlags & TSSymbolFlags.Nullish ? "?." : "";
100
+ memberExpr += `${joiner}[${JSON.stringify(sym.name)}]`;
96
101
  }
102
+ prevNullish = sym.tsFlags & TSSymbolFlags.Nullish;
97
103
  }
98
104
  return memberExpr;
99
105
  }
@@ -5,6 +5,9 @@ export interface ImportedSymbol {
5
5
  target: TSOutputSymbol;
6
6
  }
7
7
  export type ImportRecords = Map<TSModuleScope, Set<ImportedSymbol>>;
8
+ export interface AddImportOptions {
9
+ type?: boolean;
10
+ }
8
11
  export interface TSModuleScope extends OutputScope {
9
12
  kind: "module";
10
13
  exportedSymbols: Map<Refkey, TSOutputSymbol>;
@@ -13,7 +16,7 @@ export interface TSModuleScope extends OutputScope {
13
16
  */
14
17
  importedSymbols: Map<TSOutputSymbol, TSOutputSymbol>;
15
18
  importedModules: ImportRecords;
16
- addImport(symbol: TSOutputSymbol, module: TSModuleScope): TSOutputSymbol;
19
+ addImport(symbol: TSOutputSymbol, module: TSModuleScope, options?: AddImportOptions): TSOutputSymbol;
17
20
  }
18
21
  export declare function createTSModuleScope(binder: Binder, parent: OutputScope, path: string): TSModuleScope;
19
22
  //# sourceMappingURL=ts-module-scope.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ts-module-scope.d.ts","sourceRoot":"","sources":["../../../src/symbols/ts-module-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAU,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAEL,cAAc,EAEf,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,cAAc,CAAC;CACxB;AACD,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;AAEpE,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,IAAI,EAAE,QAAQ,CAAC;IACf,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7C;;OAEG;IACH,eAAe,EAAE,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IACrD,eAAe,EAAE,aAAa,CAAC;IAC/B,SAAS,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,aAAa,GAAG,cAAc,CAAC;CAC1E;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,GACX,aAAa,CAsCf"}
1
+ {"version":3,"file":"ts-module-scope.d.ts","sourceRoot":"","sources":["../../../src/symbols/ts-module-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAU,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAEL,cAAc,EAEf,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,cAAc,CAAC;CACxB;AACD,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,aAAa,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;AAEpE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,IAAI,EAAE,QAAQ,CAAC;IACf,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7C;;OAEG;IACH,eAAe,EAAE,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;IACrD,eAAe,EAAE,aAAa,CAAC;IAC/B,SAAS,CACP,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,gBAAgB,GACzB,cAAc,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,MAAM,GACX,aAAa,CA6Cf"}
@@ -8,9 +8,13 @@ export function createTSModuleScope(binder, parent, path) {
8
8
  exportedSymbols: new Map(),
9
9
  importedSymbols: new Map(),
10
10
  importedModules: new Map(),
11
- addImport(targetSymbol, targetModule) {
12
- if (this.importedSymbols.has(targetSymbol)) {
13
- return this.importedSymbols.get(targetSymbol);
11
+ addImport(targetSymbol, targetModule, options) {
12
+ const existing = this.importedSymbols.get(targetSymbol);
13
+ if (existing) {
14
+ if (!options?.type && existing.tsFlags & TSSymbolFlags.TypeSymbol) {
15
+ existing.tsFlags &= ~TSSymbolFlags.TypeSymbol;
16
+ }
17
+ return existing;
14
18
  }
15
19
  if (targetModule.kind !== "module") {
16
20
  throw new Error("Cannot import symbol that isn't in module scope");
@@ -25,6 +29,9 @@ export function createTSModuleScope(binder, parent, path) {
25
29
  refkey: refkey({}),
26
30
  tsFlags: TSSymbolFlags.LocalImportSymbol
27
31
  });
32
+ if (options?.type) {
33
+ localSymbol.tsFlags |= TSSymbolFlags.TypeSymbol;
34
+ }
28
35
  this.importedSymbols.set(targetSymbol, localSymbol);
29
36
  this.importedModules.get(targetModule).add({
30
37
  local: localSymbol,
@@ -7,7 +7,8 @@ export declare enum TSSymbolFlags {
7
7
  TypeSymbol = 2,
8
8
  ParameterSymbol = 4,
9
9
  PrivateMember = 8,
10
- PrivateMemberContainer = 16
10
+ PrivateMemberContainer = 16,
11
+ Nullish = 32
11
12
  }
12
13
  export interface TSOutputSymbol extends OutputSymbol {
13
14
  scope: TSOutputScope;
@@ -1 +1 @@
1
- {"version":3,"file":"ts-output-symbol.d.ts","sourceRoot":"","sources":["../../../src/symbols/ts-output-symbol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,MAAM,EAEP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAuB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1E,oBAAY,aAAa;IACvB,IAAI,IAAsB;IAC1B,iBAAiB,IAAc;IAC/B,UAAU,IAAqB;IAC/B,eAAe,IAAgB;IAC/B,aAAa,IAAkB;IAC/B,sBAAsB,KAAS;CAChC;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,aAAa,CAAC;IACvB,kBAAkB,CAAC,EAAE,aAAa,CAAC;IACnC,wBAAwB,CAAC,EAAE,aAAa,CAAC;CAC1C;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM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CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,cAAc,CAsC7E"}
@@ -9,6 +9,7 @@ export let TSSymbolFlags = /*#__PURE__*/function (TSSymbolFlags) {
9
9
  TSSymbolFlags[TSSymbolFlags["ParameterSymbol"] = 4] = "ParameterSymbol";
10
10
  TSSymbolFlags[TSSymbolFlags["PrivateMember"] = 8] = "PrivateMember";
11
11
  TSSymbolFlags[TSSymbolFlags["PrivateMemberContainer"] = 16] = "PrivateMemberContainer";
12
+ TSSymbolFlags[TSSymbolFlags["Nullish"] = 32] = "Nullish";
12
13
  return TSSymbolFlags;
13
14
  }({});
14
15
  export function createTSSymbol(options) {
@@ -385,15 +385,15 @@ it("renders a class with docs for the class and its members", () => {
385
385
  expect(res).toEqual(d`
386
386
  /**
387
387
  * This is a class documentation
388
- **/
388
+ */
389
389
  class Foo {
390
390
  /**
391
391
  * This is a field documentation
392
- **/
392
+ */
393
393
  bar = 123;
394
394
  /**
395
395
  * This is a method documentation
396
- **/
396
+ */
397
397
  baz() {
398
398
  return 123;
399
399
  }
@@ -431,7 +431,7 @@ it("renders a method with parameter docs", () => {
431
431
  * @param {string} b - Line 1 for b.
432
432
  * This is a long description that
433
433
  * should continue in the next line.
434
- **/
434
+ */
435
435
  bar(a: number, b: string): void {}
436
436
  }
437
437
  `);
@@ -24,7 +24,7 @@ it("renders an enum declaration with documentation", () => {
24
24
  expect(res).toEqual(d`
25
25
  /**
26
26
  * Color enumeration for the application
27
- **/
27
+ */
28
28
  enum Color {
29
29
  Red,
30
30
  Green,
@@ -63,25 +63,25 @@ it("renders an enum declaration with documented members", () => {
63
63
  expect(res).toEqual(d`
64
64
  /**
65
65
  * Represents cardinal directions. Used for navigation purposes
66
- **/
66
+ */
67
67
  enum Direction {
68
68
  /**
69
69
  * Bound to the north
70
- **/
70
+ */
71
71
  North = 0,
72
72
  /**
73
73
  * Bound to the East
74
74
  *
75
75
  * A second doc paragraph
76
- **/
76
+ */
77
77
  East = 1,
78
78
  /**
79
79
  * Opposite to North
80
- **/
80
+ */
81
81
  South = 2,
82
82
  /**
83
83
  * Going west!
84
- **/
84
+ */
85
85
  West = 3,
86
86
  }
87
87
  `);
@@ -19,7 +19,7 @@ it("renders a function declaration with documentation", () => {
19
19
  * A function that greets a person
20
20
  *
21
21
  * @param {string} name
22
- **/
22
+ */
23
23
  function greet(name: string): string {}
24
24
  `);
25
25
  });
@@ -44,7 +44,7 @@ it("With documented parameters", () => {
44
44
  *
45
45
  * @param {number} price
46
46
  * @param {number} [taxRate]
47
- **/
47
+ */
48
48
  export function calculateTotal(price: number, taxRate?: number): number {}
49
49
  `);
50
50
  });
@@ -86,6 +86,6 @@ it("renders a function with a reference", () => {
86
86
  * Creates a new user
87
87
  *
88
88
  * @param {User} user - The user object to create
89
- **/
89
+ */
90
90
  function createUser(user: User): void {}`);
91
91
  });
@@ -1 +1 @@
1
- {"version":3,"file":"imports.test.d.ts","sourceRoot":"","sources":["../../test/imports.test.tsx"],"names":[],"mappings":"AAOA,OAAO,wBAAwB,CAAC"}
1
+ {"version":3,"file":"imports.test.d.ts","sourceRoot":"","sources":["../../test/imports.test.tsx"],"names":[],"mappings":"AAQA,OAAO,wBAAwB,CAAC"}
@@ -1,9 +1,10 @@
1
1
  import { createComponent as _$createComponent, createIntrinsic as _$createIntrinsic } from "@alloy-js/core/jsx-runtime";
2
- import { Output, SourceDirectory, StatementList, refkey, render } from "@alloy-js/core";
2
+ import { List, Output, SourceDirectory, StatementList, refkey, render } from "@alloy-js/core";
3
3
  import "@alloy-js/core/testing";
4
- import { it } from "vitest";
4
+ import { describe, it } from "vitest";
5
5
  import * as ts from "../src/components/index.js";
6
6
  import { Reference } from "../src/components/Reference.js";
7
+ import { TypeRefContext } from "../src/context/type-ref-context.js";
7
8
  import { tsNameConflictResolver } from "../src/name-conflict-resolver.js";
8
9
  import { assertFileContents } from "./utils.js";
9
10
  it("works with default imports", () => {
@@ -431,4 +432,209 @@ it("handles conflicts with local declarations", () => {
431
432
  export function test() {}
432
433
  `
433
434
  });
435
+ });
436
+ describe("type imports", () => {
437
+ function mkTestFile(name) {
438
+ const TypeA = refkey("TypeA");
439
+ const TypeB = refkey("TypeB");
440
+ const ClassA = refkey("ClassA");
441
+ return {
442
+ component: _$createComponent(ts.SourceFile, {
443
+ path: "test1.ts",
444
+ get children() {
445
+ return [_$createComponent(ts.InterfaceDeclaration, {
446
+ "export": true,
447
+ name: "TypeA",
448
+ refkey: TypeA
449
+ }), _$createComponent(ts.InterfaceDeclaration, {
450
+ "export": true,
451
+ name: "TypeB",
452
+ refkey: TypeB
453
+ }), _$createComponent(ts.ClassDeclaration, {
454
+ "export": true,
455
+ name: "ClassA",
456
+ refkey: ClassA
457
+ })];
458
+ }
459
+ }),
460
+ TypeA,
461
+ TypeB,
462
+ ClassA
463
+ };
464
+ }
465
+ it("adds type keyword only to type imports", () => {
466
+ const {
467
+ component,
468
+ TypeA,
469
+ ClassA
470
+ } = mkTestFile("test1.ts");
471
+ const res = render(_$createComponent(Output, {
472
+ get children() {
473
+ return [component, _$createComponent(ts.SourceFile, {
474
+ path: "test2.ts",
475
+ get children() {
476
+ return _$createComponent(List, {
477
+ get children() {
478
+ return [["type A = ", _$createComponent(Reference, {
479
+ refkey: TypeA,
480
+ type: true
481
+ })], ["class B extends ", _$createComponent(Reference, {
482
+ refkey: ClassA
483
+ }), " ", "{}"]];
484
+ }
485
+ });
486
+ }
487
+ })];
488
+ }
489
+ }));
490
+ assertFileContents(res, {
491
+ "test2.ts": `
492
+ import { type TypeA, ClassA } from "./test1.js";
493
+
494
+ type A = TypeA
495
+ class B extends ClassA {}
496
+ `
497
+ });
498
+ });
499
+ it("add type keyword for whole import if all are types", () => {
500
+ const {
501
+ component,
502
+ TypeA,
503
+ TypeB
504
+ } = mkTestFile("test1.ts");
505
+ const res = render(_$createComponent(Output, {
506
+ get children() {
507
+ return [component, _$createComponent(ts.SourceFile, {
508
+ path: "test2.ts",
509
+ get children() {
510
+ return _$createComponent(List, {
511
+ get children() {
512
+ return [["type A = ", _$createComponent(Reference, {
513
+ refkey: TypeA,
514
+ type: true
515
+ })], ["type B = ", _$createComponent(Reference, {
516
+ refkey: TypeB,
517
+ type: true
518
+ })]];
519
+ }
520
+ });
521
+ }
522
+ })];
523
+ }
524
+ }));
525
+ assertFileContents(res, {
526
+ "test2.ts": `
527
+ import type { TypeA, TypeB } from "./test1.js";
528
+
529
+ type A = TypeA
530
+ type B = TypeB
531
+ `
532
+ });
533
+ });
534
+ it("reference same type multiple times", () => {
535
+ const {
536
+ component,
537
+ TypeA
538
+ } = mkTestFile("test1.ts");
539
+ const res = render(_$createComponent(Output, {
540
+ get children() {
541
+ return [component, _$createComponent(ts.SourceFile, {
542
+ path: "test2.ts",
543
+ get children() {
544
+ return _$createComponent(List, {
545
+ get children() {
546
+ return [["type A = ", _$createComponent(Reference, {
547
+ refkey: TypeA,
548
+ type: true
549
+ })], ["type B = ", _$createComponent(Reference, {
550
+ refkey: TypeA,
551
+ type: true
552
+ })]];
553
+ }
554
+ });
555
+ }
556
+ })];
557
+ }
558
+ }));
559
+ assertFileContents(res, {
560
+ "test2.ts": `
561
+ import type { TypeA } from "./test1.js";
562
+
563
+ type A = TypeA
564
+ type B = TypeA
565
+ `
566
+ });
567
+ });
568
+ it("same reference used as both type and non type doesn't include type", () => {
569
+ const {
570
+ component,
571
+ ClassA
572
+ } = mkTestFile("test1.ts");
573
+ const res = render(_$createComponent(Output, {
574
+ get children() {
575
+ return [component, _$createComponent(ts.SourceFile, {
576
+ path: "test2.ts",
577
+ get children() {
578
+ return _$createComponent(List, {
579
+ get children() {
580
+ return [["type A = ", _$createComponent(Reference, {
581
+ refkey: ClassA,
582
+ type: true
583
+ })], ["class B extends ", _$createComponent(Reference, {
584
+ refkey: ClassA
585
+ }), " ", "{}"]];
586
+ }
587
+ });
588
+ }
589
+ })];
590
+ }
591
+ }));
592
+ assertFileContents(res, {
593
+ "test2.ts": `
594
+ import { ClassA } from "./test1.js";
595
+
596
+ type A = ClassA
597
+ class B extends ClassA {}
598
+ `
599
+ });
600
+ });
601
+ it("infer if a type reference from the typescript context", () => {
602
+ const {
603
+ component,
604
+ TypeA
605
+ } = mkTestFile("test1.ts");
606
+ const res = render(_$createComponent(Output, {
607
+ get children() {
608
+ return [component, _$createComponent(ts.SourceFile, {
609
+ path: "test2.ts",
610
+ get children() {
611
+ return _$createComponent(TypeRefContext.Provider, {
612
+ value: {
613
+ type: true
614
+ },
615
+ get children() {
616
+ return _$createComponent(List, {
617
+ get children() {
618
+ return [["type A = ", _$createComponent(Reference, {
619
+ refkey: TypeA
620
+ })], ["type B = ", _$createComponent(Reference, {
621
+ refkey: TypeA
622
+ })]];
623
+ }
624
+ });
625
+ }
626
+ });
627
+ }
628
+ })];
629
+ }
630
+ }));
631
+ assertFileContents(res, {
632
+ "test2.ts": `
633
+ import type { TypeA } from "./test1.js";
634
+
635
+ type A = TypeA
636
+ type B = TypeA
637
+ `
638
+ });
639
+ });
434
640
  });
@@ -25,7 +25,7 @@ it("renders an interface declaration with documentation", () => {
25
25
  expect(res).toEqual(d`
26
26
  /**
27
27
  * Interface representing a person
28
- **/
28
+ */
29
29
  interface Person {
30
30
  name: string;
31
31
  age: number;
@@ -53,7 +53,7 @@ it("renders an interface declaration with docs from a string array with single e
53
53
  expect(res).toEqual(d`
54
54
  /**
55
55
  * Interface representing a person
56
- **/
56
+ */
57
57
  interface Person {
58
58
  name: string;
59
59
  age: number;
@@ -83,7 +83,7 @@ it("renders an interface declaration with docs from a string array", () => {
83
83
  * Interface representing a person
84
84
  *
85
85
  * This should be another paragraph
86
- **/
86
+ */
87
87
  interface Person {
88
88
  name: string;
89
89
  age: number;
@@ -118,15 +118,15 @@ it("renders an interface declaration with documented properties", () => {
118
118
  expect(res).toEqual(d`
119
119
  /**
120
120
  * Standard API response format
121
- **/
121
+ */
122
122
  export interface APIResponse {
123
123
  /**
124
124
  * Wether or not the request completed successfully
125
- **/
125
+ */
126
126
  success: boolean;
127
127
  /**
128
128
  * the response payload
129
- **/
129
+ */
130
130
  data: unknown;
131
131
  error?: string;
132
132
  }
@@ -160,17 +160,17 @@ it("renders an interface declaration with array documented properties ", () => {
160
160
  expect(res).toEqual(d`
161
161
  /**
162
162
  * Standard API response format
163
- **/
163
+ */
164
164
  export interface APIResponse {
165
165
  /**
166
166
  * Wether or not the request completed successfully
167
167
  *
168
168
  * This is another paragraph
169
- **/
169
+ */
170
170
  success: boolean;
171
171
  /**
172
172
  * the response payload
173
- **/
173
+ */
174
174
  data: unknown;
175
175
  error?: string;
176
176
  }
@@ -19,7 +19,7 @@ describe("JSDoc", () => {
19
19
  * Hello!
20
20
  *
21
21
  * This is another line
22
- **/
22
+ */
23
23
  `, {
24
24
  printWidth: 40
25
25
  });
@@ -47,7 +47,7 @@ describe("Prose", () => {
47
47
  * This is another paragraph. There
48
48
  * should be a couple breaks in front of
49
49
  * it.
50
- **/
50
+ */
51
51
  `, {
52
52
  printWidth: 40
53
53
  });
@@ -71,7 +71,7 @@ describe("JSDocExample", () => {
71
71
  *
72
72
  * @example
73
73
  * console.log("Hello world!")
74
- **/
74
+ */
75
75
  `, {
76
76
  printWidth: 40
77
77
  });
@@ -97,7 +97,7 @@ describe("JSDocExample", () => {
97
97
  * \`\`\`ts
98
98
  * console.log("Hello world!")
99
99
  * \`\`\`
100
- **/
100
+ */
101
101
  `, {
102
102
  printWidth: 40
103
103
  });
@@ -126,7 +126,7 @@ describe("JSDocExample", () => {
126
126
  * @example
127
127
  * // make a function call.
128
128
  * console.log(arg1, arg2);
129
- **/
129
+ */
130
130
  `, {
131
131
  printWidth: 40
132
132
  });