Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ast-node-types): remove [index:string]: any; from TxtNode #1295

Merged
merged 5 commits into from Nov 25, 2023
Merged

Conversation

azu
Copy link
Member

@azu azu commented Nov 25, 2023

This PR fixed types of textlint.
It does not change the behavior of textlint.

Changes

  • Remove [index:string]: any; from TxtNode
  • Plugin's preProcess should return TxtDocumentNode
    • Previously, it allow return TxtNode.

For plugin developer:

You may be necessary to change the type that returns preProcess as follows

-            preProcess(_text: string, _filePath: string): TxtNode {
+            preProcess(_text: string, _filePath: string): TxtDocumentNode {

Related

@azu azu linked an issue Nov 25, 2023 that may be closed by this pull request
@azu azu added Type: Bug Bug or Bug fixes Type: Typescript labels Nov 25, 2023
@@ -54,8 +54,6 @@ export interface TxtNode {
loc: TxtNodeLocation;
// `parent` is created by runtime
parent?: TxtParentNode;

[index: string]: any;
Copy link
Member Author

Choose a reason for hiding this comment

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

Remove [index:string]: any; from TxtNode

Previoulsy, Omit<TxtNode, "type"> return any objects. It is bad.

export type TextlintPluginPreProcessResult = TxtNode | { text: string; ast: TxtNode };
export type TextlintPluginPreProcessResult = TxtDocumentNode | { text: string; ast: TxtDocumentNode };
Copy link
Member Author

Choose a reason for hiding this comment

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

Plugin's preProcessor should returns TxtDocumentNode

@azu azu merged commit 678355e into master Nov 25, 2023
17 checks passed
@azu azu deleted the feature/1294 branch November 25, 2023 01:38
@github-actions github-actions bot mentioned this pull request Nov 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove [index:string]: any; from TxtNode.
1 participant