---
schema_version: "1"
id: 2e3008589335d712b98e6a34734b3b6d8874e9f8d8ae8f41aa053a450fcf1305
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.12/dataweave-type-reuse-modules.md
canonical_url: https://docs.mulesoft.com/dataweave/2.12/dataweave-type-reuse-modules
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 880a04259ddb480a190028e94915ebb269fa8e27d545b6ff12710c1979fb5f6d
description: MuleSoft Documentation Site
release: "2.12"
latest: false
---
---
product: DataWeave
version: 2.12
---

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