Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR removes type assertions (any casts) from the emmet extension codebase to improve type safety and eliminate the need for ESLint suppressions. The changes focus on proper type checking and handling of potentially undefined values.
- Replaced
anycasts with proper type guards and null checks - Added explicit type validation before accessing object properties
- Enhanced error handling with better return value patterns
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| extensions/emmet/src/util.ts | Removed any cast when checking for 'close' property |
| extensions/emmet/src/updateImageSize.ts | Added type guard for parsedValue property and explicit undefined return |
| extensions/emmet/src/emmetCommon.ts | Removed any casts for insertText and filterText properties with additional null check |
| } | ||
| // eslint-disable-next-line local/code-no-any-casts | ||
| else if ('close' in <any>child) { | ||
| else if ('close' in child) { |
There was a problem hiding this comment.
The type check 'close' in child may not be safe without proper type guards. Consider adding a null/undefined check for child before using the in operator to prevent potential runtime errors.
| else if ('close' in child) { | |
| else if (child && 'close' in child) { |
| } | ||
| } | ||
| return; | ||
| return undefined; |
There was a problem hiding this comment.
[nitpick] The explicit return undefined; is consistent with the function's return type, but consider whether this should match the pattern used in getFlatNodeChildren which uses an implicit return for consistency across the codebase.
| return undefined; |
Ref #269213