---
schema_version: "1"
id: 2550f8ad903b666df163d8995f1efba88b340b4ea67180d5af5ae18489e1eb17
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.11/dataweave-type-reuse-modules.md
canonical_url: https://docs.mulesoft.com/dataweave/2.11/dataweave-type-reuse-modules
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 72c3b2eb2902fe52305d79b2e020d216963b5ee556b8e69611b8edfd30c9b489
description: MuleSoft Documentation Site
release: "2.11"
latest: false
---
---
product: DataWeave
version: 2.11
---

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