Hacker News new | past | comments | ask | show | jobs | submit login

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

I completely disagree. This has always felt immediately straight forward to me. I suspect this struggle, a struggle I completely don’t understand, explains the complexity of hiring for these kinds of jobs. I really felt that to get hired for these jobs you had to be willing to play stupid games and abandon all reason to worship at the pulpit of giant frameworks and third party solutions. Fortunately, I have moved on to something else.




I'd love to see you live stream a process of creating a project consisting of several different apps using same ts config and shared libs folder from scratch using these tools.


In my personal projects I use ”type”: “module” in the package.json.

In my tsconfig.json I use

    {
    "compilerOptions": {
        "alwaysStrict": true,
        "module": "ES2020",
        "moduleResolution": "node",
        "outDir": "./js/lib",
        "noEmit": true,
        "noImplicitAny": true,
        "pretty": false,
        "strictFunctionTypes": true,
        "target": "ES2020",
        "types": ["node"],
        "typeRoots": ["./node_modules/@types"]
    },
    "exclude": [
        "js",
        "lib/terminal/test/storageTest/temp",
        "**/node_modules",
        "**/.*/"
    ],
    "include": [
        "**/*.ts"
    ]
    }
Internally in your apps never never use relative file system paths.


Is alwaysStrict the same as strict? I think this skips a lot of the strict options that are usually the case for using TypeScript in the first place.


According to the TypeScript documentation for tsconfig.json the alwaysStrict option forces the compiled out to strict mode such that the JIT interpreter parses it as such. This happens anyways when using ES6 modules, but it also ensures the TypeScript compiler parses each file in strict mode regardless of having the "use strict" pragma at the top.

https://www.typescriptlang.org/tsconfig#alwaysStrict


I just dug a bit deeper as I couldn't remember the differences. They're not referring to the same things.

"alwaysStrict", which adds "use strict", is different than TypeScript "strict" mode, which constrains the language.

Setting "strict" to "true" enables "alwaysStrict", but not the other way around. I'd remove "alwaysStrict" and go with "strict" as it covers more things.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: