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.

Allow type declarations from extend layers

See original GitHub issue

Adding type augmentations from the main layer is possible using top-level index.d.ts (and what we recommend in docs. We could also support it for all layers for augmenting NuxtApp (plugin injections) and AppConfigInput (app.config from themes).

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
pi0commented, Sep 9, 2022

Would you please help on supporting index.d.ts from layers? 🙏🏼

1reaction
danielroecommented, Sep 9, 2022

I think it’s a nice idea (and possibly worth implementing), but I think there are some solutions to consider first:

  1. Use other files. Any declarations you add in any file within the layer that is used in the nuxt build should already work for this purpose, and in fact I would personally recommend co-locating the definition with the usage.
  2. Prefer inference. For example, plugins or app config can work this way.

For app config, the following might do it (though I haven’t yet tested):

export default defineAppConfig({
  myTheme: {} as Partial<MyThemeConfig>
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

Extending object-like types with interfaces in TypeScript
Let's look at how to take advantage of declaration merging, as well as some cases of when you might want to. Expanding interfaces...
Read more >
TSConfig Reference - Docs on every TSConfig option
Without this flag, TypeScript will allow you to use the dot syntax to ... rootDirs can be used to provide a separate “type...
Read more >
Extending existing @types type definition to include missing ...
You can declare an augmentation for the module: // leaflet.aug.d.ts import 'leaflet'; declare module 'leaflet' { export interface ...
Read more >
TypeScript: Enhance Variable Types with Declaration Merging
Typically, when we use external libraries that come with their own type declarations it sometimes is necessary to extend a type with some...
Read more >
How To Use Generics in TypeScript - DigitalOcean
This generic type accepts a single type parameter, T . Inside the type declaration itself, you are checking if the type T extends...
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