News for hackers. Stuff that matters.
Re:Deno in 2021 by spankalee on Tuesday January 25, 2022 @01:36PM (#30075956)
The way TypeScript/Node does it is correct. The thing you're importing is JS with a .js extension. If you publish to npm you're publishing the JS files, not TS files. If you write .d.ts/.js pairs instead of .ts - which should be identical to importers, there's no .ts file to import.
Re:Deno in 2021 by nllsh on Tuesday January 25, 2022 @01:48PM (#30076134)
Considering that Ryan Dahl started both Node.js (where imports do not include file extensions) and Deno (where he added them back after deciding it was a bad decision to leave them off) I'm not sure how you've come to the conclusion that TypeScript/Node does importing correctly. Additionally, the ecmascript import syntax https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... specifically mentions that your tooling may or may not need file extensions but the examples in the spec (and indeed in browsers at large) require a full or relative path including the extension. If anything, I'd bet that file extensions make it into Node and tsc in the next few years.
Re:Deno in 2021 by spankalee on Tuesday January 25, 2022 @03:39PM (#30077714)
Node requires the extension for imports already, unless the package you're importing from has defined extensionless entries in an export map.
Re:Deno in 2021 by xkapastel on Tuesday January 25, 2022 @10:40PM (#30081392)
I don't see how it is correct. If you publish to npm, of course you do it the way Node does it, but that's not very interesting. If you publish a module for consumption by Deno, you're publishing TS files, not JS files, and there is no need for .d.ts files.