Skip to content

Commit

Permalink
Fix @ts-expect-error comments (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
ybiquitous authored Jul 27, 2023
1 parent 069238c commit 7c4870c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Head

- Fixed: `@ts-expect-error` comments ([#5](https://github.com/ybiquitous/changelog-to-github-release-action/pull/5)) ([@ybiquitous](https://github.com/ybiquitous)).

## 0.0.3

- Fixed: missing a result message when a release is created.
Expand Down
15 changes: 7 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28646,17 +28646,16 @@ function extractChangeItems({ version }) {
throw new Error(`Not found version: ${version}`);
}
// Rewrite a link to a PR notation (#123) or a user mention (@username).
lib_visit(list, 'link', (node) => {
lib_visit(list, 'link', (node, index, parent) => {
if (index === undefined || parent === undefined)
return lib_CONTINUE;
const [text] = node.children;
if (text?.type !== 'text')
return;
// @ts-expect-error -- TS2322: Type '"text"' is not assignable to type '"link"'.
node.type = 'text';
// @ts-expect-error -- TS2339: Property 'value' does not exist on type 'Link'.
node.value = text.value;
return lib_CONTINUE;
parent.children.splice(index, 1, { type: 'text', value: text.value });
return lib_CONTINUE;
});
tree.children.length = 0; // clear
tree.children.push(list);
tree.children = [list];
};
}
async function changelogToGithubRelease(changelog, version) {
Expand Down
3 changes: 3 additions & 0 deletions src/__tests__/changelogToGithubRelease.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const changelog = `
## 1.0.0
- aaa [#123](https://github.com/foo/bar/pull/123) ([@user](https://github.com/user)).
- bbb.
## 0.1.0
- ccc.
`;

test('rewrite change items matching specified version', async () => {
Expand Down
15 changes: 7 additions & 8 deletions src/changelogToGithubRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,17 @@ function extractChangeItems({ version }: { version: string }) {
}

// Rewrite a link to a PR notation (#123) or a user mention (@username).
visit(list, 'link', (node) => {
visit(list, 'link', (node, index, parent) => {
if (index === undefined || parent === undefined) return CONTINUE;

const [text] = node.children;
if (text?.type !== 'text') return;
if (text?.type !== 'text') return CONTINUE;

// @ts-expect-error -- TS2322: Type '"text"' is not assignable to type '"link"'.
node.type = 'text';
// @ts-expect-error -- TS2339: Property 'value' does not exist on type 'Link'.
node.value = text.value;
parent.children.splice(index, 1, { type: 'text', value: text.value });
return CONTINUE;
});

tree.children.length = 0; // clear
tree.children.push(list);
tree.children = [list];
};
}

Expand Down

0 comments on commit 7c4870c

Please sign in to comment.