<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/statically-typed-lua-hb06zssjy" -->

---
title: Statically Typed Lua | daily.dev
description: A livestream recording follows a developer exploring Teal, a statically typed dialect of Lua similar to TypeScript for JavaScript, by retrofitting type...
canonical: https://daily.dev/posts/statically-typed-lua-hb06zssjy
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Statically Typed Lua | daily.dev
og:description: A livestream recording follows a developer exploring Teal, a statically typed dialect of Lua similar to TypeScript for JavaScript, by retrofitting type...
og:url: https://daily.dev/posts/statically-typed-lua-hb06zssjy
og:image: https://api.daily.dev/og/posts/HB06zSsJY.png
og:image:alt: Statically Typed Lua
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Statically Typed Lua

**[Tsoding Daily](https://daily.dev/sources/tsoding_daily)** · 105 min read · 4 upvotes · 1 comments

## Summary

A livestream recording follows a developer exploring Teal, a statically typed dialect of Lua similar to TypeScript for JavaScript, by retrofitting type annotations onto a previously built Pong clone made with Love2D. The streamer installs the Teal compiler, writes custom type declaration files for the Love2D API since none exist for their subset of usage, and gradually eliminates type errors (starting around 70, ending near zero) while expressing opinions on Lua's dynamic typing weaknesses, Teal's ergonomics, records, enums, integer vs number types, nullable types, and the benefits of compiler-assisted refactoring. The session ends with extending the game with a pause feature and a custom glyph-based text renderer.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=8lwogk6xeM0>

## Questions this post answers

### What is Teal and how does it relate to Lua?

Teal is a statically typed dialect of Lua that adds type annotations for arrays, maps, records, interfaces, union types, and generics while preserving Lua's minimalism, portability, and embeddability. It fills a role similar to TypeScript for JavaScript. The compiler, called tl, type-checks .tl files and compiles them into plain .lua files that run with any standard Lua interpreter.

_daily.dev surfaces tooling like this for developers weighing static typing options for Lua projects._

### How do you add type definitions for a third-party Lua library like Love2D in Teal?

Create a declaration file with a .d.tl extension and require it as normal, for example naming it love.d.tl for the Love2D API. Inside, define global records (such as a love record with nested graphics, audio, keyboard, and joystick records) describing only the functions and fields actually used, since writing a full binding isn't necessary for partial API usage. Callback functions like love.update or love.keypressed must first be declared in the .d.tl file before being implemented in a separate .tl file.

_developers binding untyped libraries into a typed Lua workflow can track Teal patterns like this on daily.dev._

### Does Lua have a separate integer type distinct from floating point numbers?

Yes, within Teal's type system, numbers have subtypes: integer and number (which covers floats), even though plain Lua treats all numbers similarly. Teal's type checker can infer a value as an integer specifically, and using 'number' is recommended in places needing floats since integers are compatible with it, while integer-only contexts reject non-integer numbers.

_developers choosing between loose and strict numeric typing in Lua projects can keep up with cases like this on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@andradei** · 0 upvotes

> Typing makes programming better for the majority of projects.
> It's only optional (if ever) when the written code is organizes and easy to read.
>
> But who cares, give a convoluted and poorly written code base to AI and it'll grok it for you anyways...

## Similar posts on daily.dev

- [Lua can be a really cool HTML templating engine](https://daily.dev/posts/lua-can-be-a-really-cool-html-templating-engine-pwy47nz8p) · Lobsters · 0 upvotes · 0 comments
- [Why AI is pushing developers toward typed languages](https://daily.dev/posts/why-ai-is-pushing-developers-toward-typed-languages-2d0r9uzxl) · GitHub Blog · 46 upvotes · 13 comments

---

Tags: [#general-programming](https://daily.dev/tags/general-programming), [#game-development](https://daily.dev/tags/game-development), [#lua](https://daily.dev/tags/lua)

[View this post on daily.dev](https://daily.dev/posts/statically-typed-lua-hb06zssjy)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Statically Typed Lua","url":"https://daily.dev/posts/statically-typed-lua-hb06zssjy","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/statically-typed-lua-hb06zssjy"},"datePublished":"2026-10-17T13:10:46.660Z","dateModified":"2026-10-17T13:11:09.133Z","description":"A livestream recording follows a developer exploring Teal, a statically typed dialect of Lua similar to TypeScript for JavaScript, by retrofitting type...","image":"https://i.ytimg.com/vi/8lwogk6xeM0/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/8lwogk6xeM0/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Tsoding Daily","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Tsoding Daily","logo":"https://media.daily.dev/image/upload/s--6msWm9pp--/f_auto/v1728806157/logos/tsoding_daily","url":"https://daily.dev/sources/tsoding_daily"},"commentCount":1,"discussionUrl":"https://daily.dev/posts/statically-typed-lua-hb06zssjy","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":4},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":1}],"keywords":"general-programming,game-development,lua","timeRequired":"PT105M","video":{"@type":"VideoObject","name":"Statically Typed Lua","description":"A livestream recording follows a developer exploring Teal, a statically typed dialect of Lua similar to TypeScript for JavaScript, by retrofitting type...","thumbnailUrl":"https://i.ytimg.com/vi/8lwogk6xeM0/sddefault.jpg","uploadDate":"2026-10-17T13:10:46.660Z","duration":"PT105M","url":"https://api.daily.dev/r/HB06zSsJY","embedUrl":"https://www.youtube.com/embed/8lwogk6xeM0"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Tsoding Daily","item":"https://daily.dev/sources/tsoding_daily"},{"@type":"ListItem","position":3,"name":"Statically Typed Lua"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/statically-typed-lua-hb06zssjy","comment":[{"@type":"Comment","text":"Typing makes programming better for the majority of projects.\nIt’s only optional (if ever) when the written code is organizes and easy to read.\nBut who cares, give a convoluted and poorly written code base to AI and it’ll grok it for you anyways…","datePublished":"2026-10-17T14:43:42.869Z","url":"https://daily.dev/posts/HB06zSsJY#c-5wUz0eA54","author":{"@type":"Person","name":"Isaac de Andrade","url":"https://daily.dev/andradei","image":"https://avatars.githubusercontent.com/u/2653546?v=4"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/statically-typed-lua-hb06zssjy#faq","mainEntity":[{"@type":"Question","name":"What is Teal and how does it relate to Lua?","acceptedAnswer":{"@type":"Answer","text":"Teal is a statically typed dialect of Lua that adds type annotations for arrays, maps, records, interfaces, union types, and generics while preserving Lua's minimalism, portability, and embeddability. It fills a role similar to TypeScript for JavaScript. The compiler, called tl, type-checks .tl files and compiles them into plain .lua files that run with any standard Lua interpreter. daily.dev surfaces tooling like this for developers weighing static typing options for Lua projects."}},{"@type":"Question","name":"How do you add type definitions for a third-party Lua library like Love2D in Teal?","acceptedAnswer":{"@type":"Answer","text":"Create a declaration file with a .d.tl extension and require it as normal, for example naming it love.d.tl for the Love2D API. Inside, define global records (such as a love record with nested graphics, audio, keyboard, and joystick records) describing only the functions and fields actually used, since writing a full binding isn't necessary for partial API usage. Callback functions like love.update or love.keypressed must first be declared in the .d.tl file before being implemented in a separate .tl file. developers binding untyped libraries into a typed Lua workflow can track Teal patterns like this on daily.dev."}},{"@type":"Question","name":"Does Lua have a separate integer type distinct from floating point numbers?","acceptedAnswer":{"@type":"Answer","text":"Yes, within Teal's type system, numbers have subtypes: integer and number (which covers floats), even though plain Lua treats all numbers similarly. Teal's type checker can infer a value as an integer specifically, and using 'number' is recommended in places needing floats since integers are compatible with it, while integer-only contexts reject non-integer numbers. developers choosing between loose and strict numeric typing in Lua projects can keep up with cases like this on daily.dev."}}]}
```

