Question: "Cannot find namespace 'e' when using Typescript types from edgeql-js
See original GitHub issueHi! Sorry for a “question issue”, but I just can’t get past this myself.
- I’ve setup edgeql-js according to the docs.
- I’ve run
npx edgeql-js
to generate all code. - I can query for results with
e.select().run(client)
and so on.
But when I try to do use a generated TS type from the package, I run into this TS error:
error TS2503: Cannot find namespace 'e'
Code:
import e from './edgeql-js'; // auto-generated
// can't use my own types from the schema:
// error TS2503: Cannot find namespace 'e'
let c: e.Contact = {};
// not even built-types work:
// error TS2503: Cannot find namespace 'e'
let s: e.str = e.str('hey');
I’m following the docs in “Objects and paths”, which says:
All object types in your schema are reflected into the query builder, properly namespaced by module. … For convenience, the contents of the
default
module are also available at the top-level ofe
.
Are the docs talking about the Typescript type here? Or is it a reference to the EdgeQL schema type?
Thoughts
- Am I somehow misunderstanding the use of the types from edgeql-js? Am I not supposed to be using them like this? I was of the impression of that I could generate TS types and use in my app code. I understand the types are inferred when returning from a query function, but there are places where I’d like to get hold of the type too, for use in React component props, for instance.
- Am I importing
e
incorrectly?
Versions
Typescript: 4.5.5
EdgeDB (npm): 0.19.8
Many thanks!
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Typescript: Cannot find namespace - Stack Overflow
This causes a Typescript error on express() of Cannot invoke an expression whose type lacks a call signature. Type 'typeof e' has no...
Read more >AllowJs - ts-check - Cannot find namespace #19547 - GitHub
In my hypothetical example demo won't be globally available. How would it be possible to import types from that thirdParty plugin into a...
Read more >tslint error "Cannot find namespace 'MicrosoftGraph'. ts(2503 ...
I followed all the instructions npm install @microsoft/microsoft-graph-client --save npm install @microsoft/microsoft-graph-types --save-dev.
Read more >Cannot find namespace Context error in React (TypeScript)
To solve the "Cannot find name context" error in React typescript, use a `.tsx` extension for the files in which you use JSX,...
Read more >edge-js - npm
There are 53 other projects in the npm registry using edge-js. ... TypeScript icon, indicating that this package has built-in type declarations.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
PR for this here: https://github.com/edgedb/edgedb-js/pull/281
The
$XXXXXλShape
types are very different - that is a complex data structure representing that EdgeDB type. You can introspect what this type looks like by playing around with autocompletion:We don’t currently generate “plain” types like what you are describing, though I think we should. It’ll probably look something like this:
Should be possible to do @jaclarke thoughts? Internally it’ll look something like this: