5 ms·
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.
by theThree 1y ago
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.
- erikpukinskis 1y agoWhy would you want to do either of those?
- solarkraft 1y agoBoth are very common Typescript patterns.
- bapak 1y agoImporting 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.
- silverwind 1y agoMaybe common in some legacy code bases. I recommend running with `erasableSyntaxOnly` for new code bases.
- throwitaway1123 1y agoEnums 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/typescript-5-7.html#path-rewriting-for-relative-paths https://www.typescriptlang.org/docs/handbook/release-notes/t...
- int_19h 1y agoWhy not import files with extensions? That's the way JS (and TS) import is actually supposed to work.
- mcv 1y agoI 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?