Description
Describe the bug
I used to be able to use a local build emitter to generate code for testing or debugging purposes.
tsp compile ./ --emit c:\Users\<username>\source\autorest.powershell\packages\typespec-powershell
However, after upgrading to TypeSpec/Compiler 0.67.1, I found that it no longer works.
I noticed two major issues
- It will report issues as below.
Diagnostics were reported during compilation:
../C:/Users/xidi/source/autorest.powershell/tests-upgrade/tests-emitter/AppComplianceAutomation.Management/main.tsp:21:1 - error @azure-tools/typespec-azure-resource-manager/single-arm-provider: Only one @armProviderNamespace can be declared in a typespec spec at once.
> 21 | @armProviderNamespace
| ^^^^^^^^^^^^^^^^^^^^^
../C:/Users/xidi/source/autorest.powershell/tests-upgrade/tests-emitter/AppComplianceAutomation.Management/resources/WebhookResource.tsp:29:7 - error @azure-tools/typespec-azure-resource-manager/arm-resource-missing-arm-namespace: The @armProviderNamespace decorator must be used to define the ARM namespace of the service. This is best applied to the file-level namespace.
> 29 | model WebhookResource extends Azure.ResourceManager.Foundations.ProxyResource {
| ^^^^^^^^^^^^^^^
../C:/Users/xidi/source/autorest.powershell/tests-upgrade/tests-emitter/AppComplianceAutomation.Management/resources/SnapshotResource.tsp:23:7 - error @azure-tools/typespec-azure-resource-manager/arm-resource-missing-arm-namespace: The @armProviderNamespace decorator must be used to define the ARM namespace of the service. This is best applied to the file-level namespace.
> 23 | model SnapshotResource extends Azure.ResourceManager.Foundations.ProxyResource {
| ^^^^^^^^^^^^^^^^
../C:/Users/xidi/source/autorest.powershell/tests-upgrade/tests-emitter/AppComplianceAutomation.Management/resources/ScopingConfigurationResource.tsp:31:7 - error @azure-tools/typespec-azure-resource-manager/arm-resource-missing-arm-namespace: The @armProviderNamespace decorator must be used to define the ARM namespace of the service. This is best applied to the file-level namespace.
> 31 | model ScopingConfigurationResource
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../C:/Users/xidi/source/autorest.powershell/tests-upgrade/tests-emitter/AppComplianceAutomation.Management/resources/EvidenceResource.tsp:25:7 - error @azure-tools/typespec-azure-resource-manager/arm-resource-missing-arm-namespace: The @armProviderNamespace decorator must be used to define the ARM namespace of the service. This is best applied to the file-level namespace.
> 25 | model EvidenceResource extends Azure.ResourceManager.Foundations.ProxyResource {
| ^^^^^^^^^^^^^^^^
../C:/Users/xidi/source/autorest.powershell/tests-upgrade/tests-emitter/AppComplianceAutomation.Management/resources/ReportResource.tsp:25:7 - error @azure-tools/typespec-azure-resource-manager/arm-resource-missing-arm-namespace: The @armProviderNamespace decorator must be used to define the ARM namespace of the service. This is best applied to the file-level namespace.
> 25 | model ReportResource extends Azure.ResourceManager.Foundations.ProxyResource {
| ^^^^^^^^^^^^^^
../C:/Users/xidi/source/autorest.powershell/tests-upgrade/tests-emitter/AppComplianceAutomation.Management/resources/ReportResource.tsp:25:7 - error @azure-tools/typespec-azure-resource-manager/arm-resource-missing: No @armResource registration found for type ReportResource
> 25 | model ReportResource extends Azure.ResourceManager.Foundations.ProxyResource {
| ^^^^^^^^^^^^^^
../C:/Users/xidi/source/autorest.powershell/tests-upgrade/tests-emitter/AppComplianceAutomation.Management/resources/WebhookResource.tsp:29:7 - error @azure-tools/typespec-azure-resource-manager/parent-type: Parent type ReportResource of WebhookResource is not registered as an ARM resource type.
> 29 | model WebhookResource extends Azure.ResourceManager.Foundations.ProxyResource {
| ^^^^^^^^^^^^^^^
../C:/Users/xidi/source/autorest.powershell/tests-upgrade/tests-emitter/AppComplianceAutomation.Management/resources/ReportResource.tsp:25:7 - error @azure-tools/typespec-azure-resource-manager/arm-resource-missing: No @armResource registration found for type ReportResource
> 25 | model ReportResource extends Azure.ResourceManager.Foundations.ProxyResource {
| ^^^^^^^^^^^^^^
../C:/Users/xidi/source/autorest.powershell/tests-upgrade/tests-emitter/AppComplianceAutomation.Management/resources/WebhookResource.tsp:29:7 - error @azure-tools/typespec-azure-resource-manager/parent-type: Parent type ReportResource of WebhookResource is not registered as an ARM resource type.
> 29 | model WebhookResource extends Azure.ResourceManager.Foundations.ProxyResource {
| ^^^^^^^^^^^^^^^
../C:/Users/xidi/source/autorest.powershell/tests-upgrade/tests-emitter/AppComplianceAutomation.Management/resources/ReportResource.tsp:25:7 - error @azure-tools/typespec-azure-resource-manager/arm-resource-missing: No @armResource registration found for type ReportResource
> 25 | model ReportResource extends Azure.ResourceManager.Foundations.ProxyResource {
| ^^^^^^^^^^^^^^
../C:/Users/xidi/source/autorest.powershell/tests-upgrade/tests-emitter/AppComplianceAutomation.Management/resources/SnapshotResource.tsp:23:7 - error @azure-tools/typespec-azure-resource-manager/parent-type: Parent type ReportResource of SnapshotResource is not registered as an ARM resource type.
> 23 | model SnapshotResource extends Azure.ResourceManager.Foundations.ProxyResource {
| ^^^^^^^^^^^^^^^^
../C:/Users/xidi/source/autorest.powershell/tests-upgrade/tests-emitter/AppComplianceAutomation.Management/resources/ReportResource.tsp:25:7 - error @azure-tools/typespec-azure-resource-manager/arm-resource-missing: No @armResource registration found for type ReportResource
> 25 | model ReportResource extends Azure.ResourceManager.Foundations.ProxyResource {
| ^^^^^^^^^^^^^^
...
- The API listServices will return two duplicated services.
Some investigation
The root cause of the issue appears to be the presence of two copies of TypeSpec/Compiler: one in my emitter project and another in my test project.
How to workaround the issue
I can work around the issue by packaging my emitter locally and then installing the emitter package. However, this process is very inconvenient for testing and debugging my emitter.
Reproduction
- Install node 20 and rush.
- Clone the repo https://github.com/dolauli/autorest.powershell/tree/tspupgrade
- Go to the root folder and execute
rush update
andrush rebuild
- Go to tests-upgrade/tests-emitter, edit package.json, remove
"@azure-tools/typespec-powershell": "file:../../common/temp/artifacts/packages/azure-tools-typespec-powershell-0.0.1.tgz",
and runnpm install
- Install tsp compiler
npm install -g @typespec/compiler@latest
- Go to tests-upgrade/tests-emitter/AppComplianceAutomation.Management and run
tsp compile ./ --emit c:\Users\<username>\source\autorest.powershell\packages\typespec-powershell
ornode --inspect-brk 'C:\Users\<username>\source\autorest.powershell\packages\typespec-powershell\node_modules\@typespec\compiler\cmd\tsp.js' compile ./ --emit C:\Users\<username>\source\autorest.powershell\packages\typespec-powershell
to debug the code - You will see the issues I mention above
Following the same steps with TSP before version 0.67.1, everything worked fine. You can check out the main branch (which still uses version 0.64.0) of the repo mentioned above to give it a try.
How to workaround
- Add
"@azure-tools/typespec-powershell": "file:../../common/temp/artifacts/packages/azure-tools-typespec-powershell-0.0.1.tgz",
back to the package.json file I mentioned above - Pack the emitter locally
rush publish --publish --pack --include-all --tag latest
- Go to tests-upgrade/tests-emitter/ and run
npm install
- Go to tests-upgrade/tests-emitter/AppComplianceAutomation.Management, and run
tsp compile ./ --emit @azure-tools/typespec-powershell
- Everything works fine
Checklist
- Follow our Code of Conduct
- Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.