---
schema_version: "1"
id: fb1f98de31493d3e170c2e0b0a07b4e888f94d07df61b667736a9013b3238d52
title: Reusing Types from DataWeave Modules
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dataweave-type-reuse-modules.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dataweave-type-reuse-modules
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 5f668685ce19a78781f6bd40f2848d3b1eb8d7e3ed3e2ed033756e6075ef1b66
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

# Reusing Types from DataWeave Modules

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

To reuse types declared in other DataWeave modules, use the `import` directive:

DataWeave Module (`dw/Weather.dwl`):

```dataweave
%dw 2.0
type Weather = "cloudy" | "sunny" | "rainy" | "stormy"
type DetailedWeather = {temperature: Number, weather: Weather}
```

You can use those imported types as any other type in DataWeave, as constraints for variables and
functions or for pattern matching and checking types at runtime:

DataWeave Script:

```dataweave
%dw 2.0
output json
import * from dw::Weather


fun weatherMessage(todayWeather: Weather) =
    "The weather for today is: " ++ todayWeather
var worstPossibleWeather: DetailedWeather = {temperature: -10, weather: "stormy"}
---
{
    a: weatherMessage("sunny"),
    b: worstPossibleWeather.weather is Weather
}
```

## See Also

- [Create Custom Modules and Mappings](https://docs.mulesoft.com/dataweave/latest/dataweave-create-module)
