News for hackers. Stuff that matters.
Re:Modern Node.js Patterns by theThree on Sunday August 03, 2025 @07:06PM (#44780587)
It's still not ready for use. I don't care Enum. But you can not import local files without extensions. You can not define class properties in constructor.
Re:Modern Node.js Patterns by erikpukinskis on Sunday August 03, 2025 @07:36PM (#44780771)
Why would you want to do either of those?
Re:Modern Node.js Patterns by solarkraft on Sunday August 03, 2025 @08:44PM (#44781134)
Both are very common Typescript patterns.
Re:Modern Node.js Patterns by bapak on Sunday August 03, 2025 @11:33PM (#44781911)
Importing without extensions is not a TypeScript thing at all. Node introduced it at the beginning and then stopped when implementing ESM. Being strict is a feature.

What's true is that they "support TS" but require .ts extensions, which was never even allowed until Node added "TS support". That part is insane.

TS only ever accepted .js and officially rejected support for .ts appearing in imports. Then came Node and strong-armed them into it.

Re:Modern Node.js Patterns by silverwind on Monday August 04, 2025 @04:55AM (#44783380)
Maybe common in some legacy code bases. I recommend running with `erasableSyntaxOnly` for new code bases.
Re:Modern Node.js Patterns by throwitaway1123 on Sunday August 03, 2025 @09:03PM (#44781211)
Enums and parameter properties can be enabled with the --experimental-transform-types CLI option.

Not being able to import TypeScript files without including the ts extension is definitely annoying. The rewriteRelativeImportExtensions tsconfig option added in TS 5.7 made it much more bearable though. When you enable that option not only does the TS compiler stop complaining when you specify the '.ts' extension in import statements (just like the allowImportingTsExtensions option has always allowed), but it also rewrites the paths if you compile the files, so that the build artifacts have the correct js extension: https://www.typescriptlang.org/docs/handbook/release-notes/t...

Re:Modern Node.js Patterns by int_19h on Monday August 04, 2025 @02:15AM (#44782572)
Why not import files with extensions? That's the way JS (and TS) import is actually supposed to work.
Re:Modern Node.js Patterns by mcv on Monday August 04, 2025 @06:10AM (#44783858)
I have to admit I was a bit surprised when I was suddenly expected to get rid of all extensions in import. Sure, looks clean, but is it right?