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

🐛 BUG: Cannot import TS types and interfaces #12144

Closed
1 task
adamarutyunov opened this issue Oct 7, 2024 · 1 comment
Closed
1 task

🐛 BUG: Cannot import TS types and interfaces #12144

adamarutyunov opened this issue Oct 7, 2024 · 1 comment
Labels
needs triage Issue needs to be triaged

Comments

@adamarutyunov
Copy link

adamarutyunov commented Oct 7, 2024

Astro Info

Astro                    v4.15.11
Node                     v21.7.3
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/tailwind
                         @astrojs/react

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I have encountered the same bug that was fixed three years ago: #3787

In an astro component, it is not possible to import an interface or a type from a typescript file.

The behaviour is the same:

  • It does not matter if .ts is included or not (import x from "./x.ts" vs import x from "./x");
  • It does not matter if the export is default or not;
  • It does not work neither with export type nor `export interface;
  • Imports and exports of any other JS native items (functions/objects/etc) work perfectly;

The only difference is that the “Weird workaround” (to add any other non-TS export in the file) does not work anymore.

What's the expected result?

Interfaces and types should be able to be imported as it is convenient to use these repeatable items in different components.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-dkmvrf?file=src%2Fpages%2Findex.astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Oct 7, 2024
@Princesseuh
Copy link
Member

TypeScript types don't have runtime values, as such it's normal that they'll always be undefined when trying to console.log them.

In an editor with intellisense, you'll get a warning when trying to do so:
image

The actual type works fine:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants