@alloy-js/typescript 0.21.0-dev.0 → 0.21.0-dev.4
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.
- package/dist/src/components/ClassDeclaration.d.ts +4 -4
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +6 -11
- package/dist/src/components/ClassDeclaration.js.map +1 -1
- package/dist/src/components/Declaration.d.ts +27 -24
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +12 -8
- package/dist/src/components/Declaration.js.map +1 -1
- package/dist/src/components/EnumDeclaration.d.ts +2 -2
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
- package/dist/src/components/EnumDeclaration.js +3 -3
- package/dist/src/components/EnumDeclaration.js.map +1 -1
- package/dist/src/components/EnumMember.d.ts +2 -2
- package/dist/src/components/EnumMember.d.ts.map +1 -1
- package/dist/src/components/EnumMember.js +8 -10
- package/dist/src/components/EnumMember.js.map +1 -1
- package/dist/src/components/FunctionBase.d.ts.map +1 -1
- package/dist/src/components/FunctionBase.js +3 -2
- package/dist/src/components/FunctionBase.js.map +1 -1
- package/dist/src/components/FunctionDeclaration.d.ts +2 -2
- package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
- package/dist/src/components/FunctionDeclaration.js +0 -3
- package/dist/src/components/FunctionDeclaration.js.map +1 -1
- package/dist/src/components/Interface.d.ts +13 -8
- package/dist/src/components/Interface.d.ts.map +1 -1
- package/dist/src/components/Interface.js +46 -43
- package/dist/src/components/Interface.js.map +1 -1
- package/dist/src/components/InterfaceMethod.d.ts +2 -2
- package/dist/src/components/InterfaceMethod.d.ts.map +1 -1
- package/dist/src/components/InterfaceMethod.js +3 -8
- package/dist/src/components/InterfaceMethod.js.map +1 -1
- package/dist/src/components/MemberDeclaration.d.ts +10 -13
- package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
- package/dist/src/components/MemberDeclaration.js +4 -5
- package/dist/src/components/MemberDeclaration.js.map +1 -1
- package/dist/src/components/TypeDeclaration.d.ts +2 -2
- package/dist/src/components/TypeDeclaration.d.ts.map +1 -1
- package/dist/src/components/TypeDeclaration.js.map +1 -1
- package/dist/src/components/VarDeclaration.d.ts +2 -2
- package/dist/src/components/VarDeclaration.d.ts.map +1 -1
- package/dist/src/components/VarDeclaration.js +3 -3
- package/dist/src/components/VarDeclaration.js.map +1 -1
- package/dist/src/parameter-descriptor.d.ts +3 -3
- package/dist/src/parameter-descriptor.d.ts.map +1 -1
- package/dist/src/symbols/index.d.ts +9 -9
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js.map +1 -1
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +2 -2
- package/dist/src/symbols/reference.js.map +1 -1
- package/dist/src/symbols/ts-output-symbol.d.ts +2 -2
- package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/ts-output-symbol.js.map +1 -1
- package/dist/test/class.test.js +29 -1
- package/dist/test/class.test.js.map +1 -1
- package/dist/test/enum.test.js +30 -1
- package/dist/test/enum.test.js.map +1 -1
- package/dist/test/function-declaration.test.js +18 -1
- package/dist/test/function-declaration.test.js.map +1 -1
- package/dist/test/imports.test.js +3 -2
- package/dist/test/imports.test.js.map +1 -1
- package/dist/test/interface.test.d.ts.map +1 -1
- package/dist/test/interface.test.js +25 -1
- package/dist/test/interface.test.js.map +1 -1
- package/dist/test/reference.test.js +14 -0
- package/dist/test/reference.test.js.map +1 -1
- package/dist/test/var-declaration.test.d.ts.map +1 -1
- package/dist/test/var-declaration.test.js +18 -1
- package/dist/test/var-declaration.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/components/ClassDeclaration.tsx +9 -12
- package/src/components/Declaration.tsx +39 -32
- package/src/components/EnumDeclaration.tsx +4 -4
- package/src/components/EnumMember.tsx +8 -13
- package/src/components/FunctionBase.tsx +7 -9
- package/src/components/FunctionDeclaration.tsx +3 -3
- package/src/components/Interface.tsx +57 -51
- package/src/components/InterfaceMethod.tsx +12 -7
- package/src/components/MemberDeclaration.tsx +20 -24
- package/src/components/TypeDeclaration.tsx +2 -2
- package/src/components/VarDeclaration.tsx +4 -4
- package/src/parameter-descriptor.ts +3 -3
- package/src/symbols/index.ts +12 -9
- package/src/symbols/reference.tsx +3 -1
- package/src/symbols/ts-output-symbol.ts +2 -1
- package/temp/api.json +756 -508
- package/test/class.test.tsx +19 -1
- package/test/enum.test.tsx +21 -1
- package/test/function-declaration.test.tsx +15 -0
- package/test/imports.test.tsx +2 -1
- package/test/interface.test.tsx +29 -0
- package/test/reference.test.tsx +12 -2
- package/test/var-declaration.test.tsx +17 -1
|
@@ -8,11 +8,11 @@ import {
|
|
|
8
8
|
import { useTSNamePolicy } from "../name-policy.js";
|
|
9
9
|
import { createValueSymbol } from "../symbols/index.js";
|
|
10
10
|
import { TSSymbolFlags } from "../symbols/ts-output-symbol.js";
|
|
11
|
-
import {
|
|
11
|
+
import { CommonDeclarationProps } from "./Declaration.js";
|
|
12
12
|
import { JSDoc } from "./JSDoc.jsx";
|
|
13
13
|
import { TypeRefContext } from "./TypeRefContext.jsx";
|
|
14
14
|
|
|
15
|
-
export interface VarDeclarationProps extends
|
|
15
|
+
export interface VarDeclarationProps extends CommonDeclarationProps {
|
|
16
16
|
const?: boolean;
|
|
17
17
|
let?: boolean;
|
|
18
18
|
var?: boolean;
|
|
@@ -24,14 +24,14 @@ export interface VarDeclarationProps extends BaseDeclarationProps {
|
|
|
24
24
|
export function VarDeclaration(props: VarDeclarationProps) {
|
|
25
25
|
const TypeSymbolSlot = createSymbolSlot();
|
|
26
26
|
const ValueTypeSymbolSlot = createSymbolSlot();
|
|
27
|
-
const
|
|
28
|
-
const sym = createValueSymbol(name, {
|
|
27
|
+
const sym = createValueSymbol(props.name, {
|
|
29
28
|
refkeys: props.refkey,
|
|
30
29
|
default: props.default,
|
|
31
30
|
export: props.export,
|
|
32
31
|
metadata: props.metadata,
|
|
33
32
|
tsFlags: props.nullish ? TSSymbolFlags.Nullish : TSSymbolFlags.None,
|
|
34
33
|
type: props.type ? TypeSymbolSlot.firstSymbol : undefined,
|
|
34
|
+
namePolicy: useTSNamePolicy().for("variable"),
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
if (!props.type) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Children, Refkey } from "@alloy-js/core";
|
|
1
|
+
import type { Children, Namekey, Refkey } from "@alloy-js/core";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Common properties for ParameterDescriptor and FunctionTypeParameterDescriptor.
|
|
@@ -7,7 +7,7 @@ export interface ParameterDescriptorBase {
|
|
|
7
7
|
/**
|
|
8
8
|
* The name of the parameter.
|
|
9
9
|
*/
|
|
10
|
-
readonly name: string;
|
|
10
|
+
readonly name: string | Namekey;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* The type of the parameter.
|
|
@@ -75,7 +75,7 @@ export interface TypeParameterDescriptor {
|
|
|
75
75
|
/**
|
|
76
76
|
* The name of the type parameter.
|
|
77
77
|
*/
|
|
78
|
-
readonly name: string;
|
|
78
|
+
readonly name: string | Namekey;
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* The extends constraint for the type parameter.
|
package/src/symbols/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OutputScopeOptions } from "@alloy-js/core";
|
|
1
|
+
import { Namekey, OutputScopeOptions } from "@alloy-js/core";
|
|
2
2
|
import { useLexicalScope, useMemberOwner } from "../utils.js";
|
|
3
3
|
import { useTSScope } from "./scopes.js";
|
|
4
4
|
import { TSLexicalScope } from "./ts-lexical-scope.js";
|
|
@@ -14,7 +14,7 @@ export * from "./ts-output-symbol.js";
|
|
|
14
14
|
export * from "./ts-package-scope.js";
|
|
15
15
|
|
|
16
16
|
export function createTypeAndValueSymbol(
|
|
17
|
-
name: string,
|
|
17
|
+
name: string | Namekey,
|
|
18
18
|
options: CreateTsSymbolOptions = {},
|
|
19
19
|
) {
|
|
20
20
|
const scope = useLexicalScope();
|
|
@@ -22,7 +22,10 @@ export function createTypeAndValueSymbol(
|
|
|
22
22
|
return new TSOutputSymbol(name, spaces, options);
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
export function createTypeSymbol(
|
|
25
|
+
export function createTypeSymbol(
|
|
26
|
+
name: string | Namekey,
|
|
27
|
+
options: CreateTsSymbolOptions,
|
|
28
|
+
) {
|
|
26
29
|
const scope = useLexicalScope();
|
|
27
30
|
if (scope && !scope.types) {
|
|
28
31
|
throw new Error(
|
|
@@ -34,7 +37,7 @@ export function createTypeSymbol(name: string, options: CreateTsSymbolOptions) {
|
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
export function createValueSymbol(
|
|
37
|
-
name: string,
|
|
40
|
+
name: string | Namekey,
|
|
38
41
|
options: CreateTsSymbolOptions = {},
|
|
39
42
|
) {
|
|
40
43
|
const scope = useLexicalScope();
|
|
@@ -54,7 +57,7 @@ export function createTransientValueSymbol() {
|
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
export function createStaticMemberSymbol(
|
|
57
|
-
name: string,
|
|
60
|
+
name: string | Namekey,
|
|
58
61
|
options: CreateTsSymbolOptions = {},
|
|
59
62
|
) {
|
|
60
63
|
const owner = useMemberOwner();
|
|
@@ -62,7 +65,7 @@ export function createStaticMemberSymbol(
|
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
export function createInstanceMemberSymbol(
|
|
65
|
-
name: string,
|
|
68
|
+
name: string | Namekey,
|
|
66
69
|
options: CreateTsSymbolOptions = {},
|
|
67
70
|
) {
|
|
68
71
|
const owner = useMemberOwner();
|
|
@@ -70,7 +73,7 @@ export function createInstanceMemberSymbol(
|
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
export function createPrivateStaticMemberSymbol(
|
|
73
|
-
name: string,
|
|
76
|
+
name: string | Namekey,
|
|
74
77
|
options: CreateTsSymbolOptions = {},
|
|
75
78
|
) {
|
|
76
79
|
const owner = useMemberOwner();
|
|
@@ -78,7 +81,7 @@ export function createPrivateStaticMemberSymbol(
|
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
export function createPrivateInstanceMemberSymbol(
|
|
81
|
-
name: string,
|
|
84
|
+
name: string | Namekey,
|
|
82
85
|
options: CreateTsSymbolOptions = {},
|
|
83
86
|
) {
|
|
84
87
|
const owner = useMemberOwner();
|
|
@@ -86,7 +89,7 @@ export function createPrivateInstanceMemberSymbol(
|
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
export function createMemberSymbol(
|
|
89
|
-
name: string,
|
|
92
|
+
name: string | Namekey,
|
|
90
93
|
locationOptions: { jsPrivate?: boolean; static?: boolean },
|
|
91
94
|
options: CreateTsSymbolOptions = {},
|
|
92
95
|
) {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
memo,
|
|
6
6
|
Refkey,
|
|
7
7
|
resolve,
|
|
8
|
+
unresolvedRefkey,
|
|
8
9
|
untrack,
|
|
9
10
|
useContext,
|
|
10
11
|
} from "@alloy-js/core";
|
|
@@ -20,6 +21,7 @@ import { TSPackageScope } from "./ts-package-scope.js";
|
|
|
20
21
|
export interface RefOptions {
|
|
21
22
|
type?: boolean;
|
|
22
23
|
}
|
|
24
|
+
|
|
23
25
|
export function ref(
|
|
24
26
|
refkey: Refkey,
|
|
25
27
|
options?: RefOptions,
|
|
@@ -32,7 +34,7 @@ export function ref(
|
|
|
32
34
|
|
|
33
35
|
return memo(() => {
|
|
34
36
|
if (resolveResult.value === undefined) {
|
|
35
|
-
return [
|
|
37
|
+
return [unresolvedRefkey(refkey), undefined];
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
const { symbol, pathDown, memberPath, lexicalDeclaration, commonScope } =
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Namekey,
|
|
2
3
|
OutputSpace,
|
|
3
4
|
OutputSymbol,
|
|
4
5
|
OutputSymbolOptions,
|
|
@@ -36,7 +37,7 @@ export class TSOutputSymbol extends OutputSymbol {
|
|
|
36
37
|
] as const;
|
|
37
38
|
|
|
38
39
|
constructor(
|
|
39
|
-
name: string,
|
|
40
|
+
name: string | Namekey,
|
|
40
41
|
spaces: OutputSpace[] | OutputSpace | undefined,
|
|
41
42
|
options: CreateTsSymbolOptions = {},
|
|
42
43
|
) {
|