v1.3.0
TsFluent v1.3.0 Release Notes ๐
Major Features ๐
Generic Context Support
- Added
TContext
generic parameter to bothResult
andResultAsync
classes - Type-safe context handling in metadata and error objects
- Improved type inference in chaining operations
- Better IDE support with accurate type hints
Property-Based Access
- Introduced direct property access for better developer experience:
result.errors
instead ofgetErrors()
result.metadata
instead ofgetMetadata()
- Deprecated method-based access in favor of properties
Enhanced Error Handling
- Improved error context preservation across transformations
- Better retry information in AsyncUtils error context
- Rich metadata support with timestamps and custom contexts
API Improvements
- Enhanced
ResultAsync.from()
for better Promise handling - Improved
AsyncUtils.tryAsync()
with configurable retries and timeouts - Added comprehensive type safety across all operations
Breaking Changes โ ๏ธ
Deprecated Methods
getErrors()
โ useerrors
property insteadgetMetadata()
โ usemetadata
property instead
Type Changes
ResultAsync.from<T>()
now only accepts one generic type parameterAsyncUtils.tryAsync<T>()
simplified to one generic type parameter- Context types must extend
Record<string, unknown>
New Features in Detail ๐
Result Class
// New context support
interface UserContext {
userId: string;
environment: "dev" | "prod";
}
const result = Result.ok<number, UserContext>(42)
.withMetadata({
context: {
userId: "123",
environment: "prod"
}
});
ResultAsync Class
// Improved Promise handling
const result = await ResultAsync.from<Response>(
fetch("https://api.example.com/data")
);
// Type-safe metadata
result.withMetadata({
context: {
requestId: "123",
endpoint: "/data"
}
});
AsyncUtils
// Enhanced retry configuration
const result = await AsyncUtils.tryAsync(
async () => {
// async operation
},
3, // maxAttempts
1000, // delayMs
2000 // timeoutMs
);
Bug Fixes ๐
- Fixed type compatibility issues between
Result
andResultAsync
- Corrected metadata propagation in transformation methods
- Resolved context type preservation in chaining operations
- Fixed error context handling in retry operations
Performance Improvements โก
- Optimized error handling chain
- Improved type inference performance
- Better memory usage in retry operations
Documentation Updates ๐
- Added comprehensive examples for all new features
- Updated API reference with accurate type information
- Improved code samples with real-world use cases
- Added detailed error handling scenarios
Migration Guide ๐
Updating from v1.1.x
-
Replace method calls with property access:
// Old result.getErrors(); result.getMetadata(); // New result.errors; result.metadata;
-
Update generic type parameters:
// Old ResultAsync.from<T, Context>(); // New ResultAsync.from<T>();
-
Review context types:
// Ensure context types extend Record<string, unknown> interface YourContext extends Record<string, unknown> { // your context properties }
Contributors ๐ฅ
Special thanks to all contributors who helped make this release possible!
What's Next? ๐ฎ
We're planning several exciting features for upcoming releases:
- Enhanced error categorization
- More utility functions for common patterns
- Additional convenience methods for error handling
- Performance optimizations
Feedback and Support ๐ฌ
We welcome your feedback and contributions! Please:
- Report issues on our GitHub Issues
- Join discussions in our GitHub Discussions
- Submit pull requests for improvements
License ๐
TsFluent is released under the MIT License. See the LICENSE file for details.