microsoft / microsoft/typespec

Mutators/Realm issues with decorator that check the list of registered items in the map

Open
#5,836 0 comments 0 reactions 0 assignees View on GitHub
compiler:core design:needed needs-area triaged:core
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

```ts
export const $armProviderNamespace: ArmProviderNamespaceDecorator = (
context: DecoratorContext,
entity: Namespace,
armProviderNamespace?: string,
) => {
const { program } = context;

const override = isArmNamespaceOverride(program, entity);
const namespaceCount = program.stateMap(ArmStateKeys.armProviderNamespaces).size;
if (namespaceCount > 0 && !override) {
reportDiagnostic(program, {
code: "single-arm-provider",
target: context.decoratorTarget,
});
return;
}

}
```

with a decorator like that when it runs again in the mutated subgraph it will fail because it already finds one, the decorator doesn't take into account the current realm.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.