edgedb-js icon indicating copy to clipboard operation
edgedb-js copied to clipboard

Exported variable 'fooQuery' has or is using name 'typenameSymbol' from external module but cannot be named

Open tomnz opened this issue 9 months ago • 4 comments

Code I'm trying to define a function that generates a query, such as:

export const caseQuery = (issueId: string) =>
  e.select(e.issue.Issue, () => ({
    id: true,
    openedAt: true,
    closedAt: true,
    title: true,
    documents: document => ({
      id: true,
      name: true,
      createdAt: true,
      participant: true,
      dataType: true,
      order_by: document.createdAt,
    }),
    filter_single: { id: issueId },
  }));

This previously seemed to work just fine with edgedb version 1.5.3, but breaks after updating to 2.0.1. I believe this PR is the culprit, as it adds the mentioned typenameSymbol stuff.

The error is as follows:

Exported variable 'caseQuery' has or is using name 'typenameSymbol' from external module "/workspace/src/ts/packages/gel/src/edgeql/path" but cannot be named. ts(4023)

(where packages/gel/src/edgeql is the codegen folder from edgedb generate edgeql-js).

The issue appears to pop up specifically when using the nested subquery for documents (or any subquery like that) - the error disappears after removing that field.

Schema

Too big to list here.

Generated EdgeQL

N/A

Error or desired behavior

Image

Versions (please complete the following information):

  • EdgeDB version: 5.6
  • gel-js version: 2.0.1
  • @gel/generate version: 0.6.2
  • TypeScript version: 5.5

tomnz avatar Mar 10 '25 03:03 tomnz

This is probably related to some tsconfig.json option on your side being different than the config we use and test. Can you provide some insight into your setup so we can see what the breakage is?

scotttrinh avatar Mar 10 '25 13:03 scotttrinh

Ours looks something like this (some pieces removed that didn't seem relevant, like paths and plugins).

{
  "include": [],
  "files": [],
  "exclude": [
    "**/jest.*",
    "**/node_modules/**/*",
    "**/dist/**/*",
    "**/types/**/*",
    "**/*.spec.ts",
    "**/*.spec.tsx"
  ],
  "compilerOptions": {
    "noErrorTruncation": true,
    "target": "esnext",
    "module": "commonjs",
    "moduleResolution": "node",
    "jsx": "react-jsx",
    "lib": ["esnext", "dom", "dom.iterable"],
    "types": ["node"],
    "typeRoots": ["node_modules/@types"],
    "baseUrl": ".",
    "rootDir": ".",
    "composite": true,
    "strict": true,
    "allowJs": true,
    "checkJs": false,
    "declaration": true,
    "declarationMap": true,
    "sourceMap": true,
    "importHelpers": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "noEmitHelpers": true,
    "noImplicitAny": true,
    "noImplicitReturns": false,
    "noUncheckedIndexedAccess": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "preserveConstEnums": true,
    "removeComments": false,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "skipDefaultLibCheck": true,
    "strictNullChecks": true,
    "useUnknownInCatchVariables": false,
    "experimentalDecorators": true
  }
}

tomnz avatar Mar 10 '25 16:03 tomnz

It does seem to be something specific to the nested subquery for documents there - removing that makes the error go away. Also the function piece seems unrelated - moving to a bare query assignment like this also results in the same error:

export const caseQuery = e.select(e.issue.Issue, () => ({
  id: true,
  openedAt: true,
  closedAt: true,
  title: true,
  documents: document => ({
    id: true,
    name: true,
    createdAt: true,
    participant: true,
    dataType: true,
    order_by: document.createdAt,
  }),
  filter_single: { id: "" },
}));

Something about it also seems to essentially crash TypeScript - after a while I can no longer save the file without triggering a message like this forever in VSCode, after which point the TypeScript warnings no longer update:

Image

EDIT: OK just removing the order_by also seemed to fix it - this worked without errors:

export const caseQuery = e.select(e.issue.Issue, () => ({
  id: true,
  openedAt: true,
  closedAt: true,
  title: true,
  documents: () => ({
    id: true,
    name: true,
    createdAt: true,
    participant: true,
    dataType: true,
  }),
  filter_single: { id: "" },
}));

tomnz avatar Mar 10 '25 16:03 tomnz

Someone from the discord has a temporary fix till this is fixed in the package

I found it in gel-js/packages/generate/src/syntax/path.ts, and locally fixed it by changing:

export const typenameSymbol = Symbol("typename");

As a temporary solution, I’m just importing it where needed:

import { typenameSymbol } from "../edgeql-js/path";

Gobot1234 avatar Aug 25 '25 23:08 Gobot1234