Example code in docs doesn't work when NodeNext is used for module resolution
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- node.js, typescript
调研方向
从 Databricks SQL driver 文档 URL 中的 TypeScript 示例开始,使用提供的 package.json、Node 22 以及 NodeNext tsconfig 设置重现失败。检查文档中的 imports 是否能够解析,以及示例是否能在 NodeNext 下成功构建;当示例能够运行,或文档清楚地反映受支持的配置时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Using this tsconfig.json I can get the example code to build without error.
tsconfig.json:
{
"compilerOptions": {
"lib": ["ES2022"],
"outDir": "./dist",
"rootDir": "./src",
"target": "ES2022",
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
}
}
Code from website - https://docs.databricks.com/en/dev-tools/nodejs-sql-driver.html#language-TypeScript:
import { DBSQLClient } from '@databricks/sql';
import IDBSQLSession from '@databricks/sql/dist/contracts/IDBSQLSession';
import IOperation from '@databricks/sql/dist/contracts/IOperation';
const serverHostname: string = process.env.DATABRICKS_SERVER_HOSTNAME || '';
const httpPath: string = process.env.DATABRICKS_HTTP_PATH || '';
const token: string = process.env.DATABRICKS_TOKEN || '';
if (serverHostname == '' || httpPath == '' || token == '') {
throw new Error("Cannot find Server Hostname, HTTP Path, or personal access token. " +
"Check the environment variables DATABRICKS_SERVER_HOSTNAME, " +
"DATABRICKS_HTTP_PATH, and DATABRICKS_TOKEN.");
}
const client: DBSQLClient = new DBSQLClient();
const connectOptions = {
host: serverHostname,
path: httpPath,
token: token
};
client.connect(connectOptions)
.then(async client => {
const session: IDBSQLSession = await client.openSession();
const queryOperation: IOperation = await session.executeStatement(
'SELECT * FROM samples.nyctaxi.trips LIMIT 2',
{
runAsync: true,
maxRows: 10000 // This option enables the direct results feature.
}
);
const result = await queryOperation.fetchAll();
await queryOperation.close();
console.table(result);
await session.close();
client.close();
})
.catch((error) => {
console.error(error);
});
However, when changing the tsconfig to use NodeNext (like the below):
{
"compilerOptions": {
"lib": ["ES2022"],
"outDir": "./dist",
"rootDir": "./src",
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
}
}
I see the following error on the imports:
Cannot find module '@databricks/sql/dist/contracts/IDBSQLSession' or its corresponding type declarations.ts(2307)
Cannot find module '@databricks/sql/dist/contracts/IOperation' or its corresponding type declarations.ts(2307)
Versions:
- node 22
- this is the package.json:
{
"name": "example",
"version": "1.0.0",
"description": "show example of issue",
"main": "index.js",
"type": "module",
"scripts": {
"build": "tsc"
},
"author": "",
"license": "ISC",
"dependencies": {
"@databricks/sql": "^1.9.0"
},
"devDependencies": {
"typescript": "^5.6.3",
"typescript-eslint": "^8.14.0"
}
}
- 主要语言
- TypeScript
- 星标
- 36
- 派生
- 50
- 平均合并
- 13 小时 46 分钟
- 30 天内合并 PR
- 9
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
databricks/databricks-sql-nodejs 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 72/100
-
engineer-bot
难度 2/5 1-3 小时 新手友好度 64/100
databricks/databricks-sql-nodejs#274 · 1 条评论 · 1 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 3/5 1-2 天 新手友好度 68/100
查看 databricks/databricks-sql-nodejs 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
mksglu/context-mode#1200 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
难度 2/5 1-3 小时 新手友好度 75/100
anthropics/claude-code#96687 ·
-
good first issue
难度 1/5 1 小时以内 新手友好度 95/100
AOSSIE-Org/DebateAI#582 · 2 条评论 ·