#Is there an easy 'Sane TypeScript Starter' configuration for a NodeJS application?

33 messages · Page 1 of 1 (latest)

unique dove
#

Feels like there's a lot of random ones, but doesn't look to be an official boilerplate. The only one appears to be deprecated on GitHub. I'm just looking for a super simple configuration that's good to start an Express server on. I feel like I've set up TypeScript way too many times to want to do it again.

lime current
#

every project is unique, there are so many use cases

#

front-end, back-end

#

so there is no single configuration that fits all

#

and thuse not "official" config either

unique dove
#

I vaguely assumed that the frontend / backend would be the only two options.

#

As the main things I'm configuring are stuff like export format, etc.

lime current
#

just run tsc --init and change the options according to your needs

#

there aren't that many options, it should be pretty straight forward

#

I can give you a minimal config tho if you want

unique dove
#

That'd be really useful if you have one lying around for NodeJS.

#

Greenfield project, targeting a modern (v16+) version.

lime current
#

the default options given by tsc --init should be good enough 🤔

unique dove
#

The 'commonjs' default for module output surprised me.

lime current
#
{
    "compilerOptions": {
        "target": "es2016",
        "module": "commonjs",
        "outDir": "dist"
        "strict": true
    },
    "include": [
        "src/**/*"
    ]
}
#

it's all you need really

unique dove
#

Will I not run into issues with ESM only modules?

lime current
#

that's a bit more advanced that just the bare minimum

unique dove
#

(Am not sure why I'm asking when I could just test it out, but do really appreciate your expertise.)

lime current
#

tho the opposite is possible

unique dove
#

Are esm imports not the default / assumed strategy now?

lime current
#

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.
This means you have the following choices:

  1. Use ESM yourself. (preferred)
    this basically
lime current
#

lots of packages are still written for commonjs

#

since npm was intended for node

#

and not web stuff

unique dove
#

So sad. I worked on one of the initial proposals for ESM.

lime current
#

and since node only supported cjs at the time

lime current
#

just that you might have to use external tools

lime current