Comments (7)
If you were relying on tsc
for dual emit then it might be the easiest to switch to using tshy. If you prefer to handroll the solution then I'd recommend switching to .ts
files. I've seen you have post-processing step to fixup extensions and stuff - that step could be reused. It feels that if you just tweak its logic a little bit to handle a different set of files and do a slightly different fixup then it should work. Note that I didn't take too deep into your current setup so what I'm saying is not a guarantee but rather a conclusion drawn solely on a first impression of a very tiny slice of your repo ;p
from typescript.
bisects to #59479
from typescript.
So it seems that before this PR it would ignore the fact that your files are authored using .mts
and it would allow you to compile that to a commonjs module. With the new version the extension is always taken into consideration, even with "moduleResolution": "node10"
.
We can trace back this work to #57896 and #58825 . They mention that from now on extensions should be considered in more module
modes but they are not as explicit when it comes to what does it mean for moduleResolution
modes.
This is a one-line change to fix your issue but the changed code is also almost explicit when it comes to applying the new logic for extensions regardless of moduleResolution
... so I think it's best to ping @andrewbranch and defer to his opinion about this.
Minimal repro case:
// @moduleResolution: node10
// @module: commonjs
// @filename: index.mts
export const foo = ''
from typescript.
Yes, this is working as intended. Compiling .mts files to CommonJS-containing .mjs files was not something we ever intended to support—the fact that it ever worked was a bug / unintentional side effect of other work.
from typescript.
from typescript.
This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes.
from typescript.
Thanks for the answer! I'll review how I dual ship then.
It might be good to document cases where tsc ignore settings. I combed through the documentation first and this behavior didn't appear obvious to me.
from typescript.
Related Issues (20)
- Type inference when using `extend` in a generic is not consistent HOT 3
- Check when a function that uses `this` is referenced without binding it HOT 2
- Built-in URL is not compatible with `@types/node` URL
- [suggest] constructor init delegation with "strictPropertyInitialization" HOT 2
- Potential memory leak or dead recursive during auto completion HOT 2
- Incorrect type deducted for accumulator in reduce HOT 2
- moduleResolution: 'bundler' with subpath import seem to not support directory module and extensionless import HOT 4
- Source mappings are missing for serialized properties
- Missing overload method on union types HOT 7
- JSDoc `@import` of "tslib" fails under `--moduleResolution bundler`
- Interface that extends another no longer constrains types like the original HOT 1
- Proposal: Allow isolated declarations to infer results of constructor calls HOT 10
- Property 'difference' does not exist on type 'Set' HOT 3
- Type narrowing of condition leads to unexpected error for assignment HOT 3
- Increase the distinction between class and interface properties when defining a class or interface
- Add adaptation to class and interface property prompts HOT 1
- Weird behavior with recursive generic types HOT 2
- Array of unions changed to union of arrays in conditional type HOT 4
- tsserver requires `npm` to be installed on `neovim` trough `mason` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript.