---
schema_version: "1"
id: 98becfd30a27d1c5789d03cf441dd6e9841c9ca3c392aa303f7b40bc7cc0acf5
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.6/dataweave-type-reuse-modules.md
canonical_url: https://docs.mulesoft.com/dataweave/2.6/dataweave-type-reuse-modules
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 70b19ac3435e76ff77bcabcba9f6d017c49b0fa55e6356dfab5834c5f962262e
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
---
product: DataWeave
version: 2.6
---

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