TS2C ESP-GDBK-N Target
raw JSON → 0.0.1 verified Fri May 01 auth: no javascript
A target package for the TS2C transpiler (v0.15.0+, monthly releases) that compiles TypeScript to C for the ESP-GDBK-N microcontroller. Provides board-specific hardware abstractions (GPIO, SPI, I2C) as TypeScript decorators. Differentiates from Arduino by allowing TypeScript-to-C transpilation, enabling type-safe embedded development. No readme available; usage inferred from peer package 'ts2c'.
Common errors
error Cannot find module 'ts2c-target-gdbk-n' or its corresponding type declarations. ↓
cause Package not installed or missing from tsconfig includes.
fix
npm install ts2c-target-gdbk-n --save-dev
error SyntaxError: Unexpected token 'export' ↓
cause Using require() on ESM-only package.
fix
Switch to import statement in an ESM context.
error TypeError: GPIO is not a function ↓
cause Using default import instead of named import.
fix
Use import { GPIO } from 'ts2c-target-gdbk-n'
Warnings
breaking Requires ts2c >= 0.15.0; older versions not compatible. ↓
fix Update ts2c to >=0.15.0.
gotcha No readme or documentation available; API surface may change without notice. ↓
fix Refer to ts2c documentation for general usage patterns.
gotcha All exports are named; no default export exists. ↓
fix Use { GPIO, SPI, I2C } import syntax.
gotcha Package is ESM-only; CommonJS require() may fail in some environments. ↓
fix Use import statements with the transpiler which expects ESM.
Install
npm install ts2c-target-gdbk-n yarn add ts2c-target-gdbk-n pnpm add ts2c-target-gdbk-n Imports
- GPIO wrong
import GPIO from 'ts2c-target-gdbk-n'correctimport { GPIO } from 'ts2c-target-gdbk-n' - SPI wrong
const SPI = require('ts2c-target-gdbk-n').SPIcorrectimport { SPI } from 'ts2c-target-gdbk-n' - I2C wrong
const { I2C } = require('ts2c-target-gdbk-n')correctimport { I2C } from 'ts2c-target-gdbk-n'
Quickstart
// ts2c-target-gdbk-n quickstart: blink LED on GPIO 2
import { GPIO } from 'ts2c-target-gdbk-n';
@GPIO({ pin: 2, mode: 'output' })
class Led {
on() { /* compiler inserts C code */ }
off() { /* compiler inserts C code */ }
}
const led = new Led();
led.on();
setTimeout(() => led.off(), 1000);