# Types
BrightScript already lets you declare the types of function parameters and return values, and Roku checks them when your code runs. BrighterScript builds on that. You can use your own classes, interfaces and enums as types, along with the names of Roku's built-in components, and the compiler checks those names before your code ever reaches a device. When you build, each type is converted to one that the Roku runtime understands.
## Using your own types
In `.bs` files, you can use the name of a [class](classes.md), [interface](interfaces.md) or [enum](enums.md) anywhere you can use a built-in type. Here, `quality` is typed as an enum, and the function returns an object described by an interface:
```brighterscript
function createStream(url as string, quality as Quality) as VideoStream
return {
url: url
quality: quality
}
end function
enum Quality
sd = "sd"
hd = "hd"
end enum
interface VideoStream
url as string
quality as Quality
end interface
```
View the transpiled BrightScript code
```brightscript
function createStream(url as string, quality as object) as object
return {
url: url
quality: quality
}
end function
```
The device only knows BrightScript's built-in types. Built-in types like `string` are left as they are, and `Quality` and `VideoStream` become `object`. Before transpiling, the compiler uses the original names to check your code, as described in [What the compiler checks](#what-the-compiler-checks).
Types declared inside a [namespace](namespaces.md) are referenced by their full name:
```brighterscript
namespace catalog
class Movie
title as string
end class
end namespace
sub printTitle(movie as catalog.Movie)
print movie.title
end sub
```
## Built-in types
These types are part of BrightScript itself. They work in both `.brs` and `.bs` files, and they are left unchanged in the transpiled code, so the device checks them at runtime.
| Type | Description |
|---|---|
| `boolean` | `true` or `false` |
| `integer` | A 32-bit whole number |
| `longinteger` | A 64-bit whole number |
| `float` | A single-precision decimal number |
| `double` | A double-precision decimal number |
| `string` | Text |
| `object` | Any BrightScript object, such as an associative array, array or node |
| `function` | A reference to a function |
| `dynamic` | Any value |
| `void` | No value. Only valid as a return type |
## Roku component types
You can also use the name of any built-in Roku component or interface as a type, such as `roAssociativeArray`, `roSGNode`, `roDateTime` or `ifArray`. Roku's SceneGraph node types work as well, by adding the `roSGNode` prefix to the node's name:
```brighterscript
sub populateList(list as roSGNodeLabelList, items as roArray)
content = createObject("roSGNode", "ContentNode")
for each item in items
content.createChild("ContentNode").title = item
end for
list.content = content
end sub
```
View the transpiled BrightScript code
```brightscript
sub populateList(list as object, items as object)
content = createObject("roSGNode", "ContentNode")
for each item in items
content.createChild("ContentNode").title = item
end for
list.content = content
end sub
```
Like your own types, these become `object` in the transpiled code. They make your function signatures easier to read, and they tell other developers what a function expects.
## Class fields and interface members
Class fields and interface members use the same `as` syntax:
```brighterscript
class Episode
title as string
seasonNumber as integer
durationInSeconds as integer = 0
series as Series
end class
interface Series
title as string
optional rating as string
end interface
```
Interfaces only exist at compile time and are removed from the transpiled code. The types of class fields are removed too. Each field is initialized to its default value, or to `invalid` if it doesn't have one. See [Classes](classes.md#property-initialization) for details.
## What the compiler checks
When you build your project, BrighterScript checks the following.
**Every type name refers to something that exists.** A misspelled or missing type is reported where you wrote it:
```brighterscript
sub play(item as MediaItme)
end sub
```
```bsc-output
error BS1044: Function parameter 'item' is of invalid type 'MediaItme'
```
The same check applies to return types (BS1037) and class field types (BS1123). The type must be a built-in type, a Roku component, or a class, interface or enum that the file can see. A type declared in another file is available when that file is part of the same scope, through an [import](imports.md) or a `