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

Add typecheck as tests. #134

Closed
wants to merge 4 commits into from
Closed

Add typecheck as tests. #134

wants to merge 4 commits into from

Conversation

kachick
Copy link
Contributor

@kachick kachick commented Sep 16, 2022

This PR based on #133

When I digging above issue, I found #101 (comment)
So tried to add typecheckers. Similar ways are used in https://github.com/octokit/types.ts/blob/725c32e3a3827d8e89a232fc09c7225fdaea84e0/test.ts.

@uhop uhop self-assigned this Sep 16, 2022
@uhop uhop self-requested a review September 19, 2022 03:23
Copy link
Owner

@uhop uhop left a comment

Choose a reason for hiding this comment

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

It looks like this PR doesn't achieve its objectives. It should be reworked.

The added file test_types.ts is supposed to be a smoke test. It doesn't use the existing test harness. That's totally fine. I suggest moving it to a separate directory, e.g., ts-tests, and adding a different command to run it, e.g., npm run ts-test. Then I can update the GitHub action to run it automatically.

package.json Outdated
},
"scripts": {
"pretest": "tsc",
Copy link
Owner

Choose a reason for hiding this comment

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

I am not an expert in Typescript, but I don't see any file produced running this command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, intentionally omitted compiling. Just using TypeScript for the typechecking in this PR. noEmit option makes the behavior.

}

test_execTypes()
test_matchTypes()
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think this file is ever executed. I added console.log() and I couldn't see its output. I tried to run it with ts-node and it fails to compile (some import problems).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. These code won't run. However TypeScript checks them with tsc. Removing them makes following error with current config.

npx tsc
tests/test_types.ts:16:10 - error TS6133: 'test_matchTypes' is declared but its value is never read.

16 function test_matchTypes() {
            ~~~~~~~~~~~~~~~


Found 1 error in tests/test_types.ts:16

@kachick
Copy link
Contributor Author

kachick commented Sep 22, 2022

Thanks for your review!

moving it to a separate directory, e.g., ts-tests, and adding a different command to run it, e.g., npm run ts-test

How about this change? e380c18

@uhop
Copy link
Owner

uhop commented Sep 22, 2022

Thank you, I plan to review it in the coming days.

@uhop
Copy link
Owner

uhop commented Nov 23, 2022

The code is in https://github.com/uhop/node-re2/tree/kachick-add-ts-tests branch. It includes the minimal fix from #141. It fails to compile with the latest Typescript.

I am not sure how to handle a type expansion in TS correctly. I am proposing a way in my next commit to this branch. Please review because I am not a TS programmer and can make stupid mistakes. ;-)

@uhop uhop mentioned this pull request Nov 23, 2022
@uhop
Copy link
Owner

uhop commented Nov 23, 2022

Moving the development to #142.

@uhop uhop closed this Nov 23, 2022
@kachick kachick deleted the add-ts-tests branch November 24, 2022 01:34
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