opc-types
opc-types copied to clipboard
OpenComputers and TypeScript
OpenComputers and TypeScript
Language
Introduction
This repository contains type declarations for OpenOS and GUI (and also some of it dependencies).
It is assumed that you will use TypeScriptToLua as a transpiler.
Some examples can be found in the examples
folder. Also look at VSCode extension, which integrates TypeScript with OpenComputers.
Installation
# Typings for OpenOS
yarn add @opct/openos # or npm install @opct/openos -S
# Typings for MineOS
yarn add @opct/mineos
# Typings for GUI
yarn add @opct/gui
# TSTL
yarn add typescript-to-lua
// tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"outDir": "dist",
"module": "commonjs",
"lib": ["esnext"],
"strict": true,
"moduleResolution": "node",
"rootDir": "src",
"types": [
"lua-types/jit",
"@opct/openos",
"@opct/gui",
"@opct/mineos"
]
},
"tstl": {
"luaTarget": "JIT"
}
}
Setting up a comfortable working environment
-
You can use Visual Studio Code or any other editor with TypeScript support.
-
Instead of a real mod, you can use an emulator. Otherwise, it is necessary to set
filesystem.bufferChanges
tofalse
in order to have external access to the disk. -
Create a link to the disk to keep the source code separate from it:
# linux / macos ln -s /path/to/disk/home/app dist
# windows (cmd) mklink /j dist C:\path\to\disk\home
-
Use
tstl --watch