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';constttypes=require('./thrift/generated/client_types');asyncfunctionexample(){constsession=newSession({host: 'localhost',port: 6667,username: 'root',password: 'root'});awaitsession.open();// TypeScript provides autocomplete and type checkingconstresult=awaitsession.executeQueryStatement('SELECT * FROM root.test');// TypeScript knows result.columns is string[]result.columns.forEach(col=>console.log(col.toUpperCase()));awaitsession.close();}Existing JavaScript code continues to work without changes. The .d.ts files provide optional type information for TypeScript users.