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

[tsgen] Expand TS generation test to compile and run a TS file. #22582

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

brendandahl
Copy link
Collaborator

In the new TS file we can add tests for things where just checking if the definition file compiles is not enough. This will help catch issues like #22569.

In the new TS file we can add tests for things where just checking if the
definition file compiles is not enough. This will help catch issues like
emscripten-core#22569.
Bar bar;
std::string string;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed this to be a more realistic use of a ValueObject.

test/other/embind_tsgen.ts Outdated Show resolved Hide resolved
test/other/embind_tsgen.ts Outdated Show resolved Hide resolved

# Test that the output compiles with a TS file that uses the defintions.
cmd = shared.get_npm_cmd('tsc') + ['embind_tsgen.d.ts', '--noEmit']
shutil.copyfile(test_file('other/embind_tsgen.ts'), 'main.ts')
# A package file with type=module is needed to allow top level await in TS.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you instead use the .mjs extension?

test/other/embind_tsgen_package.json Outdated Show resolved Hide resolved
test/test_other.py Outdated Show resolved Hide resolved
shutil.copyfile(test_file('other/embind_tsgen.ts'), 'main.ts')
# A package file with type=module is needed to allow top level await in TS.
shutil.copyfile(test_file('other/embind_tsgen_package.json'), 'package.json')
cmd = shared.get_npm_cmd('tsc') + ['embind_tsgen.d.ts', 'main.ts', '--module', 'NodeNext', '--moduleResolution', 'nodenext']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why doesn't tsc generate a file called .mjs here I wonder?

Is the package.json file here needed for running tsc or for running the output?

- Use different expected test file now that the output is different.
-
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