Closed MarcusOtter closed 3 years ago
I've had similar problems trying to import types from Astro as well
I would rather like to be able to write interfaces in Astro files and export them so that I can use those types in consuming components.
Making interface imports work w/ regular typescript files would be great!
This is likely a compiler bug, will make sure this is fixed in the new compiler work.
The weird workaround suggested seems to just return undefined
rather than a valid type :/
Confirming that this is fixed in the astro@next
preview! See working demo.
Will put this in our milestone to be closed when that release is stable.
Following up on my previous comment, the team has decided to close out issues that have been confirmed as fixed by astro@0.21.0-next.0, astro@0.21.0-next.1, or astro@0.21.0-next.2. Our hope is that this will help the v0.21 milestone remain as actionable as possible.
To verify that this issue has been fixed, you may
astro@next
project on StackBlitzastro@next
preview
npm i astro@next
# If using Framework renderers...
npm i @astrojs/renderer-name@next
If you think we made a mistake, please reopen this issue!
If you run into any other problems with astro@next
, please open a new issue.
What package manager are you using?
npm
What operating system are you using?
Windows
Describe the Bug
In an astro component, it is not possible to import an interface from a typescript file.
.ts
is included or not (import x from "./x.ts"
vsimport x from "./x"
)import type ...
(see Example 2)Example 1
index.astro
:ToolInfo.ts
:Output:
Example 2
Same files as above, except
index.astro
has:Output:
Weird workaround
(thanks to @JSHSJ for finding this)
If you add any other export in the
ts
file it will work. With the same.astro
file from Example 1, this works as a temporary workaround in theToolInfo.ts
file:Steps to Reproduce
npm init astro
using templateStarter Kit (Generic)
info.ts
undersrc/pages
with the following content:index.astro
:Link to Minimal Reproducible Example (Optional)
No response