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.

Auto import for types like `Ref`

See original GitHub issue

Environment

  • Operating System: Darwin
  • Node Version: v14.16.1
  • Nuxt Version: 3.0.0-27277498.850ef69
  • Package Manager: pnpm@6.17.1
  • Bundler: Vite
  • User Config: env, alias, srcDir, dev, build, publicRuntimeConfig, buildModules, css, vite
  • Runtime Modules: -
  • Build Modules: @vueuse/core/nuxt@6.8.0, @pinia/nuxt@0.1.2, ./app/t5-ui/nuxt

Reproduction

Describe the bug

I want to use Ref to type assertions, But:

image

Additional context

No response

Logs

No response

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ennioViscocommented, Jul 21, 2022

As for prior art, @userquin and I are doing experiments for type auto imports on unplugin-auto-import: antfu/unplugin-auto-import#62

Unfortunately, I don’t think we have achieved a good enough solution, once we alias the types, we have to forward the generics explicitly for every overload. And more importantly, the TSDocs get lost during alias. I guess we might need to hold this for a while, or maybe looking for some support from TypeScript.

@antfu do you have any flash update on this? From what I can see, the Ref type must still be manually imported

0reactions
ennioViscocommented, Sep 10, 2022

nuxt is in rc stage now, do we have an update on this yet? It’s easy to just add type imports, but that defies whole point of using nuxt. Would be great to have a framework centered solution for something as essential as this.

AFAIK it’s a current typescript limitation: you cannot re-export types

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there auto-import functionality for typescript in Visual Studio ...
Automatically searches for TypeScript definitions in workspace files and provides all known symbols as completion item to allow code completion ...
Read more >
Auto import | IntelliJ IDEA Documentation - JetBrains
Basic procedures to create and optimize imports in IntelliJ IDEA. Learn more how to import the missing import or XML namespace.
Read more >
Auto import namespaces/references - Visual Studio Feedback
I'm coming from Java and in Eclipse, you can configure auto import so that classes are imported automatically when you type them. This...
Read more >
Auto imports · Nuxt Concepts
In the documentation, every function that is not explicitly imported is auto-imported by Nuxt and can be used as-is in your code. You...
Read more >
Documentation - TypeScript 3.8
import type only imports declarations to be used for type annotations and declarations. It always gets fully erased, so there's no remnant of...
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