Closed kamecha closed 1 month ago
The updates across various files enhance type safety and validation mechanisms by transitioning from utility functions to assertion-based checks. This shift from ensure
functions to assert
calls improves error handling and code readability, ensuring that variables conform to expected types before processing. Overall, the changes lead to a more robust and maintainable code structure, minimizing potential runtime errors.
Files | Change Summary |
---|---|
denops/@ddc-sources/*.ts |
Updated onInit methods in the Source class to use assert for string validation instead of ensureString , enhancing type safety. |
denops/@ddu-kinds/*.ts |
Replaced ensureNumber and ensureArray with assert checks, enhancing validation for limit and ret variables. |
denops/traqvim/*.ts |
Replaced various ensure functions with assert , improving validation for timeline messages and other parameters, enhancing type safety and error handling. |
denops/traqvim/deps.ts |
Transitioned exports from utility functions (ensure... ) to assertion-based utilities (assert , is ), enhancing type safety in the codebase. |
denops/traqvim/type_check.ts |
Introduced type predicates for MessageStamp , UserAccountState , User , and Message to validate data structures, enhancing type safety. |
sequenceDiagram
participant User
participant App
participant Source
participant Validator
User->>App: Initiates action
App->>Source: Call onInit()
Source->>Validator: Validate path
Validator-->>Source: Assert path is string
Source-->>App: Proceed with valid path
App-->>User: Action completed
🐇 "In a world so neat and bright,
We check our paths, make things right.
With assertions bold and true,
Our code now dances, fresh and new!
Hooray for types, let errors flee,
A happy rabbit, that's me! 🐰✨"
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
as
を使用してる箇所があったら積極的にassert
とかに変更しておきたい
一度as
してて、知らないうちにvim固まっちゃった事あるので...
Predicateだとメタデータの情報が落ちるらしいから、折をみてsatisfies
とかいうの使ってみたい
60
↑これに関連する
Summary by CodeRabbit
New Features
Bug Fixes
Documentation