microsoft / microsoft/typespec
[Bug]: When main.tsp only contain minimal import, emitter fails
- Dominant language
- Java
- Stars
- 5.9k
- Forks
- 394
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 104
Description
### Describe the bug
Right after `tsp init` with empty project that only, `npx tsp compile .` fails.
```
Emitter "@typespec/http-client-csharp" crashed! This is a bug.
Please file an issue at https://github.com/Microsoft/typespec/issues
Error: Root client not found
at getRootApiVersions (file:///C:/github/typespec-e2e-demo/sandbox/junk/node_modules/@typespec/http-client-csharp/dist/emitter/lib/client-model-builder.js:130:15)
at createModel (file:///C:/github/typespec-e2e-demo/sandbox/junk/node_modules/@typespec/http-client-csharp/dist/emitter/lib/client-model-builder.js:23:11)
at Object.$onEmit [as emitFunction] (file:///C:/github/typespec-e2e-demo/sandbox/junk/node_modules/@typespec/http-client-csharp/dist/emitter/emitter.js:44:22)
at async runEmitter (file:///C:/github/typespec-e2e-demo/sandbox/junk/node_modules/@typespec/compiler/dist/src/core/program.js:366:13)
at async compile (file:///C:/github/typespec-e2e-demo/sandbox/junk/node_modules/@typespec/compiler/dist/src/core/program.js:123:9)
at async compileOnce (file:///C:/github/typespec-e2e-demo/sandbox/junk/node_modules/@typespec/compiler/dist/src/core/cli/actions/compile/compile.js:36:25)
at async compileAction (file:///C:/github/typespec-e2e-demo/sandbox/junk/node_modules/@typespec/compiler/dist/src/core/cli/actions/compile/compile.js:19:9)
```
main.tsp only contains following:
```
import "@typespec/http";
import "@typespec/rest";
import "@typespec/openapi3";
```
### Reproduction
In E2E repo,
```bash
cd sandbox
md [project] && cd [project]
npx tsp init ../../tsptemplate.json
npm install
npx tsp compile .
```
### Checklist
- [x] Follow our [Code of Conduct](https://github.com/microsoft/typespec/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- [x] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/Microsoft/typespec/discussions).
- [x] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
Contributor guide
Assessment
This issue has not been assessed yet.