Skip to content

refactor: reduce ignored type errors in AST conversion#22

Merged
3w36zj6 merged 2 commits intomainfrom
feature/reduce-ignored-type-errors
Oct 1, 2025
Merged

refactor: reduce ignored type errors in AST conversion#22
3w36zj6 merged 2 commits intomainfrom
feature/reduce-ignored-type-errors

Conversation

@3w36zj6
Copy link
Member

@3w36zj6 3w36zj6 commented Oct 1, 2025

No description provided.

@3w36zj6 3w36zj6 requested a review from Copilot October 1, 2025 15:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the AST conversion module to reduce ignored TypeScript errors by improving type safety and replacing // @ts-expect-error comments with proper type handling. The changes introduce type guards, utility functions, and better-typed interfaces to handle the gradual transformation from Typst AST to textlint AST without suppressing type errors.

Key changes include:

  • Added comprehensive type imports and type guards for AST node validation
  • Introduced utility functions for safe property access and type checking
  • Replaced property deletion using delete with Reflect.deleteProperty() for type safety

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +189 to +190
const isTypstType = (type: string, pattern: string): boolean => {
return new RegExp(pattern).test(type);
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a new RegExp object on every call is inefficient. Consider using RegExp.prototype.test directly or caching compiled regex patterns if they're reused frequently.

Suggested change
const isTypstType = (type: string, pattern: string): boolean => {
return new RegExp(pattern).test(type);
const isTypstType = (type: string, pattern: RegExp): boolean => {
return pattern.test(type);

Copilot uses AI. Check for mistakes.
spread: false,
// @ts-expect-error
children: listItems,
children: listItems as Content[] as TxtListItemNode[],
Copy link

Copilot AI Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double type assertion (as Content[] as TxtListItemNode[]) is a code smell that suggests type safety issues. Consider refining the types to avoid the need for this double assertion.

Copilot uses AI. Check for mistakes.
@3w36zj6 3w36zj6 merged commit 94e3b37 into main Oct 1, 2025
4 checks passed
@3w36zj6 3w36zj6 deleted the feature/reduce-ignored-type-errors branch October 1, 2025 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants