[Integration API] Support dynamic content construction in injectTypes based on file destination URL
#1211
Closed
sushichan044
started this conversation in
Proposal
Replies: 2 comments 1 reply
-
|
You can already get the dir using the result of |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Nice. Thanks @florian-lefebvre! Sounds like the use case is covered in this case and I imagine we most likely wouldn’t add a second API to do the same thing, so will close this. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Body
Summary
This proposal suggests allowing the
contentpassed toinjectTypes()to be set dynamically by using the output path of the.d.tsfile, which is the function's return value.Please check the Example section to see what this makes possible.
docs of
injectTypes(): https://docs.astro.build/en/reference/integrations-reference/#injecttypes-optionBackground & Motivation
Currently, we cannot generate type definitions that depend on the path of the
d.tsfile output byinjectTypes()in a single call.As a workaround, it's possible to get the output directory of the
.d.tsfile with a firstinjectTypes()call and then use a second call to inject the path-dependent type definitions.However, this is not ideal because it adds the extra type definitions from the first call to the user's type namespace.
My library uses this workaround to generate type definitions as follows:
https://github.com/sushichan044/astro-simple-feature-flags/blob/fe0b4a2cb245c1a13ad518b57b978494a229a980/packages/astro-simple-feature-flags/src/integration.ts#L42-L75
Goals
injectTypes()call.Example
I expect to be able to write code like this:
Beta Was this translation helpful? Give feedback.
All reactions