---
schema_version: "1"
id: 74292e4bcb05f6ae02f3a39403f1dc988798cb22e931b02e3328879f1eab5165
title: Reusing Types from DataWeave Modules
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dataweave-type-reuse-modules.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dataweave-type-reuse-modules
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 987f1238713d15fab071e28a9046b4f6572cb3ddfbe6119e8efa100d3268434e
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
---

# 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/2.9/dataweave-create-module)
