@alloy-js/typescript 0.22.0 → 0.23.0-dev.10
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/dev/src/builtins/index.js +2 -0
- package/dist/dev/src/builtins/index.js.map +1 -0
- package/dist/dev/src/builtins/node.js +42 -0
- package/dist/dev/src/builtins/node.js.map +1 -0
- package/dist/dev/src/components/ArrayExpression.js +59 -0
- package/dist/dev/src/components/ArrayExpression.js.map +1 -0
- package/dist/dev/src/components/ArrowFunction.js +74 -0
- package/dist/dev/src/components/ArrowFunction.js.map +1 -0
- package/dist/dev/src/components/BarrelFile.js +87 -0
- package/dist/dev/src/components/BarrelFile.js.map +1 -0
- package/dist/dev/src/components/BlockScope.js +28 -0
- package/dist/dev/src/components/BlockScope.js.map +1 -0
- package/dist/dev/src/components/CallSignature.js +42 -0
- package/dist/dev/src/components/CallSignature.js.map +1 -0
- package/dist/dev/src/components/ClassDeclaration.js +279 -0
- package/dist/dev/src/components/ClassDeclaration.js.map +1 -0
- package/dist/dev/src/components/CommaList.js +21 -0
- package/dist/dev/src/components/CommaList.js.map +1 -0
- package/dist/dev/src/components/Declaration.js +60 -0
- package/dist/dev/src/components/Declaration.js.map +1 -0
- package/dist/dev/src/components/EnumDeclaration.js +96 -0
- package/dist/dev/src/components/EnumDeclaration.js.map +1 -0
- package/dist/dev/src/components/EnumMember.js +69 -0
- package/dist/dev/src/components/EnumMember.js.map +1 -0
- package/dist/dev/src/components/ExportStatement.js +18 -0
- package/dist/dev/src/components/ExportStatement.js.map +1 -0
- package/dist/dev/src/components/FunctionBase.js +364 -0
- package/dist/dev/src/components/FunctionBase.js.map +1 -0
- package/dist/dev/src/components/FunctionCallExpression.js +41 -0
- package/dist/dev/src/components/FunctionCallExpression.js.map +1 -0
- package/dist/dev/src/components/FunctionDeclaration.js +118 -0
- package/dist/dev/src/components/FunctionDeclaration.js.map +1 -0
- package/dist/dev/src/components/FunctionExpression.js +73 -0
- package/dist/dev/src/components/FunctionExpression.js.map +1 -0
- package/dist/dev/src/components/FunctionType.js +106 -0
- package/dist/dev/src/components/FunctionType.js.map +1 -0
- package/dist/dev/src/components/IfStatement.js +45 -0
- package/dist/dev/src/components/IfStatement.js.map +1 -0
- package/dist/dev/src/components/ImportStatement.js +142 -0
- package/dist/dev/src/components/ImportStatement.js.map +1 -0
- package/dist/dev/src/components/Interface.js +254 -0
- package/dist/dev/src/components/Interface.js.map +1 -0
- package/dist/dev/src/components/InterfaceMethod.js +120 -0
- package/dist/dev/src/components/InterfaceMethod.js.map +1 -0
- package/dist/dev/src/components/JSDoc.js +28 -0
- package/dist/dev/src/components/JSDoc.js.map +1 -0
- package/dist/dev/src/components/JSDocComment.js +27 -0
- package/dist/dev/src/components/JSDocComment.js.map +1 -0
- package/dist/dev/src/components/JSDocExample.js +44 -0
- package/dist/dev/src/components/JSDocExample.js.map +1 -0
- package/dist/dev/src/components/JSDocParam.js +175 -0
- package/dist/dev/src/components/JSDocParam.js.map +1 -0
- package/dist/dev/src/components/LexicalScope.js +29 -0
- package/dist/dev/src/components/LexicalScope.js.map +1 -0
- package/dist/dev/src/components/MemberDeclaration.js +29 -0
- package/dist/dev/src/components/MemberDeclaration.js.map +1 -0
- package/dist/dev/src/components/MemberExpression.js +284 -0
- package/dist/dev/src/components/MemberExpression.js.map +1 -0
- package/dist/dev/src/components/MemberScope.js +26 -0
- package/dist/dev/src/components/MemberScope.js.map +1 -0
- package/dist/dev/src/components/NewExpression.js +17 -0
- package/dist/dev/src/components/NewExpression.js.map +1 -0
- package/dist/dev/src/components/ObjectExpression.js +179 -0
- package/dist/dev/src/components/ObjectExpression.js.map +1 -0
- package/dist/dev/src/components/PackageDirectory.js +108 -0
- package/dist/dev/src/components/PackageDirectory.js.map +1 -0
- package/dist/dev/src/components/PackageJson.js +78 -0
- package/dist/dev/src/components/PackageJson.js.map +1 -0
- package/dist/dev/src/components/PropertyName.js +37 -0
- package/dist/dev/src/components/PropertyName.js.map +1 -0
- package/dist/dev/src/components/Reference.js +17 -0
- package/dist/dev/src/components/Reference.js.map +1 -0
- package/dist/dev/src/components/SingleLineCommentBlock.js +27 -0
- package/dist/dev/src/components/SingleLineCommentBlock.js.map +1 -0
- package/dist/dev/src/components/SourceFile.js +150 -0
- package/dist/dev/src/components/SourceFile.js.map +1 -0
- package/dist/dev/src/components/SwitchStatement.js +74 -0
- package/dist/dev/src/components/SwitchStatement.js.map +1 -0
- package/dist/dev/src/components/TryStatement.js +128 -0
- package/dist/dev/src/components/TryStatement.js.map +1 -0
- package/dist/dev/src/components/TryStatement.test.js +181 -0
- package/dist/dev/src/components/TryStatement.test.js.map +1 -0
- package/dist/dev/src/components/TsConfigJson.js +62 -0
- package/dist/dev/src/components/TsConfigJson.js.map +1 -0
- package/dist/dev/src/components/TypeDeclaration.js +46 -0
- package/dist/dev/src/components/TypeDeclaration.js.map +1 -0
- package/dist/dev/src/components/TypeRefContext.js +58 -0
- package/dist/dev/src/components/TypeRefContext.js.map +1 -0
- package/dist/dev/src/components/ValueExpression.js +42 -0
- package/dist/dev/src/components/ValueExpression.js.map +1 -0
- package/dist/dev/src/components/VarDeclaration.js +107 -0
- package/dist/dev/src/components/VarDeclaration.js.map +1 -0
- package/dist/dev/src/components/index.js +40 -0
- package/dist/dev/src/components/index.js.map +1 -0
- package/dist/dev/src/components/interface/expression.test.js +217 -0
- package/dist/dev/src/components/interface/expression.test.js.map +1 -0
- package/dist/dev/src/components/stc/index.js +48 -0
- package/dist/dev/src/components/stc/index.js.map +1 -0
- package/dist/dev/src/context/index.js +3 -0
- package/dist/dev/src/context/index.js.map +1 -0
- package/dist/dev/src/context/package-metadata.js +3 -0
- package/dist/dev/src/context/package-metadata.js.map +1 -0
- package/dist/dev/src/context/type-ref-context.js +13 -0
- package/dist/dev/src/context/type-ref-context.js.map +1 -0
- package/dist/dev/src/create-package.js +178 -0
- package/dist/dev/src/create-package.js.map +1 -0
- package/dist/dev/src/index.js +10 -0
- package/dist/dev/src/index.js.map +1 -0
- package/dist/dev/src/name-conflict-resolver.js +21 -0
- package/dist/dev/src/name-conflict-resolver.js.map +1 -0
- package/dist/dev/src/name-policy.js +52 -0
- package/dist/dev/src/name-policy.js.map +1 -0
- package/dist/dev/src/parameter-descriptor.js +2 -0
- package/dist/dev/src/parameter-descriptor.js.map +1 -0
- package/dist/dev/src/source-directory-data.js +13 -0
- package/dist/dev/src/source-directory-data.js.map +1 -0
- package/dist/dev/src/symbols/index.js +151 -0
- package/dist/dev/src/symbols/index.js.map +1 -0
- package/dist/dev/src/symbols/reference.js +155 -0
- package/dist/dev/src/symbols/reference.js.map +1 -0
- package/dist/dev/src/symbols/scopes.js +31 -0
- package/dist/dev/src/symbols/scopes.js.map +1 -0
- package/dist/dev/src/symbols/ts-lexical-scope.js +17 -0
- package/dist/dev/src/symbols/ts-lexical-scope.js.map +1 -0
- package/dist/dev/src/symbols/ts-member-scope.js +19 -0
- package/dist/dev/src/symbols/ts-member-scope.js.map +1 -0
- package/dist/dev/src/symbols/ts-module-scope.js +137 -0
- package/dist/dev/src/symbols/ts-module-scope.js.map +1 -0
- package/dist/dev/src/symbols/ts-output-symbol.js +144 -0
- package/dist/dev/src/symbols/ts-output-symbol.js.map +1 -0
- package/dist/dev/src/symbols/ts-package-scope.js +90 -0
- package/dist/dev/src/symbols/ts-package-scope.js.map +1 -0
- package/dist/dev/src/utils.js +46 -0
- package/dist/dev/src/utils.js.map +1 -0
- package/dist/dev/test/array.test.js +158 -0
- package/dist/dev/test/array.test.js.map +1 -0
- package/dist/dev/test/arrow-function.test.js +308 -0
- package/dist/dev/test/arrow-function.test.js.map +1 -0
- package/dist/dev/test/barrel.test.js +115 -0
- package/dist/dev/test/barrel.test.js.map +1 -0
- package/dist/dev/test/basic.test.js +131 -0
- package/dist/dev/test/basic.test.js.map +1 -0
- package/dist/dev/test/block-scope.test.js +51 -0
- package/dist/dev/test/block-scope.test.js.map +1 -0
- package/dist/dev/test/class.test.js +940 -0
- package/dist/dev/test/class.test.js.map +1 -0
- package/dist/dev/test/decl-helpers.test.js +217 -0
- package/dist/dev/test/decl-helpers.test.js.map +1 -0
- package/dist/dev/test/enum-jsdoc.test.js +133 -0
- package/dist/dev/test/enum-jsdoc.test.js.map +1 -0
- package/dist/dev/test/enum.test.js +461 -0
- package/dist/dev/test/enum.test.js.map +1 -0
- package/dist/dev/test/externals.test.js +493 -0
- package/dist/dev/test/externals.test.js.map +1 -0
- package/dist/dev/test/function-call-expression.test.js +144 -0
- package/dist/dev/test/function-call-expression.test.js.map +1 -0
- package/dist/dev/test/function-declaration-jsdoc.test.js +128 -0
- package/dist/dev/test/function-declaration-jsdoc.test.js.map +1 -0
- package/dist/dev/test/function-declaration.test.js +671 -0
- package/dist/dev/test/function-declaration.test.js.map +1 -0
- package/dist/dev/test/function-expression.test.js +308 -0
- package/dist/dev/test/function-expression.test.js.map +1 -0
- package/dist/dev/test/function-type.test.js +201 -0
- package/dist/dev/test/function-type.test.js.map +1 -0
- package/dist/dev/test/if-statement.test.js +38 -0
- package/dist/dev/test/if-statement.test.js.map +1 -0
- package/dist/dev/test/imports-reactive.test.js +223 -0
- package/dist/dev/test/imports-reactive.test.js.map +1 -0
- package/dist/dev/test/imports.test.js +1673 -0
- package/dist/dev/test/imports.test.js.map +1 -0
- package/dist/dev/test/interface-jsdoc.test.js +267 -0
- package/dist/dev/test/interface-jsdoc.test.js.map +1 -0
- package/dist/dev/test/interface.test.js +986 -0
- package/dist/dev/test/interface.test.js.map +1 -0
- package/dist/dev/test/jscomment.test.js +123 -0
- package/dist/dev/test/jscomment.test.js.map +1 -0
- package/dist/dev/test/jsdoc.test.js +203 -0
- package/dist/dev/test/jsdoc.test.js.map +1 -0
- package/dist/dev/test/jsdocparam.test.js +237 -0
- package/dist/dev/test/jsdocparam.test.js.map +1 -0
- package/dist/dev/test/member-expression.test.js +2021 -0
- package/dist/dev/test/member-expression.test.js.map +1 -0
- package/dist/dev/test/name-conflict.test.js +119 -0
- package/dist/dev/test/name-conflict.test.js.map +1 -0
- package/dist/dev/test/name-policy.test.js +215 -0
- package/dist/dev/test/name-policy.test.js.map +1 -0
- package/dist/dev/test/new-expression.test.js +100 -0
- package/dist/dev/test/new-expression.test.js.map +1 -0
- package/dist/dev/test/object.test.js +167 -0
- package/dist/dev/test/object.test.js.map +1 -0
- package/dist/dev/test/package-external.test.js +281 -0
- package/dist/dev/test/package-external.test.js.map +1 -0
- package/dist/dev/test/package-json.test.js +113 -0
- package/dist/dev/test/package-json.test.js.map +1 -0
- package/dist/dev/test/package.test.js +188 -0
- package/dist/dev/test/package.test.js.map +1 -0
- package/dist/dev/test/reference.test.js +141 -0
- package/dist/dev/test/reference.test.js.map +1 -0
- package/dist/dev/test/source-file.test.js +50 -0
- package/dist/dev/test/source-file.test.js.map +1 -0
- package/dist/dev/test/switch-statement.test.js +94 -0
- package/dist/dev/test/switch-statement.test.js.map +1 -0
- package/dist/dev/test/utils.js +77 -0
- package/dist/dev/test/utils.js.map +1 -0
- package/dist/dev/test/value-expression.test.js +35 -0
- package/dist/dev/test/value-expression.test.js.map +1 -0
- package/dist/dev/test/values.test.js +618 -0
- package/dist/dev/test/values.test.js.map +1 -0
- package/dist/dev/test/var-declaration-jsdoc.test.js +63 -0
- package/dist/dev/test/var-declaration-jsdoc.test.js.map +1 -0
- package/dist/dev/test/var-declaration.test.js +395 -0
- package/dist/dev/test/var-declaration.test.js.map +1 -0
- package/dist/dev/test/vitest.setup.js +2 -0
- package/dist/dev/test/vitest.setup.js.map +1 -0
- package/dist/dev/testing/create-wrapper.js +12 -0
- package/dist/dev/testing/create-wrapper.js.map +1 -0
- package/dist/dev/testing/create-wrapper.test.js +231 -0
- package/dist/dev/testing/create-wrapper.test.js.map +1 -0
- package/dist/dev/testing/index.js +2 -0
- package/dist/dev/testing/index.js.map +1 -0
- package/dist/src/components/FunctionBase.js +1 -5
- package/dist/src/components/FunctionBase.js.map +1 -1
- package/dist/src/components/FunctionType.d.ts +1 -1
- package/dist/src/components/FunctionType.js +1 -1
- package/dist/src/components/FunctionType.js.map +1 -1
- package/dist/src/components/IfStatement.d.ts.map +1 -1
- package/dist/src/components/IfStatement.js +2 -3
- package/dist/src/components/IfStatement.js.map +1 -1
- package/dist/src/components/ImportStatement.d.ts.map +1 -1
- package/dist/src/components/ImportStatement.js +16 -8
- package/dist/src/components/ImportStatement.js.map +1 -1
- package/dist/src/components/Interface.d.ts +1 -1
- package/dist/src/components/Interface.d.ts.map +1 -1
- package/dist/src/components/Interface.js +24 -9
- package/dist/src/components/Interface.js.map +1 -1
- package/dist/src/components/MemberExpression.d.ts +1 -1
- package/dist/src/components/MemberExpression.d.ts.map +1 -1
- package/dist/src/components/MemberExpression.js +115 -330
- package/dist/src/components/MemberExpression.js.map +1 -1
- package/dist/src/components/MemberScope.d.ts.map +1 -1
- package/dist/src/components/MemberScope.js +6 -2
- package/dist/src/components/MemberScope.js.map +1 -1
- package/dist/src/components/PackageDirectory.d.ts.map +1 -1
- package/dist/src/components/PackageDirectory.js +2 -2
- package/dist/src/components/PackageDirectory.js.map +1 -1
- package/dist/src/components/SourceFile.d.ts.map +1 -1
- package/dist/src/components/SourceFile.js +4 -2
- package/dist/src/components/SourceFile.js.map +1 -1
- package/dist/src/components/TryStatement.d.ts +80 -0
- package/dist/src/components/TryStatement.d.ts.map +1 -0
- package/dist/src/components/TryStatement.js +112 -0
- package/dist/src/components/TryStatement.js.map +1 -0
- package/dist/src/components/TryStatement.test.d.ts +2 -0
- package/dist/src/components/TryStatement.test.d.ts.map +1 -0
- package/dist/src/components/TryStatement.test.js +121 -0
- package/dist/src/components/TryStatement.test.js.map +1 -0
- package/dist/src/components/TsConfigJson.d.ts.map +1 -1
- package/dist/src/components/TsConfigJson.js +5 -0
- package/dist/src/components/TsConfigJson.js.map +1 -1
- package/dist/src/components/TypeDeclaration.d.ts +1 -1
- package/dist/src/components/TypeDeclaration.d.ts.map +1 -1
- package/dist/src/components/TypeDeclaration.js +1 -1
- package/dist/src/components/TypeDeclaration.js.map +1 -1
- package/dist/src/components/TypeRefContext.d.ts +1 -1
- package/dist/src/components/TypeRefContext.d.ts.map +1 -1
- package/dist/src/components/TypeRefContext.js +1 -1
- package/dist/src/components/TypeRefContext.js.map +1 -1
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/context/type-ref-context.d.ts.map +1 -1
- package/dist/src/context/type-ref-context.js +2 -2
- package/dist/src/context/type-ref-context.js.map +1 -1
- package/dist/src/create-package.d.ts.map +1 -1
- package/dist/src/create-package.js +7 -6
- package/dist/src/create-package.js.map +1 -1
- package/dist/src/name-conflict-resolver.d.ts +2 -2
- package/dist/src/name-conflict-resolver.d.ts.map +1 -1
- package/dist/src/name-conflict-resolver.js +8 -2
- package/dist/src/name-conflict-resolver.js.map +1 -1
- package/dist/src/symbols/index.d.ts.map +1 -1
- package/dist/src/symbols/index.js +53 -11
- 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 +13 -3
- package/dist/src/symbols/reference.js.map +1 -1
- package/dist/src/symbols/ts-module-scope.d.ts +8 -0
- package/dist/src/symbols/ts-module-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-module-scope.js +80 -5
- package/dist/src/symbols/ts-module-scope.js.map +1 -1
- package/dist/src/symbols/ts-output-symbol.d.ts +1 -0
- package/dist/src/symbols/ts-output-symbol.d.ts.map +1 -1
- package/dist/src/symbols/ts-output-symbol.js +20 -3
- package/dist/src/symbols/ts-output-symbol.js.map +1 -1
- package/dist/src/symbols/ts-package-scope.d.ts +1 -0
- package/dist/src/symbols/ts-package-scope.d.ts.map +1 -1
- package/dist/src/symbols/ts-package-scope.js +8 -0
- package/dist/src/symbols/ts-package-scope.js.map +1 -1
- package/dist/test/externals.test.js +5 -1
- package/dist/test/externals.test.js.map +1 -1
- package/dist/test/function-declaration.test.js +42 -0
- package/dist/test/function-declaration.test.js.map +1 -1
- package/dist/test/imports-reactive.test.d.ts +2 -0
- package/dist/test/imports-reactive.test.d.ts.map +1 -0
- package/dist/test/imports-reactive.test.js +167 -0
- package/dist/test/imports-reactive.test.js.map +1 -0
- package/dist/test/imports.test.js +121 -3
- package/dist/test/imports.test.js.map +1 -1
- package/dist/test/name-conflict.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/docs/api/components/ArrowFunction.md +71 -0
- package/docs/api/components/BarrelFile.md +58 -0
- package/docs/api/components/BlockScope.md +97 -0
- package/docs/api/components/CallSignature.md +45 -0
- package/docs/api/components/CaseClause.md +102 -0
- package/docs/api/components/CatchClause.md +50 -0
- package/docs/api/components/ClassDeclaration.md +61 -0
- package/docs/api/components/ClassField.md +63 -0
- package/docs/api/components/ClassMember.md +56 -0
- package/docs/api/components/ClassMethod.md +75 -0
- package/docs/api/components/CommaList.md +31 -0
- package/docs/api/components/Declaration.md +87 -0
- package/docs/api/components/ElseClause.md +29 -0
- package/docs/api/components/ElseIfClause.md +30 -0
- package/docs/api/components/EnumDeclaration.md +29 -0
- package/docs/api/components/EnumMember.md +46 -0
- package/docs/api/components/ExportStatement.md +26 -0
- package/docs/api/components/FinallyClause.md +50 -0
- package/docs/api/components/FunctionCallExpression.md +29 -0
- package/docs/api/components/FunctionDeclaration.md +57 -0
- package/docs/api/components/FunctionExpression.md +71 -0
- package/docs/api/components/IfStatement.md +30 -0
- package/docs/api/components/ImportStatement.md +29 -0
- package/docs/api/components/ImportStatements.md +25 -0
- package/docs/api/components/InterfaceDeclaration.md +38 -0
- package/docs/api/components/InterfaceMember.md +99 -0
- package/docs/api/components/InterfaceMethod.md +74 -0
- package/docs/api/components/JSDoc.md +29 -0
- package/docs/api/components/JSDocComment.md +29 -0
- package/docs/api/components/JSDocExample.md +31 -0
- package/docs/api/components/MemberExpression.md +58 -0
- package/docs/api/components/NewExpression.md +26 -0
- package/docs/api/components/ObjectExpression.md +32 -0
- package/docs/api/components/ObjectProperty.md +44 -0
- package/docs/api/components/ObjectSpreadProperty.md +29 -0
- package/docs/api/components/PackageDirectory.md +102 -0
- package/docs/api/components/PackageJsonFile.md +82 -0
- package/docs/api/components/Reference.md +26 -0
- package/docs/api/components/SingleLineCommentBlock.md +29 -0
- package/docs/api/components/SourceFile.md +41 -0
- package/docs/api/components/SwitchStatement.md +30 -0
- package/docs/api/components/TSConfigJson.md +25 -0
- package/docs/api/components/TryStatement.md +50 -0
- package/docs/api/components/TypeRefContext.md +35 -0
- package/docs/api/components/ValueExpression.md +25 -0
- package/docs/api/components/VarDeclaration.md +44 -0
- package/docs/api/components/ensureTypeRefContext.md +28 -0
- package/docs/api/components/index.md +49 -0
- package/docs/api/contexts/Package-context.md +21 -0
- package/docs/api/contexts/PackageMetadata-context.md +18 -0
- package/docs/api/contexts/SourceFile-context.md +20 -0
- package/docs/api/contexts/index.md +5 -0
- package/docs/api/functions/createInstanceMemberSymbol.md +38 -0
- package/docs/api/functions/createLexicalScope.md +27 -0
- package/docs/api/functions/createMemberScope.md +28 -0
- package/docs/api/functions/createMemberSymbol.md +42 -0
- package/docs/api/functions/createPackage.md +18 -0
- package/docs/api/functions/createPrivateInstanceMemberSymbol.md +38 -0
- package/docs/api/functions/createPrivateStaticMemberSymbol.md +38 -0
- package/docs/api/functions/createStaticMemberSymbol.md +38 -0
- package/docs/api/functions/createTSNamePolicy.md +17 -0
- package/docs/api/functions/createTransientValueSymbol.md +17 -0
- package/docs/api/functions/createTypeAndValueSymbol.md +38 -0
- package/docs/api/functions/createTypeSymbol.md +38 -0
- package/docs/api/functions/createValueSymbol.md +38 -0
- package/docs/api/functions/decl.md +38 -0
- package/docs/api/functions/declMember.md +42 -0
- package/docs/api/functions/declType.md +38 -0
- package/docs/api/functions/getPackageScope.md +20 -0
- package/docs/api/functions/getSourceDirectoryData.md +18 -0
- package/docs/api/functions/index.md +27 -0
- package/docs/api/functions/ref.md +25 -0
- package/docs/api/functions/tsNameConflictResolver.md +19 -0
- package/docs/api/functions/useTSLexicalScope.md +17 -0
- package/docs/api/functions/useTSLexicalScopeIfPresent.md +17 -0
- package/docs/api/functions/useTSMemberScope.md +17 -0
- package/docs/api/functions/useTSNamePolicy.md +17 -0
- package/docs/api/functions/useTSScope.md +17 -0
- package/docs/api/index.md +7 -0
- package/docs/api/types/AddImportOptions.md +7 -0
- package/docs/api/types/BlockScopeProps.md +5 -0
- package/docs/api/types/CaseClauseProps.md +5 -0
- package/docs/api/types/CaseClausePropsBase.md +9 -0
- package/docs/api/types/CommonDeclarationProps.md +7 -0
- package/docs/api/types/CreatePackageProps.md +12 -0
- package/docs/api/types/CreateTsSymbolOptions.md +12 -0
- package/docs/api/types/DeclarationProps.md +5 -0
- package/docs/api/types/DeclarationPropsBase.md +8 -0
- package/docs/api/types/ExportConditions.md +7 -0
- package/docs/api/types/ExportPath.md +5 -0
- package/docs/api/types/ExternalPackage.md +7 -0
- package/docs/api/types/FunctionBodyProps.md +7 -0
- package/docs/api/types/FunctionParametersProps.md +10 -0
- package/docs/api/types/FunctionTypeParameterDescriptor.md +10 -0
- package/docs/api/types/FunctionTypeParametersProps.md +10 -0
- package/docs/api/types/FunctionTypeProps.md +13 -0
- package/docs/api/types/ImportRecords.md +5 -0
- package/docs/api/types/ImportedSymbol.md +8 -0
- package/docs/api/types/InterfaceExpressionProps.md +7 -0
- package/docs/api/types/InterfaceMemberProps.md +5 -0
- package/docs/api/types/InterfaceMemberPropsBase.md +11 -0
- package/docs/api/types/MemberExpressionPartProps.md +15 -0
- package/docs/api/types/ModuleExports.md +18 -0
- package/docs/api/types/ModuleSymbolsDescriptor.md +10 -0
- package/docs/api/types/NamedMap.md +18 -0
- package/docs/api/types/NamedModuleDescriptor.md +17 -0
- package/docs/api/types/PackageDescriptor.md +7 -0
- package/docs/api/types/PackageExports.md +7 -0
- package/docs/api/types/PackageRefkeys.md +10 -0
- package/docs/api/types/ParameterDescriptor.md +11 -0
- package/docs/api/types/ParameterDescriptorBase.md +16 -0
- package/docs/api/types/RefOptions.md +7 -0
- package/docs/api/types/SourceDirectoryData.md +7 -0
- package/docs/api/types/SourceFileHeaderProps.md +8 -0
- package/docs/api/types/TSLexicalScope.md +13 -0
- package/docs/api/types/TSMemberScope.md +14 -0
- package/docs/api/types/TSModuleScope.md +17 -0
- package/docs/api/types/TSOutputScope.md +5 -0
- package/docs/api/types/TSOutputSymbol.md +28 -0
- package/docs/api/types/TSPackageScope.md +21 -0
- package/docs/api/types/TSPackageScopeOptions.md +9 -0
- package/docs/api/types/TypeDeclarationProps.md +8 -0
- package/docs/api/types/TypeParameterDescriptor.md +13 -0
- package/docs/api/types/TypeScriptElements.md +5 -0
- package/docs/api/types/index.md +47 -0
- package/docs/api/variables/FunctionType.md +24 -0
- package/docs/api/variables/InterfaceExpression.md +5 -0
- package/docs/api/variables/TSSymbolFlags.md +5 -0
- package/docs/api/variables/TypeDeclaration.md +5 -0
- package/docs/api/variables/index.md +6 -0
- package/package.json +15 -7
- package/src/components/FunctionBase.tsx +1 -1
- package/src/components/FunctionType.tsx +1 -1
- package/src/components/IfStatement.tsx +3 -3
- package/src/components/ImportStatement.tsx +26 -12
- package/src/components/Interface.tsx +58 -29
- package/src/components/MemberExpression.tsx +194 -454
- package/src/components/MemberScope.tsx +13 -3
- package/src/components/PackageDirectory.tsx +2 -1
- package/src/components/SourceFile.tsx +4 -1
- package/src/components/TryStatement.test.tsx +123 -0
- package/src/components/TryStatement.tsx +141 -0
- package/src/components/TsConfigJson.tsx +18 -9
- package/src/components/TypeDeclaration.tsx +15 -15
- package/src/components/TypeRefContext.tsx +2 -2
- package/src/components/index.ts +1 -0
- package/src/context/type-ref-context.tsx +6 -2
- package/src/create-package.ts +29 -15
- package/src/name-conflict-resolver.ts +12 -8
- package/src/symbols/index.ts +51 -10
- package/src/symbols/reference.tsx +17 -6
- package/src/symbols/ts-module-scope.ts +115 -11
- package/src/symbols/ts-output-symbol.ts +21 -2
- package/src/symbols/ts-package-scope.ts +9 -0
- package/temp/api.json +547 -73
- package/test/externals.test.tsx +5 -1
- package/test/function-declaration.test.tsx +36 -0
- package/test/imports-reactive.test.tsx +128 -0
- package/test/imports.test.tsx +136 -2
- package/test/name-conflict.test.tsx +4 -4
- package/vitest.config.ts +8 -0
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Children,
|
|
3
|
+
MemberScope as CoreMemberScope,
|
|
4
|
+
createScope,
|
|
5
|
+
} from "@alloy-js/core";
|
|
2
6
|
import { useTSLexicalScopeIfPresent } from "../symbols/scopes.js";
|
|
3
7
|
import { TSMemberScope } from "../symbols/ts-member-scope.js";
|
|
4
8
|
import { TSOutputSymbol } from "../symbols/ts-output-symbol.js";
|
|
@@ -17,10 +21,16 @@ export interface MemberScopeProps {
|
|
|
17
21
|
* in this scope, which will be added to the owner symbol's members.
|
|
18
22
|
*/
|
|
19
23
|
export function MemberScope(props: MemberScopeProps) {
|
|
20
|
-
const
|
|
24
|
+
const parentScope = useTSLexicalScopeIfPresent();
|
|
25
|
+
const binder = props.ownerSymbol.binder ?? parentScope?.binder;
|
|
26
|
+
const memberScope = createScope(
|
|
27
|
+
TSMemberScope,
|
|
21
28
|
"member-scope",
|
|
22
|
-
|
|
29
|
+
parentScope,
|
|
23
30
|
props.ownerSymbol,
|
|
31
|
+
{
|
|
32
|
+
binder,
|
|
33
|
+
},
|
|
24
34
|
);
|
|
25
35
|
|
|
26
36
|
return (
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
Children,
|
|
3
3
|
ComponentContext,
|
|
4
4
|
createNamedContext,
|
|
5
|
+
createScope,
|
|
5
6
|
Ref,
|
|
6
7
|
Scope,
|
|
7
8
|
shallowRef,
|
|
@@ -122,7 +123,7 @@ function createPackageContext(
|
|
|
122
123
|
// todo: this can probably just use context.
|
|
123
124
|
const fullPath = parentDir ? join(parentDir.path, path) : path;
|
|
124
125
|
|
|
125
|
-
const scope =
|
|
126
|
+
const scope = createScope(TSPackageScope, name, version, fullPath);
|
|
126
127
|
|
|
127
128
|
return {
|
|
128
129
|
scope,
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
ComponentContext,
|
|
3
3
|
SourceFile as CoreSourceFile,
|
|
4
4
|
createNamedContext,
|
|
5
|
+
createScope,
|
|
5
6
|
Scope,
|
|
6
7
|
Show,
|
|
7
8
|
SourceDirectoryContext,
|
|
@@ -41,7 +42,9 @@ export function SourceFile(props: SourceFileProps) {
|
|
|
41
42
|
const currentDir = directoryContext.path;
|
|
42
43
|
const path: string = join(currentDir, props.path);
|
|
43
44
|
const parent = useScope();
|
|
44
|
-
const scope =
|
|
45
|
+
const scope = createScope(TSModuleScope, path, parent, {
|
|
46
|
+
binder: parent?.binder,
|
|
47
|
+
});
|
|
45
48
|
sdData.modules.add(scope);
|
|
46
49
|
const pkg = useContext(PackageContext);
|
|
47
50
|
if (pkg) {
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { refkey, StatementList } from "@alloy-js/core";
|
|
2
|
+
import { d } from "@alloy-js/core/testing";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
import { toSourceText } from "../../test/utils.jsx";
|
|
5
|
+
import { CatchClause, FinallyClause, TryStatement } from "./TryStatement.jsx";
|
|
6
|
+
import { VarDeclaration } from "./VarDeclaration.jsx";
|
|
7
|
+
|
|
8
|
+
it("works with try-catch", () => {
|
|
9
|
+
const text = toSourceText(
|
|
10
|
+
<>
|
|
11
|
+
<TryStatement>// try something</TryStatement>
|
|
12
|
+
<CatchClause parameter="error">// handle error</CatchClause>
|
|
13
|
+
</>,
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
expect(text).toBe(d`
|
|
17
|
+
try {
|
|
18
|
+
// try something
|
|
19
|
+
} catch (error) {
|
|
20
|
+
// handle error
|
|
21
|
+
}
|
|
22
|
+
`);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("works with try-catch-finally", () => {
|
|
26
|
+
const text = toSourceText(
|
|
27
|
+
<>
|
|
28
|
+
<TryStatement>// try something</TryStatement>
|
|
29
|
+
<CatchClause parameter="error">// handle error</CatchClause>
|
|
30
|
+
<FinallyClause>// cleanup</FinallyClause>
|
|
31
|
+
</>,
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
expect(text).toBe(d`
|
|
35
|
+
try {
|
|
36
|
+
// try something
|
|
37
|
+
} catch (error) {
|
|
38
|
+
// handle error
|
|
39
|
+
} finally {
|
|
40
|
+
// cleanup
|
|
41
|
+
}
|
|
42
|
+
`);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("works with try-finally", () => {
|
|
46
|
+
const text = toSourceText(
|
|
47
|
+
<>
|
|
48
|
+
<TryStatement>// try something</TryStatement>
|
|
49
|
+
<FinallyClause>// cleanup</FinallyClause>
|
|
50
|
+
</>,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
expect(text).toBe(d`
|
|
54
|
+
try {
|
|
55
|
+
// try something
|
|
56
|
+
} finally {
|
|
57
|
+
// cleanup
|
|
58
|
+
}
|
|
59
|
+
`);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("works with catch without parameter", () => {
|
|
63
|
+
const text = toSourceText(
|
|
64
|
+
<>
|
|
65
|
+
<TryStatement>// try something</TryStatement>
|
|
66
|
+
<CatchClause>// handle error without parameter</CatchClause>
|
|
67
|
+
</>,
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
expect(text).toBe(d`
|
|
71
|
+
try {
|
|
72
|
+
// try something
|
|
73
|
+
} catch {
|
|
74
|
+
// handle error without parameter
|
|
75
|
+
}
|
|
76
|
+
`);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("works with typed catch parameter", () => {
|
|
80
|
+
const text = toSourceText(
|
|
81
|
+
<>
|
|
82
|
+
<TryStatement>// try something</TryStatement>
|
|
83
|
+
<CatchClause parameter={{ name: "error", type: "Error" }}>
|
|
84
|
+
// handle typed error
|
|
85
|
+
</CatchClause>
|
|
86
|
+
</>,
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
expect(text).toBe(d`
|
|
90
|
+
try {
|
|
91
|
+
// try something
|
|
92
|
+
} catch (error: Error) {
|
|
93
|
+
// handle typed error
|
|
94
|
+
}
|
|
95
|
+
`);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("creates symbols for catch parameters", () => {
|
|
99
|
+
const rk = refkey();
|
|
100
|
+
|
|
101
|
+
const text = toSourceText(
|
|
102
|
+
<>
|
|
103
|
+
<TryStatement>// try something</TryStatement>
|
|
104
|
+
<CatchClause parameter={{ name: "error", type: "Error", refkey: rk }}>
|
|
105
|
+
<StatementList>
|
|
106
|
+
{rk}
|
|
107
|
+
<VarDeclaration name="message" type="string">
|
|
108
|
+
{rk}.message
|
|
109
|
+
</VarDeclaration>
|
|
110
|
+
</StatementList>
|
|
111
|
+
</CatchClause>
|
|
112
|
+
</>,
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
expect(text).toBe(d`
|
|
116
|
+
try {
|
|
117
|
+
// try something
|
|
118
|
+
} catch (error: Error) {
|
|
119
|
+
error;
|
|
120
|
+
const message: string = error.message;
|
|
121
|
+
}
|
|
122
|
+
`);
|
|
123
|
+
});
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { onCleanup, type Children } from "@alloy-js/core";
|
|
2
|
+
import { useTSNamePolicy } from "../name-policy.js";
|
|
3
|
+
import type { ParameterDescriptor } from "../parameter-descriptor.js";
|
|
4
|
+
import { createValueSymbol, TSSymbolFlags } from "../symbols/index.js";
|
|
5
|
+
import { BlockScope } from "./BlockScope.jsx";
|
|
6
|
+
|
|
7
|
+
export interface TryStatementProps {
|
|
8
|
+
children: Children;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A try statement.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* <TryStatement>
|
|
17
|
+
* // risky operation
|
|
18
|
+
* </TryStatement>
|
|
19
|
+
* <CatchClause parameter="error">
|
|
20
|
+
* console.error(error);
|
|
21
|
+
* </CatchClause>
|
|
22
|
+
* ```
|
|
23
|
+
* renders to
|
|
24
|
+
* ```ts
|
|
25
|
+
* try {
|
|
26
|
+
* // risky operation
|
|
27
|
+
* } catch (error) {
|
|
28
|
+
* console.error(error);
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function TryStatement(props: TryStatementProps) {
|
|
33
|
+
return (
|
|
34
|
+
<>
|
|
35
|
+
try <BlockScope>{props.children}</BlockScope>
|
|
36
|
+
</>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface CatchClauseProps {
|
|
41
|
+
parameter?: ParameterDescriptor | string;
|
|
42
|
+
children: Children;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A catch clause of a try statement.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```tsx
|
|
50
|
+
* <CatchClause parameter={{ name: "error", type: "unknown" }}>
|
|
51
|
+
* console.error(error);
|
|
52
|
+
* </CatchClause>
|
|
53
|
+
* ```
|
|
54
|
+
* renders to
|
|
55
|
+
* ```ts
|
|
56
|
+
* catch (error: unknown) {
|
|
57
|
+
* console.error(error);
|
|
58
|
+
* }
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* The parameter can be omitted for a catch-all clause, or provided as a string
|
|
63
|
+
* or {@link ParameterDescriptor}. When using a descriptor, a refkey can be provided
|
|
64
|
+
* to reference the parameter within the catch block. Note that TypeScript only allows
|
|
65
|
+
* `any` or `unknown` as catch parameter types.
|
|
66
|
+
*/
|
|
67
|
+
export function CatchClause(props: CatchClauseProps) {
|
|
68
|
+
if (!props.parameter) {
|
|
69
|
+
return (
|
|
70
|
+
<>
|
|
71
|
+
{" "}
|
|
72
|
+
catch <BlockScope>{props.children}</BlockScope>
|
|
73
|
+
</>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const namePolicy = useTSNamePolicy();
|
|
78
|
+
const paramDesc =
|
|
79
|
+
typeof props.parameter === "string" ?
|
|
80
|
+
{ name: props.parameter }
|
|
81
|
+
: props.parameter;
|
|
82
|
+
|
|
83
|
+
const symbol = createValueSymbol(paramDesc.name, {
|
|
84
|
+
refkeys: paramDesc.refkey,
|
|
85
|
+
tsFlags: TSSymbolFlags.ParameterSymbol,
|
|
86
|
+
metadata: paramDesc.metadata,
|
|
87
|
+
namePolicy: namePolicy.for("parameter"),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
onCleanup(() => {
|
|
91
|
+
symbol.delete();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const param = (
|
|
95
|
+
<>
|
|
96
|
+
{symbol.name}
|
|
97
|
+
{paramDesc.type && <>: {paramDesc.type}</>}
|
|
98
|
+
</>
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<>
|
|
103
|
+
{" "}
|
|
104
|
+
catch ({param}) <BlockScope>{props.children}</BlockScope>
|
|
105
|
+
</>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface FinallyClauseProps {
|
|
110
|
+
children: Children;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* A finally clause of a try statement.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```tsx
|
|
118
|
+
* <TryStatement>
|
|
119
|
+
* // risky operation
|
|
120
|
+
* </TryStatement>
|
|
121
|
+
* <FinallyClause>
|
|
122
|
+
* // cleanup
|
|
123
|
+
* </FinallyClause>
|
|
124
|
+
* ```
|
|
125
|
+
* renders to
|
|
126
|
+
* ```ts
|
|
127
|
+
* try {
|
|
128
|
+
* // risky operation
|
|
129
|
+
* } finally {
|
|
130
|
+
* // cleanup
|
|
131
|
+
* }
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export function FinallyClause(props: FinallyClauseProps) {
|
|
135
|
+
return (
|
|
136
|
+
<>
|
|
137
|
+
{" "}
|
|
138
|
+
finally <BlockScope>{props.children}</BlockScope>
|
|
139
|
+
</>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
@@ -28,15 +28,24 @@ export function TSConfigJson(props: TSConfigJsonProps) {
|
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
effect(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
effect(
|
|
32
|
+
() => {
|
|
33
|
+
const dirs = includeDirs();
|
|
34
|
+
if (dirs.length === 1) {
|
|
35
|
+
pkg.outFileMapper.value = (path: string) =>
|
|
36
|
+
join(outDir, relative(dirs[0], path));
|
|
37
|
+
} else {
|
|
38
|
+
pkg.outFileMapper.value = (path: string) => join(outDir, path);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
undefined,
|
|
42
|
+
{
|
|
43
|
+
debug: {
|
|
44
|
+
name: "TsConfigJson:outFileMapper",
|
|
45
|
+
type: "render",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
);
|
|
40
49
|
|
|
41
50
|
const jsonContent = memo(() => {
|
|
42
51
|
const jsonContent = {
|
|
@@ -5,18 +5,18 @@ import { ensureTypeRefContext } from "./TypeRefContext.jsx";
|
|
|
5
5
|
|
|
6
6
|
export interface TypeDeclarationProps extends CommonDeclarationProps {}
|
|
7
7
|
|
|
8
|
-
export const TypeDeclaration = ensureTypeRefContext(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
);
|
|
8
|
+
export const TypeDeclaration = ensureTypeRefContext(function TypeDeclaration(
|
|
9
|
+
props: TypeDeclarationProps,
|
|
10
|
+
) {
|
|
11
|
+
return (
|
|
12
|
+
<>
|
|
13
|
+
<Show when={Boolean(props.doc)}>
|
|
14
|
+
<JSDoc children={props.doc} />
|
|
15
|
+
<hbr />
|
|
16
|
+
</Show>
|
|
17
|
+
<Declaration {...props} kind="type" nameKind="type">
|
|
18
|
+
type <Name /> = {props.children};
|
|
19
|
+
</Declaration>
|
|
20
|
+
</>
|
|
21
|
+
);
|
|
22
|
+
});
|
|
@@ -33,8 +33,8 @@ export const TypeRefContext = ({ children }: TypeRefContextProps) => {
|
|
|
33
33
|
*/
|
|
34
34
|
export function ensureTypeRefContext<TProps>(
|
|
35
35
|
Comp: Component<TProps>,
|
|
36
|
-
):
|
|
37
|
-
return (props: TProps)
|
|
36
|
+
): Component<TProps> {
|
|
37
|
+
return function EnsureTypeRefContext(props: TProps) {
|
|
38
38
|
const ref = isTypeRefContext();
|
|
39
39
|
if (!ref) {
|
|
40
40
|
return (
|
package/src/components/index.ts
CHANGED
|
@@ -35,6 +35,7 @@ export * from "./Reference.js";
|
|
|
35
35
|
export * from "./SingleLineCommentBlock.jsx";
|
|
36
36
|
export * from "./SourceFile.js";
|
|
37
37
|
export * from "./SwitchStatement.jsx";
|
|
38
|
+
export * from "./TryStatement.jsx";
|
|
38
39
|
export * from "./TsConfigJson.js";
|
|
39
40
|
export * from "./TypeDeclaration.js";
|
|
40
41
|
export * from "./TypeRefContext.jsx";
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ComponentContext,
|
|
3
|
+
createNamedContext,
|
|
4
|
+
useContext,
|
|
5
|
+
} from "@alloy-js/core";
|
|
2
6
|
|
|
3
7
|
interface TypeRefContext {
|
|
4
8
|
/** If in a type context */
|
|
@@ -9,7 +13,7 @@ interface TypeRefContext {
|
|
|
9
13
|
* Provides scopes for instance and static private members.
|
|
10
14
|
*/
|
|
11
15
|
export const TypeRefContext: ComponentContext<TypeRefContext> =
|
|
12
|
-
|
|
16
|
+
createNamedContext<TypeRefContext>("@alloy-js/typescript TypeRef");
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
19
|
* @returns 'true' if in a type context, 'false' if in a value context.
|
package/src/create-package.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type Binder,
|
|
3
|
+
createScope,
|
|
4
|
+
createSymbol,
|
|
3
5
|
getSymbolCreatorSymbol,
|
|
4
6
|
OutputMemberSpace,
|
|
5
7
|
type Refkey,
|
|
@@ -136,7 +138,7 @@ function assignMembers(
|
|
|
136
138
|
const memberKey = keys[namespace][memberObj.name];
|
|
137
139
|
if (!memberKey) continue; // Skip if key doesn't exist
|
|
138
140
|
|
|
139
|
-
const memberSym =
|
|
141
|
+
const memberSym = createSymbol(TSOutputSymbol, memberObj.name, space, {
|
|
140
142
|
binder,
|
|
141
143
|
refkeys: memberKey,
|
|
142
144
|
export: false,
|
|
@@ -179,7 +181,8 @@ function createSymbols(
|
|
|
179
181
|
props: CreatePackageProps<PackageDescriptor>,
|
|
180
182
|
refkeys: Record<string | typeof packageScopeSymbol, any>,
|
|
181
183
|
) {
|
|
182
|
-
const pkgScope =
|
|
184
|
+
const pkgScope = createScope(
|
|
185
|
+
TSPackageScope,
|
|
183
186
|
props.name,
|
|
184
187
|
props.version,
|
|
185
188
|
`node_modules/${props.name}`,
|
|
@@ -193,7 +196,7 @@ function createSymbols(
|
|
|
193
196
|
|
|
194
197
|
for (const [path, symbols] of Object.entries(props.descriptor)) {
|
|
195
198
|
const keys = path === "." ? refkeys : refkeys[path];
|
|
196
|
-
const moduleScope =
|
|
199
|
+
const moduleScope = createScope(TSModuleScope, path, pkgScope, {
|
|
197
200
|
binder,
|
|
198
201
|
});
|
|
199
202
|
|
|
@@ -201,11 +204,17 @@ function createSymbols(
|
|
|
201
204
|
|
|
202
205
|
if (symbols.default) {
|
|
203
206
|
const key = keys.default;
|
|
204
|
-
const sym =
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
const sym = createSymbol(
|
|
208
|
+
TSOutputSymbol,
|
|
209
|
+
symbols.default,
|
|
210
|
+
moduleScope.values,
|
|
211
|
+
{
|
|
212
|
+
binder,
|
|
213
|
+
refkeys: key,
|
|
214
|
+
export: true,
|
|
215
|
+
default: true,
|
|
216
|
+
},
|
|
217
|
+
);
|
|
209
218
|
moduleScope.exportedSymbols.set(key, sym);
|
|
210
219
|
}
|
|
211
220
|
|
|
@@ -215,13 +224,18 @@ function createSymbols(
|
|
|
215
224
|
{ name: exportedName }
|
|
216
225
|
: exportedName;
|
|
217
226
|
const key = keys[namedRef.name];
|
|
218
|
-
const ownerSym =
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
227
|
+
const ownerSym = createSymbol(
|
|
228
|
+
TSOutputSymbol,
|
|
229
|
+
namedRef.name,
|
|
230
|
+
moduleScope.values,
|
|
231
|
+
{
|
|
232
|
+
binder,
|
|
233
|
+
refkeys: key,
|
|
234
|
+
export: true,
|
|
235
|
+
default: false,
|
|
236
|
+
hasInstanceMembers: !!namedRef.instanceMembers?.length,
|
|
237
|
+
},
|
|
238
|
+
);
|
|
225
239
|
moduleScope.exportedSymbols.set(key, ownerSym);
|
|
226
240
|
|
|
227
241
|
assignMembers(
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
+
import { OutputSymbol } from "@alloy-js/core";
|
|
1
2
|
import { TSOutputSymbol, TSSymbolFlags } from "./symbols/index.js";
|
|
2
3
|
|
|
3
|
-
export function tsNameConflictResolver(
|
|
4
|
-
|
|
5
|
-
symbols: TSOutputSymbol[],
|
|
6
|
-
) {
|
|
7
|
-
const goodNamedSymbols = symbols.filter(
|
|
4
|
+
export function tsNameConflictResolver(name: string, symbols: OutputSymbol[]) {
|
|
5
|
+
const goodNamedSymbols = (symbols as TSOutputSymbol[]).filter(
|
|
8
6
|
(s) => ~s.tsFlags & TSSymbolFlags.LocalImportSymbol,
|
|
9
7
|
);
|
|
10
|
-
const badNamedSymbols = symbols.filter(
|
|
8
|
+
const badNamedSymbols = (symbols as TSOutputSymbol[]).filter(
|
|
11
9
|
(s) => s.tsFlags & TSSymbolFlags.LocalImportSymbol,
|
|
12
10
|
);
|
|
13
11
|
let nameCount = 1;
|
|
12
|
+
if (goodNamedSymbols.length >= 1) {
|
|
13
|
+
// The first "good" symbol owns the plain name. Clear any prior
|
|
14
|
+
// deconflict rename so survivors reclaim the original name when a
|
|
15
|
+
// collision is resolved.
|
|
16
|
+
goodNamedSymbols[0].deconflictedName = undefined;
|
|
17
|
+
}
|
|
14
18
|
if (goodNamedSymbols.length > 1) {
|
|
15
19
|
for (const sym of goodNamedSymbols.slice(1)) {
|
|
16
|
-
sym.
|
|
20
|
+
sym.deconflictedName = name + "_" + nameCount++;
|
|
17
21
|
}
|
|
18
22
|
}
|
|
19
23
|
for (const sym of badNamedSymbols) {
|
|
20
|
-
sym.
|
|
24
|
+
sym.deconflictedName = name + "_" + nameCount++;
|
|
21
25
|
}
|
|
22
26
|
}
|
package/src/symbols/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createComponent,
|
|
3
|
+
createScope,
|
|
4
|
+
createSymbol,
|
|
3
5
|
Namekey,
|
|
4
6
|
onCleanup,
|
|
5
7
|
OutputScopeOptions,
|
|
@@ -25,7 +27,13 @@ export function createTypeAndValueSymbol(
|
|
|
25
27
|
) {
|
|
26
28
|
const scope = useLexicalScope();
|
|
27
29
|
const spaces = scope ? [scope.types, scope.values] : [];
|
|
28
|
-
|
|
30
|
+
const binder = options.binder ?? scope?.binder;
|
|
31
|
+
const symbol = createSymbol(TSOutputSymbol, name, spaces, {
|
|
32
|
+
...options,
|
|
33
|
+
binder,
|
|
34
|
+
});
|
|
35
|
+
onCleanup(() => symbol.delete());
|
|
36
|
+
return symbol;
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
export function createTypeSymbol(
|
|
@@ -39,7 +47,13 @@ export function createTypeSymbol(
|
|
|
39
47
|
);
|
|
40
48
|
}
|
|
41
49
|
const spaces = scope ? [scope.types] : [];
|
|
42
|
-
|
|
50
|
+
const binder = options.binder ?? scope?.binder;
|
|
51
|
+
const symbol = createSymbol(TSOutputSymbol, name, spaces, {
|
|
52
|
+
...options,
|
|
53
|
+
binder,
|
|
54
|
+
});
|
|
55
|
+
onCleanup(() => symbol.delete());
|
|
56
|
+
return symbol;
|
|
43
57
|
}
|
|
44
58
|
|
|
45
59
|
export function createValueSymbol(
|
|
@@ -53,11 +67,17 @@ export function createValueSymbol(
|
|
|
53
67
|
);
|
|
54
68
|
}
|
|
55
69
|
const spaces = scope ? [scope.values] : [];
|
|
56
|
-
|
|
70
|
+
const binder = options.binder ?? scope?.binder;
|
|
71
|
+
const symbol = createSymbol(TSOutputSymbol, name, spaces, {
|
|
72
|
+
...options,
|
|
73
|
+
binder,
|
|
74
|
+
});
|
|
75
|
+
onCleanup(() => symbol.delete());
|
|
76
|
+
return symbol;
|
|
57
77
|
}
|
|
58
78
|
|
|
59
79
|
export function createTransientValueSymbol() {
|
|
60
|
-
return
|
|
80
|
+
return createSymbol(TSOutputSymbol, "transient-value", undefined, {
|
|
61
81
|
transient: true,
|
|
62
82
|
});
|
|
63
83
|
}
|
|
@@ -67,7 +87,11 @@ export function createStaticMemberSymbol(
|
|
|
67
87
|
options: CreateTsSymbolOptions = {},
|
|
68
88
|
) {
|
|
69
89
|
const owner = useMemberOwner();
|
|
70
|
-
|
|
90
|
+
const binder = options.binder ?? owner.binder;
|
|
91
|
+
return createSymbol(TSOutputSymbol, name, owner.staticMembers, {
|
|
92
|
+
...options,
|
|
93
|
+
binder,
|
|
94
|
+
});
|
|
71
95
|
}
|
|
72
96
|
|
|
73
97
|
export function createInstanceMemberSymbol(
|
|
@@ -75,7 +99,11 @@ export function createInstanceMemberSymbol(
|
|
|
75
99
|
options: CreateTsSymbolOptions = {},
|
|
76
100
|
) {
|
|
77
101
|
const owner = useMemberOwner();
|
|
78
|
-
|
|
102
|
+
const binder = options.binder ?? owner.binder;
|
|
103
|
+
return createSymbol(TSOutputSymbol, name, owner.instanceMembers, {
|
|
104
|
+
...options,
|
|
105
|
+
binder,
|
|
106
|
+
});
|
|
79
107
|
}
|
|
80
108
|
|
|
81
109
|
export function createPrivateStaticMemberSymbol(
|
|
@@ -83,7 +111,11 @@ export function createPrivateStaticMemberSymbol(
|
|
|
83
111
|
options: CreateTsSymbolOptions = {},
|
|
84
112
|
) {
|
|
85
113
|
const owner = useMemberOwner();
|
|
86
|
-
|
|
114
|
+
const binder = options.binder ?? owner.binder;
|
|
115
|
+
return createSymbol(TSOutputSymbol, name, owner.privateStaticMembers, {
|
|
116
|
+
...options,
|
|
117
|
+
binder,
|
|
118
|
+
});
|
|
87
119
|
}
|
|
88
120
|
|
|
89
121
|
export function createPrivateInstanceMemberSymbol(
|
|
@@ -91,7 +123,11 @@ export function createPrivateInstanceMemberSymbol(
|
|
|
91
123
|
options: CreateTsSymbolOptions = {},
|
|
92
124
|
) {
|
|
93
125
|
const owner = useMemberOwner();
|
|
94
|
-
|
|
126
|
+
const binder = options.binder ?? owner.binder;
|
|
127
|
+
return createSymbol(TSOutputSymbol, name, owner.privateInstanceMembers, {
|
|
128
|
+
...options,
|
|
129
|
+
binder,
|
|
130
|
+
});
|
|
95
131
|
}
|
|
96
132
|
|
|
97
133
|
export function createMemberSymbol(
|
|
@@ -120,7 +156,8 @@ export function createLexicalScope(
|
|
|
120
156
|
) {
|
|
121
157
|
const parent = useTSScope();
|
|
122
158
|
|
|
123
|
-
|
|
159
|
+
const binder = options.binder ?? parent?.binder;
|
|
160
|
+
return createScope(TSLexicalScope, name, parent, { ...options, binder });
|
|
124
161
|
}
|
|
125
162
|
|
|
126
163
|
export function createMemberScope(
|
|
@@ -129,7 +166,11 @@ export function createMemberScope(
|
|
|
129
166
|
options: OutputScopeOptions = {},
|
|
130
167
|
) {
|
|
131
168
|
const parent = useTSScope();
|
|
132
|
-
|
|
169
|
+
const binder = options.binder ?? parent?.binder ?? ownerSymbol.binder;
|
|
170
|
+
return createScope(TSMemberScope, name, parent, ownerSymbol, {
|
|
171
|
+
...options,
|
|
172
|
+
binder,
|
|
173
|
+
});
|
|
133
174
|
}
|
|
134
175
|
|
|
135
176
|
export function decl(namekey: Namekey, options?: CreateTsSymbolOptions) {
|