bombillazo
bombillazo•16mo ago

Does Deno support `export type` statements?

Hello, we are using Deno + TS and I am getting the following error if I try to export a type from another file:
Uncaught SyntaxError: Unexpected token 'export'
Uncaught SyntaxError: Unexpected token 'export'
Is this something possible in Deno?
1 Reply
Deno AI Helper
Deno AI Helper•16mo ago
Yes, Deno does support export type statements. According to the documentation, if you're encountering an error when trying to export types, it might be due to the way you're importing or exporting them. In Deno 1.4 and later, you should use import type and export type for type-only imports and exports. This helps ensure that when the code is emitted, all the types are erased. Here's an example:
// Good
import type { MyType } from "./mod.ts";
export type { MyType } from "./mod.ts";
// Good
import type { MyType } from "./mod.ts";
export type { MyType } from "./mod.ts";
If you're still encountering issues, please ensure that you're running a version of Deno that supports these features (Deno 1.4 or later), and that your syntax matches the example above. 🦕

Did you find this page helpful?