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

Ts node support + tests #248

Merged
merged 12 commits into from
Jul 13, 2021
Merged

Ts node support + tests #248

merged 12 commits into from
Jul 13, 2021

Conversation

chgeo
Copy link
Member

@chgeo chgeo commented Jul 12, 2021

No description provided.

@CLAassistant
Copy link

CLAassistant commented Jul 12, 2021

CLA assistant check
All committers have signed the CLA.

@chgeo chgeo mentioned this pull request Jul 12, 2021
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@chgeo chgeo changed the title Ts node support in tests Ts node support + tests Jul 12, 2021
@Kkoile
Copy link

Kkoile commented Jul 13, 2021

I have two concerns:

  1. Because you put the preset: ts-jest in the root jest.config, it applies for all tests. Even the non typescript tests. Do they still work? Is it wanted?
  2. I had to manually set the environment variabel CDS_TYPESCRIPT=true in the tests for cds to recognize that it should load typescript files now. It had to be done, because it is not possible to programatically detect, if a process has started with ts-jest preset. I don't see this variable anywhere in the code now. Has something changed, that it is no longer required to set the environment variable? Tests seem to go through...

@Kkoile
Copy link

Kkoile commented Jul 13, 2021

Oh, regarding my second point, I've just seen that the environment variable is actually set: https://github.com/SAP-samples/cloud-cap-samples/pull/248/files#diff-2d29ae20792820e80f8924914e7010e5e25076584cff77b50001f7353d7860a9R1
I wonder though, whether it will break other tests in the future? Probably it would be better to include this

afterAll(() => {
  delete process.env.CDS_TYPESCRIPT;
});

Or remember which was the original value before assigning it true and then set it to the original value in the after handler

@tsteckenborn
Copy link
Contributor

I have two concerns:

  1. Because you put the preset: ts-jest in the root jest.config, it applies for all tests. Even the non typescript tests. Do they still work? Is it wanted?

The preset says quite explicitly:

TypeScript files (.ts, .tsx) will be transformed by ts-jest to CommonJS syntax, leaving JavaScript files (.js, jsx) as-is.

So I would expect it to do exactly the same as before (but including tsx for transformation).

@chgeo
Copy link
Member Author

chgeo commented Jul 13, 2021

So I would expect it to do exactly the same as before (but including tsx for transformation).

Yes, that's also my assumption. If it doesn't harm or slow down the js tests too much, then fine with me.

@chgeo
Copy link
Member Author

chgeo commented Jul 13, 2021

I wonder though, whether it will break other tests in the future? Probably it would be better to include this

afterAll(() => {
  delete process.env.CDS_TYPESCRIPT;
});

Done

@tsteckenborn
Copy link
Contributor

Otherwise, the question is whether there should be a separate sample repository for TypeScript (as it would need to contain ts-config and maybe other configurations in the long run) to separate the necessary configurations of JavaScript and TypeScript for newcomers.

It will be hard to distinguish what is not to compromise the JS parts and what is (really) necessary if I go the TS way. Deleting the variables afterward, for example, shouldn't be required if I decide to go complete TypeScript, right?

Therefore, it could not be obvious. Since the environment variable is not even described in capire or the changelog, it's a bit of a search for users who want to test the TypeScript files anyways.

@chgeo
Copy link
Member Author

chgeo commented Jul 13, 2021

@Kkoile we seem to have issues w/ your CLA. Can you check? Could be that you used a wrong email address not connected to your current GH account.

@chgeo
Copy link
Member Author

chgeo commented Jul 13, 2021

Otherwise, the question is whether there should be a separate sample repository for TypeScript

That's a constant trade-off in how many repos to cut the samples, given that there is maintenance overhead of each new one. That was the reason for the current mono-repo.
I do the see the potential for TS/JS confusion, though.

Since the environment variable is not even described in capire or the changelog

It is (with the wrong value though, about to fix this).

@chgeo
Copy link
Member Author

chgeo commented Jul 13, 2021

@Kkoile I have rewritten your commits with my email address if you don't mind. This way, we get over the CLA barrier.

@chgeo
Copy link
Member Author

chgeo commented Jul 13, 2021

All TS related stuff is now isolated in the hello folder, so that it's clearer where TS land is.

@chgeo chgeo merged commit 9f2eb8f into master Jul 13, 2021
@chgeo chgeo deleted the ts-node_support branch July 13, 2021 12:32
@Kkoile
Copy link

Kkoile commented Jul 14, 2021

Sorry, I'm always a bit behind timewise with my private github account. But sinced you merge the pull request, I guess everything is clear now and there's nothing more to do?

@chgeo
Copy link
Member Author

chgeo commented Jul 14, 2021

Right, all is settled :)

@tsteckenborn
Copy link
Contributor

@chgeo With the documentation saying "We invite you to contribute and help us complete the typings as appropriate. Sounds interesting? Reach out to us." -> Whom would we need to reach out to?

@chgeo
Copy link
Member Author

chgeo commented Sep 6, 2021

@tsteckenborn you can reach out to me (christian.georgi@sap.com) and maybe nils.hirsekorn@sap.com (@Kkoile), who is an active TS user here at SAP.

(@iwonahahn FYI)

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.

4 participants