question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incomplete type definition for translatePathFromContext

See original GitHub issue

translatePathFromContext says it returns a Promise<DrupalTranslatedPath>

If you look at the code for that method, it returns:

return await this.translatePath(path, {
      withAuth: this.getAuthFromContextAndOptions(context, options),
    })

translatePath says it also returns a Promise<DrupalTranslatedPath>, but in fact can also return null:

if (!response?.ok) {
      // Do not throw errors here.
      // Otherwise next.js will catch error and throw a 500.
      // We want a 404.
      return null
    }

In our app code, with no-unnecessary-condition enabled, this causes a problem:

image

Typescript rightly doesn’t think path can be null, because it’s being told translatePathFromContext will always resolve to a DrupalTranslatedPath.

I imagine there are other signatures like this that are also not complete enough, any thoughts?

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
shadcncommented, Nov 16, 2022

Hmmm this does look like a bug. Let me look into it.

I wonder if I missed this because I have strict mode turned off.

0reactions
martdavidsoncommented, Dec 21, 2022

Not a blocker, and also heading into vacation so no worries! Happy holidays!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · chapter-three/next-drupal - GitHub
Incomplete type definition for translatePathFromContext area: next-drupal bug Something isn't working. #359 opened on Nov 16 by martdavidson.
Read more >
If struct type is defined in another .c file, it becomes incomplete ...
A translation unit, i.e. one .c file and its #include d .h files must be self-standing, containing in required order all the definitions...
Read more >
translatePathFromContext - Next.js for Drupal
Fetch info about a Drupal path from getStaticProps or getServerSideProps context. ... withAuth: boolean | DrupalClientAuth : Set the authentication method to use....
Read more >
Issue with "incomplete type" with CRTP : r/cpp_questions
CRTP uses the class it's defining as a template for a base class; thus it's not fully ... gives the error that T...
Read more >
error: variable 'fops' has initializer but incomplete type
as shown in the error file. so how to solve that error. Source code: #define MODULE #include<linux/kernel.h>
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found