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.

RFC: Auto register for types

See original GitHub issue

Context:

For example, it would be great to have common types like Ref, ComputedRef globally available when using the Vue preset. I would expect the API to be like

{
  // auto importing for import
  imports: [
    'vue'
  ],
  // auto importing for types
  types: [
    'vue', // again, we could have presets for it.
    {
      vue: ['Ref', 'ComputedRef']
    }
  ]
}

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:45
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
terran42commented, Sep 23, 2022

@antfu Maybe I misunderstood, but is this not what you want?

Both seems to work, at least to my needs:

  • Ref<number> in index.ts has hint type Ref<T> = Ref<any>
  • Cmd+Click directs me to the right place in imports.d.ts or global.d.ts
  • Cmd+Click in imports.d.ts or global.d.ts on V.Ref or import('vue').Ref leads to definitions in Vue.

I’m happy with that.

1reaction
userquincommented, Oct 10, 2021

Right now I include global types on d.ts file using:

// Generated by 'unplugin-auto-import'
// We suggest you to commit this file into source control
import type {
  ComputedRef as __ComputedRef,
  Ref as __Ref  
} from 'vue'

declare global {
  type ComputedRef<T> = __ComputedRef<T>
  type Ref<T> = __Ref<T>
  const computed: typeof import('vue')['computed']
  ...
}
export{}

maybe we can use this another approach as suggested on issue on vue-global-api repo (both approaches work in IntelliJ, this latter would simplify the logic to generate the d.ts file and avoid adding redundant imports):

// Generated by 'unplugin-auto-import'
// We suggest you to commit this file into source control
declare global {
  type ComputedRef<T> = import('vue').ComputedRef<T>
  type Ref<T> = import('vue').Ref<T>
  const computed: typeof import('vue')['computed']
  ...
}
export {}
Read more comments on GitHub >

github_iconTop Results From Across the Web

RFC 4589 - Location Types Registry - IETF Datatracker
RFC 4589 Location Types Registry July 2006 1. Introduction This document creates a registry for location type tokens. We anticipate that the network, ......
Read more >
RFC 6838: Media Type Specifications and Registration ...
This document specifies the criteria for media type registrations and defines the procedures to be used to register media types (Section 5) as...
Read more >
Protocol Registries - Internet Assigned Numbers Authority
To obtain a registration in an existing registry, or to modify existing registrations, consult the relevant application form. For information on creating ...
Read more >
FAQs: What is Mexico's RFC, and What is it Used For?
The RFC is a registration number issued by Mexico's tax ... you are granted legal residency in Mexico you are automatically assigned a...
Read more >
Register targets with your target group - Elastic Load Balancing
For more information, see Attaching a load balancer to your Auto Scaling group ... The target type of your target group determines how...
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