express icon indicating copy to clipboard operation
express copied to clipboard

TypeScript Example (CJS)

Open Segmentational opened this issue 1 year ago • 3 comments

The following PR relates to a simple TypeScript implementation using [email protected].

Additionally, example (found in examples/typescript) includes a tsconfig.json that compiles down to ES5 JavaScript. A merge request I made previously had failed some tests relating to version limitations (node), so this should handle that case.

However, the compiled JavaScript and other generated assets are set to be tracked via VCS (git). It's of normal operation to usually untrack them via including *.js in the .gitignore.

We can later add a .gitignore in the example folder itself. But I do want to see what the GitHub actions returns with. If appropriate, I'll update/discuss changes to these tests to account for the typescript example.


Discussion

Looking at the other example folders, often they are without README.mds, package.jsons, etc. etc.

While totally fine, the example this PR relates to, as well as another I have outstanding, perhaps could be exceptions. I know the package maintainers and other contributors see, almost daily, issues & questions relating to ESM, TypeScript, and even both.

Providing examples, like this one, hopefully will make everyone's life a bit easier :D.

Segmentational avatar Jun 28 '22 18:06 Segmentational

Nice, seems to have passed

Segmentational avatar Jul 02 '22 20:07 Segmentational

@bozzelliandrea, thank you for the feedback; I've since updated with your recommended changes, and point of replacing require with import.

Sorry my response took so long, I'll try and get back sooner next time around :D.

P.S. I updated the tsconfig.json and package.json to align much closer to what a standard, default configuration would look like. Notice, too, the latest package version reference(s).

Using latest is to avoid (haha hopefully) any technical debt down the road with issues coming through asking to update the typescript example.

Segmentational avatar Jul 15 '22 06:07 Segmentational

@Segmentational everything looks ok and clean, nice work! 😃

Just my curiosity, what does CJS mean?

@bozzelliandrea, sorry for the delayed response... I just moved halfway across the united states, so that took a little time haha.

Yeah, "CJS" can be seen in a few odd places in the node official documentation. The first example, although referenced as a file extension, can be seen here:

  • https://nodejs.org/api/modules.html#enabling

I'm unsure of the exact other places, but essentially it's a shorthand sometimes used to describe the commonjs javascript module type.

Segmentational avatar Jul 25 '22 07:07 Segmentational