Skip to content

[Bug]: When main.tsp only contain minimal import, emitter fails #5419

Open
@allenjzhang

Description

@allenjzhang

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,

cd sandbox
md [project] && cd [project]
npx tsp init ../../tsptemplate.json
npm install
npx tsp compile .

Checklist

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinglib:http-specsFor issues/prs related to the @typespec/http-specs package

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions