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

Remove [index:string]: any; from TxtNode. #1294

Closed
azu opened this issue Nov 25, 2023 · 0 comments · Fixed by #1295
Closed

Remove [index:string]: any; from TxtNode. #1294

azu opened this issue Nov 25, 2023 · 0 comments · Fixed by #1295
Labels

Comments

@azu
Copy link
Member

azu commented Nov 25, 2023

export interface TxtNode {
type: TxtNodeType;
raw: string;
range: TxtNodeRange;
loc: TxtNodeLocation;
// `parent` is created by runtime
parent?: TxtParentNode;
[index: string]: any;
}

[index:string]: any; break Omit<> return type.

https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgJLIN4Chm+WATwAcIAuZAIiIoG4c8EALYAGwBMoIRyBnMKUAHMA2gF06eZMNBsIAD1J8BIQaPJwQBOgF8sWQiWQB5ZAF5jAW2BgAPKgA0lAxAoA+ZADJM9XM-IUAe1osXSwEAJA+ZADyI2EKJlYOLgpRM0xtOgB6LMkAPQB+PSA

interface I {
    type: "p";
    children: string[];
    [index:string]: any;
}

type O = Omit<I, "type"> & {
    type: "o";
}

const o: O["children"] = {};
//    ^? any

It prevent that extends TxtNode types.

https://github.com/textlint-rule/sentence-splitter/blob/40b80206aa0076d1ce8beab3bf4e01c69ed710a1/src/sentence-splitter.ts#L41-L48

@azu azu added Type: Bug Bug or Bug fixes Type: Typescript labels Nov 25, 2023
@azu azu linked a pull request Nov 25, 2023 that will close this issue
@azu azu closed this as completed in #1295 Nov 25, 2023
@azu azu mentioned this issue Nov 25, 2023
chick-p added a commit to chick-p/textlint-rule-period-in-list-item-with-morpheme-match that referenced this issue Feb 25, 2024
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 a pull request may close this issue.

1 participant