[typespec-ts] Operation-level @access(Access.internal) is not respected (internal ops exposed, internal-only models exported)
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 90
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 156
Description
## Summary
The TypeScript (modular) emitter ignores operation-level `@access(Access.internal)` from `@azure-tools/typespec-client-generator-core`. Internal operations are still exposed as public methods on the client class, and models used only by internal operations are still re-exported from the package entry point.
Split out from the now-closed Azure/autorest.typescript#3739 (Item 6); the other items in that issue were already fixed.
## Expected behavior
Per the [TCGC `@access` decorator docs](https://azure.github.io/typespec-azure/docs/libraries/typespec-client-generator-core/reference/decorators/#@Azure.ClientGenerator.Core.access) and the [`access` spector scenario](https://github.com/Azure/typespec-azure/blob/main/packages/azure-http-specs/specs/azure/client-generator-core/access/main.tsp#L49-L93):
- Operations marked `@access(Access.internal)` **should be generated but not exposed** (not public methods on the client).
- Models/enums used **only** by internal operations **should be generated but not exported** from the package index.
## Actual behavior
This is reproducible in the checked-in generated output at `packages/typespec-ts/test/azureModularIntegration/generated/azure/client-generator-core/access`.
**1. Internal operations exposed as public client methods** (`src/accessClient.ts`):
All of the following are `@access(Access.internal)` yet are generated as public methods on `AccessClient`:
- `internal()` (from `SharedModelInOperation`)
- `noDecoratorInInternal()`, `internalDecoratorInInternal()`, `publicDecoratorInInternal()` (from `InternalOperation`)
- `operation()`, `discriminator()` (from `RelativeModelInOperation`)
**2. Internal-only models re-exported** (`src/index.ts`):
- `NoDecoratorModelInInternal`, `InternalDecoratorModelInInternal`
- `OuterModel`, `InnerModel`, `BaseModel`, `AbstractModel`, `AbstractModelUnion`, `RealModel` (used only by internal operations)
The public-access path works correctly; only the internal-access path is broken.
## Repro
The `access` spector case above already exercises this scenario, so it can serve as the test fixture. The emitter should:
1. Omit `@access(Access.internal)` operations from the generated classic client class (while still generating the underlying `api/operations.ts` function if needed).
2. Exclude internal-only models/enums from the package `index.ts` re-exports (while still generating them for internal use).
## Notes
- Models with an explicit `@access(Access.public)` override (e.g. `PublicDecoratorModelInInternal`) should still be exported even when used by an internal operation.
Contributor guide
Assessment
This issue has not been assessed yet.