---
jsApi: true
title: "[F] cadlTypeToJson"

---
```ts
cadlTypeToJson<T>(typespecType, target): [T | undefined, Diagnostic[]]
```

## Type parameters

| Parameter |
| :------ |
| `T` |

## Parameters

| Parameter | Type |
| :------ | :------ |
| `typespecType` | [`TypeSpecValue`](Type.TypeSpecValue.md) |
| `target` | [`DiagnosticTarget`](Type.DiagnosticTarget.md) |

## Returns

[`T` \| `undefined`, [`Diagnostic`](Interface.Diagnostic.md)[]]

## Deprecated

use typespecTypeToJson
