Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax lookup: type #240

Merged
merged 1 commit into from
Mar 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions misc_docs/syntax/language_type.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
id: "type"
keywords: ["type"]
name: "type"
summary: "This is the `type` keyword"
category: "languageconstructs"
---

The `type` keyword is used to declare a _type_, including [Records](/docs/manual/latest/record), [Variants](/docs/manual/latest/variant) and [Polymorphic Variants](/docs/manual/latest/polymorphic-variant).

### Example

<CodeTab labels={["ReScript", "JS Output"]}>

```res
type location = {
name: string,
coordinates: (float, float),
keywords: array<string>,
}

let uluru: location = {
name: "Uluru",
coordinates: (-25.344490, 131.035431),
keywords: ["Rock", "Australia"],
}
```

```js
var uluru_coordinates = [-25.34449, 131.035431];

var uluru_keywords = ["Rock", "Australia"];

var uluru = {
name: "Uluru",
coordinates: uluru_coordinates,
keywords: uluru_keywords,
};
```

</CodeTab>

### References

* [ReScript Types](/docs/manual/latest/type)
* [Record Types](/docs/manual/latest/record)
* [Variant Types](/docs/manual/latest/variant)
* [Polymorphic Variant Types](/docs/manual/latest/polymorphic-variant)