---
schema_version: "1"
id: e4ea4718bb4b765829f888b78fab4dc7c68ea20d56d690bd0f9da5fe5569075c
title: DataWeave モジュールの型の再利用
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.8/dataweave-type-reuse-modules.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.8/dataweave-type-reuse-modules
source_site: docs.mulesoft.com
content_type: documentation
content_hash: fe8a4c23a962fb93f3b541191f5b8de3f434833123736316bee4c670d8ee79cc
description: MuleSoft Documentation Site
release: "2.8"
latest: false
---
# DataWeave モジュールの型の再利用

他の DataWeave モジュールで宣言されている型を再利用するには、​`import`​ ディレクティブを使用します。

DataWeave モジュール (​`dw/Weather.dwl`​):

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

それらのインポートされた型は、DataWeave の他の型のように、変数と関数の制約や、パターン一致および実行時の型のチェックの制約として使用できます。

DataWeave スクリプト:

```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
}
```

## [](#関連情報)関連情報

- [カスタムモジュールおよびマッピングの作成](https://docs.mulesoft.com/jp/dataweave/2.8/dataweave-create-module)