@alloy-js/typescript 0.20.0-dev.0 → 0.20.0-dev.2
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/builtins/index.js +2 -1
- package/dist/src/builtins/index.js.map +1 -0
- package/dist/src/builtins/node.d.ts +1 -1
- package/dist/src/builtins/node.js +2 -1
- package/dist/src/builtins/node.js.map +1 -0
- package/dist/src/components/ArrayExpression.js +2 -1
- package/dist/src/components/ArrayExpression.js.map +1 -0
- package/dist/src/components/ArrowFunction.d.ts.map +1 -1
- package/dist/src/components/ArrowFunction.js +9 -14
- package/dist/src/components/ArrowFunction.js.map +1 -0
- package/dist/src/components/BarrelFile.js +2 -1
- package/dist/src/components/BarrelFile.js.map +1 -0
- package/dist/src/components/BlockScope.d.ts.map +1 -1
- package/dist/src/components/BlockScope.js +5 -3
- package/dist/src/components/BlockScope.js.map +1 -0
- package/dist/src/components/CallSignature.js +2 -1
- package/dist/src/components/CallSignature.js.map +1 -0
- package/dist/src/components/ClassDeclaration.d.ts.map +1 -1
- package/dist/src/components/ClassDeclaration.js +22 -31
- package/dist/src/components/ClassDeclaration.js.map +1 -0
- package/dist/src/components/CommaList.js +2 -1
- package/dist/src/components/CommaList.js.map +1 -0
- package/dist/src/components/Declaration.d.ts +2 -9
- package/dist/src/components/Declaration.d.ts.map +1 -1
- package/dist/src/components/Declaration.js +22 -44
- package/dist/src/components/Declaration.js.map +1 -0
- package/dist/src/components/EnumDeclaration.d.ts.map +1 -1
- package/dist/src/components/EnumDeclaration.js +7 -10
- package/dist/src/components/EnumDeclaration.js.map +1 -0
- package/dist/src/components/EnumMember.d.ts.map +1 -1
- package/dist/src/components/EnumMember.js +5 -5
- package/dist/src/components/EnumMember.js.map +1 -0
- package/dist/src/components/ExportStatement.d.ts.map +1 -1
- package/dist/src/components/ExportStatement.js +4 -2
- package/dist/src/components/ExportStatement.js.map +1 -0
- package/dist/src/components/FunctionBase.d.ts.map +1 -1
- package/dist/src/components/FunctionBase.js +17 -13
- package/dist/src/components/FunctionBase.js.map +1 -0
- package/dist/src/components/FunctionCallExpression.js +2 -1
- package/dist/src/components/FunctionCallExpression.js.map +1 -0
- package/dist/src/components/FunctionDeclaration.d.ts.map +1 -1
- package/dist/src/components/FunctionDeclaration.js +5 -4
- package/dist/src/components/FunctionDeclaration.js.map +1 -0
- package/dist/src/components/FunctionExpression.d.ts.map +1 -1
- package/dist/src/components/FunctionExpression.js +9 -14
- package/dist/src/components/FunctionExpression.js.map +1 -0
- package/dist/src/components/FunctionType.d.ts.map +1 -1
- package/dist/src/components/FunctionType.js +5 -4
- package/dist/src/components/FunctionType.js.map +1 -0
- package/dist/src/components/IfStatement.d.ts.map +1 -1
- package/dist/src/components/IfStatement.js +4 -2
- package/dist/src/components/IfStatement.js.map +1 -0
- package/dist/src/components/ImportStatement.d.ts.map +1 -1
- package/dist/src/components/ImportStatement.js +5 -5
- package/dist/src/components/ImportStatement.js.map +1 -0
- package/dist/src/components/Interface.d.ts.map +1 -1
- package/dist/src/components/Interface.js +16 -14
- package/dist/src/components/Interface.js.map +1 -0
- package/dist/src/components/InterfaceMethod.d.ts.map +1 -1
- package/dist/src/components/InterfaceMethod.js +6 -4
- package/dist/src/components/InterfaceMethod.js.map +1 -0
- package/dist/src/components/JSDoc.js +2 -1
- package/dist/src/components/JSDoc.js.map +1 -0
- package/dist/src/components/JSDocComment.js +2 -1
- package/dist/src/components/JSDocComment.js.map +1 -0
- package/dist/src/components/JSDocExample.js +2 -1
- package/dist/src/components/JSDocExample.js.map +1 -0
- package/dist/src/components/JSDocParam.js +2 -1
- package/dist/src/components/JSDocParam.js.map +1 -0
- package/dist/src/components/LexicalScope.d.ts +12 -0
- package/dist/src/components/LexicalScope.d.ts.map +1 -0
- package/dist/src/components/LexicalScope.js +25 -0
- package/dist/src/components/LexicalScope.js.map +1 -0
- package/dist/src/components/MemberDeclaration.d.ts +1 -10
- package/dist/src/components/MemberDeclaration.d.ts.map +1 -1
- package/dist/src/components/MemberDeclaration.js +5 -8
- package/dist/src/components/MemberDeclaration.js.map +1 -0
- package/dist/src/components/MemberExpression.d.ts.map +1 -1
- package/dist/src/components/MemberExpression.js +15 -6
- package/dist/src/components/MemberExpression.js.map +1 -0
- package/dist/src/components/MemberScope.d.ts +15 -0
- package/dist/src/components/MemberScope.d.ts.map +1 -0
- package/dist/src/components/MemberScope.js +18 -0
- package/dist/src/components/MemberScope.js.map +1 -0
- package/dist/src/components/NewExpression.d.ts.map +1 -1
- package/dist/src/components/NewExpression.js +7 -6
- package/dist/src/components/NewExpression.js.map +1 -0
- package/dist/src/components/ObjectExpression.d.ts.map +1 -1
- package/dist/src/components/ObjectExpression.js +12 -15
- package/dist/src/components/ObjectExpression.js.map +1 -0
- package/dist/src/components/PackageDirectory.js +2 -1
- package/dist/src/components/PackageDirectory.js.map +1 -0
- package/dist/src/components/PackageJson.js +2 -1
- package/dist/src/components/PackageJson.js.map +1 -0
- package/dist/src/components/PropertyName.js +3 -3
- package/dist/src/components/PropertyName.js.map +1 -0
- package/dist/src/components/Reference.js +2 -1
- package/dist/src/components/Reference.js.map +1 -0
- package/dist/src/components/SingleLineCommentBlock.js +2 -1
- package/dist/src/components/SingleLineCommentBlock.js.map +1 -0
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +5 -3
- package/dist/src/components/SourceFile.js.map +1 -0
- package/dist/src/components/SwitchStatement.js +2 -1
- package/dist/src/components/SwitchStatement.js.map +1 -0
- package/dist/src/components/TsConfigJson.js +2 -1
- package/dist/src/components/TsConfigJson.js.map +1 -0
- package/dist/src/components/TypeDeclaration.js +2 -1
- package/dist/src/components/TypeDeclaration.js.map +1 -0
- package/dist/src/components/TypeRefContext.js +2 -1
- package/dist/src/components/TypeRefContext.js.map +1 -0
- package/dist/src/components/ValueExpression.js +2 -1
- package/dist/src/components/ValueExpression.js.map +1 -0
- package/dist/src/components/VarDeclaration.d.ts.map +1 -1
- package/dist/src/components/VarDeclaration.js +16 -27
- package/dist/src/components/VarDeclaration.js.map +1 -0
- package/dist/src/components/index.js +2 -1
- package/dist/src/components/index.js.map +1 -0
- package/dist/src/components/interface/expression.test.js +2 -1
- package/dist/src/components/interface/expression.test.js.map +1 -0
- package/dist/src/components/stc/index.js +2 -1
- package/dist/src/components/stc/index.js.map +1 -0
- package/dist/src/context/index.d.ts +1 -1
- package/dist/src/context/index.d.ts.map +1 -1
- package/dist/src/context/index.js +2 -1
- package/dist/src/context/index.js.map +1 -0
- package/dist/src/context/type-ref-context.js +2 -1
- package/dist/src/context/type-ref-context.js.map +1 -0
- package/dist/src/create-package.d.ts.map +1 -1
- package/dist/src/create-package.js +13 -34
- package/dist/src/create-package.js.map +1 -0
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -0
- package/dist/src/name-conflict-resolver.js +2 -1
- package/dist/src/name-conflict-resolver.js.map +1 -0
- package/dist/src/name-policy.js +2 -1
- package/dist/src/name-policy.js.map +1 -0
- package/dist/src/parameter-descriptor.js +2 -1
- package/dist/src/parameter-descriptor.js.map +1 -0
- package/dist/src/source-directory-data.js +2 -1
- package/dist/src/source-directory-data.js.map +1 -0
- package/dist/src/symbols/index.d.ts +19 -0
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js +73 -1
- package/dist/src/symbols/index.js.map +1 -0
- package/dist/src/symbols/reference.d.ts +2 -2
- package/dist/src/symbols/reference.d.ts.map +1 -1
- package/dist/src/symbols/reference.js +69 -70
- package/dist/src/symbols/reference.js.map +1 -0
- package/dist/src/symbols/scopes.d.ts +5 -8
- package/dist/src/symbols/scopes.d.ts.map +1 -1
- package/dist/src/symbols/scopes.js +28 -1
- package/dist/src/symbols/scopes.js.map +1 -0
- package/dist/src/symbols/ts-lexical-scope.d.ts +12 -0
- package/dist/src/symbols/ts-lexical-scope.d.ts.map +1 -0
- package/dist/src/symbols/ts-lexical-scope.js +17 -0
- package/dist/src/symbols/ts-lexical-scope.js.map +1 -0
- package/dist/src/symbols/ts-member-scope.d.ts +12 -4
- package/dist/src/symbols/ts-member-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-member-scope.js +17 -7
- package/dist/src/symbols/ts-member-scope.js.map +1 -0
- package/dist/src/symbols/ts-module-scope.d.ts +8 -3
- package/dist/src/symbols/ts-module-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-module-scope.js +31 -19
- package/dist/src/symbols/ts-module-scope.js.map +1 -0
- package/dist/src/symbols/ts-output-symbol.d.ts +19 -18
- package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/ts-output-symbol.js +62 -38
- package/dist/src/symbols/ts-output-symbol.js.map +1 -0
- package/dist/src/symbols/ts-package-scope.d.ts +1 -1
- package/dist/src/symbols/ts-package-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-package-scope.js +6 -6
- package/dist/src/symbols/ts-package-scope.js.map +1 -0
- package/dist/src/utils.d.ts +4 -0
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +25 -2
- package/dist/src/utils.js.map +1 -0
- package/dist/test/array.test.js +2 -1
- package/dist/test/array.test.js.map +1 -0
- package/dist/test/arrow-function.test.js +2 -1
- package/dist/test/arrow-function.test.js.map +1 -0
- package/dist/test/barrel.test.js +26 -17
- package/dist/test/barrel.test.js.map +1 -0
- package/dist/test/basic.test.js +22 -26
- package/dist/test/basic.test.js.map +1 -0
- package/dist/test/block-scope.test.js +2 -1
- package/dist/test/block-scope.test.js.map +1 -0
- package/dist/test/class.test.js +24 -18
- package/dist/test/class.test.js.map +1 -0
- package/dist/test/enum-jsdoc.test.js +2 -1
- package/dist/test/enum-jsdoc.test.js.map +1 -0
- package/dist/test/enum.test.js +2 -1
- package/dist/test/enum.test.js.map +1 -0
- package/dist/test/externals.test.js +12 -51
- package/dist/test/externals.test.js.map +1 -0
- package/dist/test/function-call-expression.test.js +9 -8
- package/dist/test/function-call-expression.test.js.map +1 -0
- package/dist/test/function-declaration-jsdoc.test.js +2 -1
- package/dist/test/function-declaration-jsdoc.test.js.map +1 -0
- package/dist/test/function-declaration.test.js +2 -1
- package/dist/test/function-declaration.test.js.map +1 -0
- package/dist/test/function-expression.test.js +2 -1
- package/dist/test/function-expression.test.js.map +1 -0
- package/dist/test/function-type.test.js +2 -1
- package/dist/test/function-type.test.js.map +1 -0
- package/dist/test/if-statement.test.js +2 -1
- package/dist/test/if-statement.test.js.map +1 -0
- package/dist/test/imports.test.d.ts.map +1 -1
- package/dist/test/imports.test.js +62 -60
- package/dist/test/imports.test.js.map +1 -0
- package/dist/test/interface-jsdoc.test.js +2 -1
- package/dist/test/interface-jsdoc.test.js.map +1 -0
- package/dist/test/interface.test.js +2 -1
- package/dist/test/interface.test.js.map +1 -0
- package/dist/test/jscomment.test.js +2 -1
- package/dist/test/jscomment.test.js.map +1 -0
- package/dist/test/jsdoc.test.js +2 -1
- package/dist/test/jsdoc.test.js.map +1 -0
- package/dist/test/jsdocparam.test.js +2 -1
- package/dist/test/jsdocparam.test.js.map +1 -0
- package/dist/test/member-expression.test.js +8 -7
- package/dist/test/member-expression.test.js.map +1 -0
- package/dist/test/name-conflict.test.js +5 -7
- package/dist/test/name-conflict.test.js.map +1 -0
- package/dist/test/name-policy.test.js +9 -13
- package/dist/test/name-policy.test.js.map +1 -0
- package/dist/test/new-expression.test.js +6 -7
- package/dist/test/new-expression.test.js.map +1 -0
- package/dist/test/object.test.js +2 -1
- package/dist/test/object.test.js.map +1 -0
- package/dist/test/package-external.test.js +71 -66
- package/dist/test/package-external.test.js.map +1 -0
- package/dist/test/package-json.test.js +8 -10
- package/dist/test/package-json.test.js.map +1 -0
- package/dist/test/package.test.js +12 -12
- package/dist/test/package.test.js.map +1 -0
- package/dist/test/reference.test.js +10 -12
- package/dist/test/reference.test.js.map +1 -0
- package/dist/test/source-file.test.js +7 -10
- package/dist/test/source-file.test.js.map +1 -0
- package/dist/test/switch-statement.test.js +2 -1
- package/dist/test/switch-statement.test.js.map +1 -0
- package/dist/test/utils.js +6 -2
- package/dist/test/utils.js.map +1 -0
- package/dist/test/value-expression.test.js +2 -1
- package/dist/test/value-expression.test.js.map +1 -0
- package/dist/test/values.test.d.ts.map +1 -1
- package/dist/test/values.test.js +11 -8
- package/dist/test/values.test.js.map +1 -0
- package/dist/test/var-declaration-jsdoc.test.js +2 -1
- package/dist/test/var-declaration-jsdoc.test.js.map +1 -0
- package/dist/test/var-declaration.test.d.ts.map +1 -1
- package/dist/test/var-declaration.test.js +21 -12
- package/dist/test/var-declaration.test.js.map +1 -0
- package/dist/test/vitest.setup.js +2 -1
- package/dist/test/vitest.setup.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/components/ArrowFunction.tsx +7 -10
- package/src/components/BlockScope.tsx +3 -3
- package/src/components/ClassDeclaration.tsx +19 -44
- package/src/components/Declaration.tsx +22 -53
- package/src/components/EnumDeclaration.tsx +4 -11
- package/src/components/EnumMember.tsx +3 -3
- package/src/components/ExportStatement.tsx +2 -1
- package/src/components/FunctionBase.tsx +33 -28
- package/src/components/FunctionDeclaration.tsx +3 -3
- package/src/components/FunctionExpression.tsx +7 -10
- package/src/components/FunctionType.tsx +3 -3
- package/src/components/IfStatement.tsx +2 -1
- package/src/components/ImportStatement.tsx +4 -8
- package/src/components/Interface.tsx +15 -22
- package/src/components/InterfaceMethod.tsx +4 -4
- package/src/components/LexicalScope.tsx +27 -0
- package/src/components/MemberDeclaration.tsx +8 -20
- package/src/components/MemberExpression.tsx +25 -5
- package/src/components/MemberScope.tsx +29 -0
- package/src/components/NewExpression.tsx +4 -5
- package/src/components/ObjectExpression.tsx +11 -18
- package/src/components/PropertyName.tsx +2 -2
- package/src/components/SourceFile.tsx +3 -1
- package/src/components/VarDeclaration.tsx +14 -28
- package/src/context/index.ts +1 -1
- package/src/create-package.ts +10 -39
- package/src/symbols/index.ts +118 -0
- package/src/symbols/reference.tsx +163 -0
- package/src/symbols/scopes.ts +38 -13
- package/src/symbols/ts-lexical-scope.ts +18 -0
- package/src/symbols/ts-member-scope.ts +23 -6
- package/src/symbols/ts-module-scope.ts +31 -21
- package/src/symbols/ts-output-symbol.ts +111 -49
- package/src/symbols/ts-package-scope.ts +5 -5
- package/src/utils.ts +38 -1
- package/temp/api.json +1641 -713
- package/test/barrel.test.tsx +24 -18
- package/test/basic.test.tsx +20 -29
- package/test/class.test.tsx +28 -18
- package/test/externals.test.tsx +10 -57
- package/test/function-call-expression.test.tsx +6 -7
- package/test/imports.test.tsx +57 -74
- package/test/member-expression.test.tsx +5 -13
- package/test/name-conflict.test.tsx +4 -7
- package/test/name-policy.test.tsx +7 -15
- package/test/new-expression.test.tsx +4 -7
- package/test/package-external.test.tsx +69 -73
- package/test/package-json.test.tsx +6 -11
- package/test/package.test.tsx +8 -11
- package/test/reference.test.tsx +10 -15
- package/test/source-file.test.tsx +5 -11
- package/test/utils.tsx +1 -1
- package/test/values.test.tsx +8 -8
- package/test/var-declaration.test.tsx +19 -20
- package/tsdoc-metadata.json +1 -1
- package/dist/src/context/private-scope.d.ts +0 -18
- package/dist/src/context/private-scope.d.ts.map +0 -1
- package/dist/src/context/private-scope.js +0 -8
- package/src/context/private-scope.ts +0 -23
- package/src/symbols/reference.ts +0 -197
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
OutputSpace,
|
|
3
3
|
OutputSymbol,
|
|
4
4
|
OutputSymbolOptions,
|
|
5
5
|
track,
|
|
6
6
|
TrackOpTypes,
|
|
7
7
|
trigger,
|
|
8
8
|
TriggerOpTypes,
|
|
9
|
+
watch,
|
|
9
10
|
} from "@alloy-js/core";
|
|
10
11
|
import { TSOutputScope } from "./scopes.js";
|
|
11
|
-
import {
|
|
12
|
+
import { TSModuleScope } from "./ts-module-scope.js";
|
|
12
13
|
|
|
13
14
|
// prettier-ignore
|
|
14
15
|
export enum TSSymbolFlags {
|
|
@@ -16,51 +17,85 @@ export enum TSSymbolFlags {
|
|
|
16
17
|
LocalImportSymbol = 1 << 0,
|
|
17
18
|
TypeSymbol = 1 << 1,
|
|
18
19
|
ParameterSymbol = 1 << 2,
|
|
19
|
-
|
|
20
|
-
PrivateMemberContainer = 1 << 4,
|
|
21
|
-
Nullish = 1 << 5,
|
|
20
|
+
Nullish = 1 << 3,
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
export interface CreateTsSymbolOptions extends OutputSymbolOptions {
|
|
25
|
-
scope?: TSOutputScope;
|
|
26
|
-
owner?: TSOutputSymbol;
|
|
27
24
|
export?: boolean;
|
|
28
25
|
default?: boolean;
|
|
29
26
|
tsFlags?: TSSymbolFlags;
|
|
27
|
+
hasInstanceMembers?: boolean;
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
export class TSOutputSymbol extends OutputSymbol {
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
static readonly memberSpaces = [
|
|
32
|
+
"static",
|
|
33
|
+
"instance",
|
|
34
|
+
"private-static",
|
|
35
|
+
"private-instance",
|
|
36
|
+
] as const;
|
|
37
|
+
|
|
38
|
+
constructor(
|
|
39
|
+
name: string,
|
|
40
|
+
spaces: OutputSpace[] | OutputSpace | undefined,
|
|
41
|
+
options: CreateTsSymbolOptions = {},
|
|
42
|
+
) {
|
|
43
|
+
super(name, spaces, options);
|
|
35
44
|
this.#export = !!options.export;
|
|
36
45
|
this.#default = !!options.default;
|
|
37
46
|
this.#tsFlags = options.tsFlags ?? TSSymbolFlags.None;
|
|
38
|
-
this.#
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
this.#
|
|
48
|
-
"private static members",
|
|
49
|
-
{
|
|
50
|
-
flags: OutputScopeFlags.StaticMemberScope,
|
|
51
|
-
binder: this.binder,
|
|
52
|
-
owner: this,
|
|
53
|
-
},
|
|
54
|
-
);
|
|
47
|
+
this.#hasInstanceMembers = !!options.hasInstanceMembers;
|
|
48
|
+
if (
|
|
49
|
+
this.ownerSymbol?.isTypeSymbol ||
|
|
50
|
+
(this.spaces.some((s) => s.key === "types") &&
|
|
51
|
+
!this.spaces.some((s) => s.key === "values"))
|
|
52
|
+
) {
|
|
53
|
+
// Classes and enums are both types and values. The check above will treat them as values
|
|
54
|
+
// exclusively so that referencing occurs properly. This should instead use type or value
|
|
55
|
+
// referencing based on type context.
|
|
56
|
+
this.#tsFlags |= TSSymbolFlags.TypeSymbol;
|
|
55
57
|
}
|
|
56
|
-
|
|
57
|
-
if (options.export && this.scope.kind === "module") {
|
|
58
|
+
if (options.export && this.scope && this.scope instanceof TSModuleScope) {
|
|
58
59
|
for (const refkey of this.refkeys) {
|
|
59
60
|
this.scope.exportedSymbols.set(refkey, this);
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
get ownerSymbol() {
|
|
66
|
+
return super.ownerSymbol as TSOutputSymbol | undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
copy() {
|
|
70
|
+
const copy = new TSOutputSymbol(this.name, undefined, {
|
|
71
|
+
binder: this.binder,
|
|
72
|
+
aliasTarget: this.aliasTarget,
|
|
73
|
+
default: this.default,
|
|
74
|
+
export: this.export,
|
|
75
|
+
tsFlags: this.tsFlags,
|
|
76
|
+
metadata: this.metadata,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
this.initializeCopy(copy);
|
|
80
|
+
|
|
81
|
+
watch(
|
|
82
|
+
() => this.default,
|
|
83
|
+
(def) => (copy.default = def),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
watch(
|
|
87
|
+
() => this.export,
|
|
88
|
+
(exp) => (copy.export = exp),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
watch(
|
|
92
|
+
() => this.tsFlags,
|
|
93
|
+
(flags) => (copy.tsFlags = flags),
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
return copy;
|
|
97
|
+
}
|
|
98
|
+
|
|
64
99
|
#export: boolean;
|
|
65
100
|
get export() {
|
|
66
101
|
track(this, TrackOpTypes.GET, "export");
|
|
@@ -94,6 +129,13 @@ export class TSOutputSymbol extends OutputSymbol {
|
|
|
94
129
|
track(this, TrackOpTypes.GET, "tsFlags");
|
|
95
130
|
return this.#tsFlags;
|
|
96
131
|
}
|
|
132
|
+
|
|
133
|
+
#hasInstanceMembers: boolean = false;
|
|
134
|
+
get hasInstanceMembers() {
|
|
135
|
+
track(this, TrackOpTypes.GET, "hasInstanceMembers");
|
|
136
|
+
return this.#hasInstanceMembers;
|
|
137
|
+
}
|
|
138
|
+
|
|
97
139
|
set tsFlags(value: TSSymbolFlags) {
|
|
98
140
|
const oldValue = this.#tsFlags;
|
|
99
141
|
if (oldValue === value) {
|
|
@@ -103,37 +145,57 @@ export class TSOutputSymbol extends OutputSymbol {
|
|
|
103
145
|
trigger(this, TriggerOpTypes.SET, "tsFlags", value, oldValue);
|
|
104
146
|
}
|
|
105
147
|
|
|
106
|
-
get scope() {
|
|
107
|
-
return super.scope as TSOutputScope;
|
|
148
|
+
get scope(): TSOutputScope | undefined {
|
|
149
|
+
return super.scope as TSOutputScope | undefined;
|
|
108
150
|
}
|
|
109
|
-
|
|
110
|
-
|
|
151
|
+
|
|
152
|
+
get staticMembers() {
|
|
153
|
+
return this.memberSpaceFor("static")!;
|
|
111
154
|
}
|
|
112
155
|
|
|
113
|
-
get
|
|
114
|
-
return
|
|
156
|
+
get instanceMembers() {
|
|
157
|
+
return this.memberSpaceFor("instance")!;
|
|
115
158
|
}
|
|
116
159
|
|
|
117
|
-
get
|
|
118
|
-
return
|
|
160
|
+
get privateInstanceMembers() {
|
|
161
|
+
return this.memberSpaceFor("private-instance")!;
|
|
119
162
|
}
|
|
120
163
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return this.#privateMemberScope;
|
|
164
|
+
get privateStaticMembers() {
|
|
165
|
+
return this.memberSpaceFor("private-static")!;
|
|
124
166
|
}
|
|
125
167
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
168
|
+
get isPrivateMemberSymbol() {
|
|
169
|
+
return (
|
|
170
|
+
this.spaces.length > 0 &&
|
|
171
|
+
this.spaces.filter(
|
|
172
|
+
(s) => s.key === "private-static" || s.key === "private-instance",
|
|
173
|
+
).length > 0
|
|
174
|
+
);
|
|
129
175
|
}
|
|
130
176
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
177
|
+
get isPublicMemberSymbol() {
|
|
178
|
+
return !this.isPrivateMemberSymbol;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
get isStaticMemberSymbol() {
|
|
182
|
+
return !this.isInstanceMemberSymbol;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
get isInstanceMemberSymbol() {
|
|
186
|
+
return (
|
|
187
|
+
this.spaces.length > 0 &&
|
|
188
|
+
this.spaces.filter(
|
|
189
|
+
(s) => s.key === "instance" || s.key === "private-instance",
|
|
190
|
+
).length > 0
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
get isTypeSymbol() {
|
|
195
|
+
return !!(this.tsFlags & TSSymbolFlags.TypeSymbol);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
get isValueSymbol() {
|
|
199
|
+
return this.spaces.some((s) => s.key === "values");
|
|
138
200
|
}
|
|
139
201
|
}
|
|
@@ -12,10 +12,6 @@ export interface TSPackageScopeOptions extends OutputScopeOptions {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export class TSPackageScope extends OutputScope {
|
|
15
|
-
get kind() {
|
|
16
|
-
return "package" as const;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
15
|
/**
|
|
20
16
|
* The version of the this package.
|
|
21
17
|
*/
|
|
@@ -74,7 +70,7 @@ export class TSPackageScope extends OutputScope {
|
|
|
74
70
|
path: string,
|
|
75
71
|
options: TSPackageScopeOptions = {},
|
|
76
72
|
) {
|
|
77
|
-
super(name, options);
|
|
73
|
+
super(name, undefined, options);
|
|
78
74
|
this.#version = version;
|
|
79
75
|
this.#path = path;
|
|
80
76
|
this.#builtin = !!options.builtin;
|
|
@@ -99,4 +95,8 @@ export class TSPackageScope extends OutputScope {
|
|
|
99
95
|
|
|
100
96
|
return null;
|
|
101
97
|
}
|
|
98
|
+
|
|
99
|
+
copyTo(): TSPackageScope {
|
|
100
|
+
throw new Error("Not supported");
|
|
101
|
+
}
|
|
102
102
|
}
|
package/src/utils.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
defaultProps,
|
|
3
|
+
splitProps,
|
|
4
|
+
useMemberContext,
|
|
5
|
+
useScope,
|
|
6
|
+
} from "@alloy-js/core";
|
|
2
7
|
import { CallSignatureProps } from "./components/CallSignature.jsx";
|
|
8
|
+
import { TSLexicalScope } from "./symbols/ts-lexical-scope.js";
|
|
9
|
+
import { TSOutputSymbol } from "./symbols/ts-output-symbol.js";
|
|
3
10
|
|
|
4
11
|
export function modulePath(path: string) {
|
|
5
12
|
if (path[0] !== ".") {
|
|
@@ -38,3 +45,33 @@ const identifierRegex =
|
|
|
38
45
|
export function isValidJSIdentifier(str: string) {
|
|
39
46
|
return identifierRegex.test(str);
|
|
40
47
|
}
|
|
48
|
+
|
|
49
|
+
export function useLexicalScope(): TSLexicalScope | undefined {
|
|
50
|
+
const scope = useScope();
|
|
51
|
+
if (!scope) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (!(scope instanceof TSLexicalScope)) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
"A lexical scope is required but the current scope is not a lexical scope",
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return scope;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function useMemberOwner(): TSOutputSymbol {
|
|
65
|
+
const memberScope = useMemberContext();
|
|
66
|
+
if (!memberScope) {
|
|
67
|
+
throw new Error("A member owner is required but no member scope was found");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!(memberScope.ownerSymbol instanceof TSOutputSymbol)) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
"A member owner is required but the current owner is not a TSOutputSymbol",
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return memberScope.ownerSymbol;
|
|
77
|
+
}
|