You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "Lang-Qiu (via GitHub)" <gi...@apache.org> on 2026/06/07 01:49:30 UTC

[PR] 改进 hocon-parser 模块的类型定义,使用更精确的类型替代 any [texera]

Lang-Qiu opened a new pull request, #5435:
URL: https://github.com/apache/texera/pull/5435

   ## 问题背景
   在 `pyright-language-service` 的类型定义文件中,`hocon-parser` 模块的 `hoconParser` 函数返回类型被声明为 `any`。`any` 类型会完全绕过 TypeScript 的类型检查,使得调用该函数的代码无法获得类型安全保证,也无法享受自动补全和重构支持。
   
   ## 修改内容
   本次修改将 `hoconParser` 函数的返回类型从 `any` 替换为 `Record<string, unknown>`。
   
   **修改原因**:
   1.  **增强类型安全**:`Record<string, unknown>` 明确表示返回一个键为字符串、值为任意类型的对象。这比 `any` 更精确,能捕获部分类型错误(如误用数组方法)。
   2.  **保持灵活性**:HOCON 解析器的输出结构是动态的,无法预先定义具体接口。使用 `Record<string, unknown>` 在不损失灵活性的前提下,提供了比 `any` 更好的类型基础。
   3.  **遵循最佳实践**:在 TypeScript 中,应尽量避免使用 `any` 类型,优先使用更具体的类型如 `unknown` 或 `Record` 以提高代码的可维护性和健壮性。
   
   **兼容性**:这是一个纯类型层面的修改,不改变函数的任何运行时行为,因此完全向后兼容。
   
   ## 验证方式
   1.  TypeScript 类型检查通过,没有引入新的类型错误。
   2.  调用 `hoconParser` 的现有代码在类型推断和编译上不受影响,因为 `Record<string, unknown>` 是对 `any` 的一个更严格的替代。
   
   感谢审阅!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] 改进 hocon-parser 模块的类型定义,使用更精确的类型替代 any [texera]

Posted by "Ma77Ball (via GitHub)" <gi...@apache.org>.
Ma77Ball commented on PR #5435:
URL: https://github.com/apache/texera/pull/5435#issuecomment-4641135652

   Thanks for this! One thing though: `hoconParser` isn't used anywhere anymore. The call was removed in #3150 and the import in #3415, so this `.d.ts` stub and the `hocon-parser` dependency (plus `hoconjs` on line 10) are now just dead code.
   
   So changing the return type polishes something nothing uses. The more useful change would be to **remove** the unused stub and deps instead, and that'd be a nice cleanup you'd get credit for.
   
   If you want to take it on:
   1. Open an issue first using our issue template.
   2. Follow our PR template (e.g. title `chore(pyright-language-service): remove unused hocon-parser dependency`).
   
   If not, no worries, I'm happy to pick it up. Either way I think we should close this PR. Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] 改进 hocon-parser 模块的类型定义,使用更精确的类型替代 any [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang closed pull request #5435: 改进 hocon-parser 模块的类型定义,使用更精确的类型替代 any
URL: https://github.com/apache/texera/pull/5435


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] 改进 hocon-parser 模块的类型定义,使用更精确的类型替代 any [texera]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #5435:
URL: https://github.com/apache/texera/pull/5435#issuecomment-4641075012

   <!-- texera:welcome-first-time-contributor -->
   👋 Thanks for your first contribution to Texera, @Lang-Qiu!
   
   You can drive common housekeeping tasks just by leaving a comment. Type the command on its own line.
   
   ### On issues
   
   | Command | What it does |
   |---|---|
   | `/take` | Assign the issue to yourself (self-claim it) |
   | `/untake` | Remove yourself as assignee |
   
   To find unclaimed work, search `is:issue is:open no:assignee` — there's no "triage" label; the search filter *is* the triage state.
   
   ### Linking sub-issues
   
   | Command | Where to run it | What it does |
   |---|---|---|
   | `/sub-issue #12 #13` | On the **parent** | Links #12 and #13 as children of this issue |
   | `/unsub-issue #12 #13` | On the **parent** | Unlinks those children |
   | `/parent-issue #5` | On the **child** | Sets #5 as this issue's parent |
   | `/unparent-issue` | On the **child** | Removes this issue's parent (auto-detected) |
   | `/unparent-issue #5` | On the **child** | Removes parent #5 explicitly |
   
   You can write references as `#12` or bare `12`. Cross-repo references like `owner/repo#12` aren't supported and are ignored.
   
   ### On pull requests (author only)
   
   | Command | What it does |
   |---|---|
   | `/request-review @user [@user ...]` | Request reviews from those users |
   | `/unrequest-review @user [@user ...]` | Cancel those review requests |
   
   You can mention teams as `@org/team`, and `@copilot` works too. Only the PR **author** can use these commands.
   
   > **Note:** Commands must match exactly — `/take this` won't work, only `/take`. Bots are ignored, and you can't self-link an issue or set an issue as its own parent.
   
   For the full contribution flow, see [CONTRIBUTING.md](https://github.com/apache/texera/blob/main/CONTRIBUTING.md).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] 改进 hocon-parser 模块的类型定义,使用更精确的类型替代 any [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on PR #5435:
URL: https://github.com/apache/texera/pull/5435#issuecomment-4641158317

   we do use that, it is for typing though, which means only used for compilation time. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] 改进 hocon-parser 模块的类型定义,使用更精确的类型替代 any [texera]

Posted by "Ma77Ball (via GitHub)" <gi...@apache.org>.
Ma77Ball commented on PR #5435:
URL: https://github.com/apache/texera/pull/5435#issuecomment-4641552478

   @Yicong-Huang, I looked into it further, and I do not see any component or code that imports or uses this code. I still think it is dead code. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] 改进 hocon-parser 模块的类型定义,使用更精确的类型替代 any [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on PR #5435:
URL: https://github.com/apache/texera/pull/5435#issuecomment-4641149789

   I did not know @Ma77Ball you could read Chinese! @Lang-Qiu please use English for communication. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] 改进 hocon-parser 模块的类型定义,使用更精确的类型替代 any [texera]

Posted by "Ma77Ball (via GitHub)" <gi...@apache.org>.
Ma77Ball commented on PR #5435:
URL: https://github.com/apache/texera/pull/5435#issuecomment-4641149624

   You can use this issue #5442 to do the work if you decide you want to contribute. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] 改进 hocon-parser 模块的类型定义,使用更精确的类型替代 any [texera]

Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on PR #5435:
URL: https://github.com/apache/texera/pull/5435#issuecomment-4643395066

   Thanks @Ma77Ball. As there is no real usage, I think we can safely close this one. 
   
   @Lang-Qiu you are welcome to open PRs on other aspects. Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] 改进 hocon-parser 模块的类型定义,使用更精确的类型替代 any [texera]

Posted by "Ma77Ball (via GitHub)" <gi...@apache.org>.
Ma77Ball commented on PR #5435:
URL: https://github.com/apache/texera/pull/5435#issuecomment-4641152668

   I had it translated to figure out why the change was added, but noticed it was small and applied to a file not used in the current codebase. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@texera.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org