D
Deno

help

Does Deno support `export type` statements?

Bbombillazo9/7/2023
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?
DAHDeno AI Helper9/7/2023
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. 🦕

Looking for more? Join the community!