Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tomnz opened this issue Mar 10, 2025 · 3 comments

Comments

@tomnz
Copy link

tomnz commented Mar 10, 2025

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
@scotttrinh
Copy link
Collaborator

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?

@tomnz
Copy link
Author

tomnz commented Mar 10, 2025

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
Copy link
Author

tomnz commented Mar 10, 2025

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: "" },
}));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants