This document demonstrates the TypeScript support in the IoTDB Node.js client.
With the TypeScript declaration files, you get complete type safety when working with Thrift-generated types.
- ✅ Full IntelliSense and autocomplete in VS Code/WebStorm
- ✅ Compile-time type checking for all Thrift types
- ✅ Better refactoring support
- ✅ Self-documenting code
- ✅ Zero runtime overhead (
.d.tsfiles are compile-time only)
import { Session } from './client/Session';
const ttypes = require('./thrift/generated/client_types');
async function example() {
const session = new Session({
host: 'localhost',
port: 6667,
username: 'root',
password: 'root'
});
await session.open();
// TypeScript provides autocomplete and type checking
const result = await session.executeQueryStatement('SELECT * FROM root.test');
// TypeScript knows result.columns is string[]
result.columns.forEach(col => console.log(col.toUpperCase()));
await session.close();
}Existing JavaScript code continues to work without changes. The .d.ts files provide optional type information for TypeScript users.