---
schema_version: "1"
id: fa3c29ea6c2f4b04c117802ea0ae62cbfc97c3e442bc22a49ed39eab6c4a087f
title: DataWeave モジュールの型の再利用
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.5/dataweave-type-reuse-modules.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.5/dataweave-type-reuse-modules
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 6e30747776aa7f31502546acdc3191bff970343d893bc6c38296fc9026d6e5e1
description: MuleSoft Documentation Site
release: "2.5"
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.5/dataweave-create-module)