Commit 771ad96
authored
fix createTool type with exactOptionalPropertyTypes (#12325)
## Description
Fixed type error when using `createTool` with Agent when
`exactOptionalPropertyTypes: true` is enabled in TypeScript config.
The `ProviderDefinedTool` structural type in `@internal/external-types`
had two incompatibilities with `ToolAction`:
1. `inputSchema` was required but `ToolAction.inputSchema` is optional
2. `execute?` didn't allow explicit `undefined` values, which
`exactOptionalPropertyTypes` distinguishes from absent properties
Changes:
- `inputSchema: unknown` → `inputSchema?: unknown`
- `execute?: (...args: any[]) => any` → `execute?: ((...args: any[]) =>
any) | undefined`
These changes make the types more permissive for users with stricter
TypeScript configs while having no effect for users without
`exactOptionalPropertyTypes`.
## Related Issue(s)
Fixes #12281
## Type of Change
- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Code refactoring
- [ ] Performance improvement
- [ ] Test update
## Checklist
- [x] I have made corresponding changes to the documentation (if
applicable)
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Fixed type compatibility for `createTool` with Agent configurations,
correcting optional property handling to support strict TypeScript type
checking.
<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent c5f4c00 commit 771ad96
File tree
2 files changed
+8
-3
lines changed- .changeset
- packages/_external-types/src
2 files changed
+8
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
0 commit comments