Skip to content

Commit

Permalink
fix(cli-utils): Fix undefined symbol crash and output bug in `turbo…
Browse files Browse the repository at this point in the history
…` command (#205)
  • Loading branch information
kitten authored Apr 15, 2024
1 parent 47b6964 commit e5f09db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/light-files-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@gql.tada/cli-utils": patch
---

Fix crash in `generate turbo` command when `returnType.symbol` is undefined
3 changes: 2 additions & 1 deletion packages/cli-utils/src/commands/turbo/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export async function* run(tty: TTY, opts: Options): AsyncIterable<ComposeInput>
}

cache = Object.assign(cache, signal.cache);
if ((warnings += signal.warnings.length)) {
warnings += signal.warnings.length;
if (signal.warnings.length) {
let buffer = logger.warningFile(signal.filePath);
for (const warning of signal.warnings) {
buffer += logger.warningMessage(warning);
Expand Down
4 changes: 3 additions & 1 deletion packages/cli-utils/src/commands/turbo/thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ async function* _runTurbo(params: TurboParams): AsyncIterableIterator<TurboSigna
for (const call of calls) {
const returnType = checker.getTypeAtLocation(call);
const argumentType = checker.getTypeAtLocation(call.arguments[0]);
if (returnType.symbol.getEscapedName() !== 'TadaDocumentNode') {
// NOTE: `returnType.symbol` is incorrectly typed and is in fact
// optional and not always present
if (!returnType.symbol || returnType.symbol.getEscapedName() !== 'TadaDocumentNode') {
const position = getFilePosition(sourceFile, call.getStart());
warnings.push({
message:
Expand Down

0 comments on commit e5f09db

Please sign in to comment.