News for hackers. Stuff that matters.
Re:Finally, a guide for Node.js and TypeScript and ESM that ... by Yiin on Tuesday November 21, 2023 @07:16AM (#38362619)
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.
Re:Finally, a guide for Node.js and TypeScript and ESM that ... by austin-cheney on Tuesday November 21, 2023 @07:47AM (#38362927)
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.
Re:Finally, a guide for Node.js and TypeScript and ESM that ... by khalidx on Tuesday November 21, 2023 @07:52AM (#38363006)
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.
Re:Finally, a guide for Node.js and TypeScript and ESM that ... by austin-cheney on Tuesday November 21, 2023 @09:39AM (#38364216)
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

Re:Finally, a guide for Node.js and TypeScript and ESM that ... by khalidx on Tuesday November 21, 2023 @02:02PM (#38368299)
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.