Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import interfaces instead of copying interfaces #184

Open
PhilippDehner opened this issue Apr 8, 2024 · 5 comments
Open

Import interfaces instead of copying interfaces #184

PhilippDehner opened this issue Apr 8, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@PhilippDehner
Copy link

What would you like to be added:

The interfaces in /src/components/CodeEditor/declarations are copied from the grafana library.

Why is this needed:

  • Duplicated code is not good
  • Adding new libraries would be easier (like d3)

Is this possible in principle?

@ZuperZee ZuperZee added the enhancement New feature or request label Apr 8, 2024
@ZuperZee
Copy link
Contributor

ZuperZee commented Apr 8, 2024

I did try importing it a while ago, but the file got very big, so I manually added the needed types

@PhilippDehner
Copy link
Author

Can you give me an example how to import it? If I just import the interfaces, they cannot be used in the code editor. I tried to do it with the getTemplateSrv interface. I replaced the interface with the library import, the build was successful, but not usable in the code editor.
Do I have to change something at the compiler?

@ZuperZee
Copy link
Contributor

ZuperZee commented Apr 8, 2024

I don't remember how I did it, I think I built the type files with tsc and linked them to the project. I could try to make a new attempt at this at some point again.

@PhilippDehner
Copy link
Author

@ZuperZee Would be nice :)

@ZuperZee
Copy link
Contributor

I've tested a little with the sizes on https://github.com/ZuperZee/declaration-dev.
To retrieve all the declarations for the types, the size is about 2.6 MB. Might be fine. It would be a 50x increase in the declaration size, but only 3x the size of the build output. The declarations would only be loaded in edit mode.

I haven't decided yet whether to add a build step to do this for the plugin, but I might.
Any feedback is welcome :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants