# Re-Export An Imported Type

I have a TypeScript module that is defining an XState machine. Among other things, it imports the `DoneEventObject` type from `xstate`. I want to re-export that type so that any modules using this machine have access to that type definition.

This can be done a couple of ways. One way to import it under an aliased name and then assign + export it using the original name.

```typescript
import {Machine, DoneEventObject as _DoneEventObject} from 'xstate'

export type DoneEventObject = _DoneEventObject
```

This works, but adds some potential indirection and confusion through the double assignment.

Another way of doing this is to reference the type off the import statement as part of an assignment.

```typescript
import {Machine} from 'xstate'

export type DoneEventObject = import('xstate').DoneEventObject
```

This imports, assigns, and exports the type in a single statement.

[source](https://github.com/microsoft/TypeScript/issues/28481#issuecomment-552938424)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ploegert.gitbook.io/til/programmy/typescript/re-export-an-imported-type.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
