-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle runtime agnostic scripts and type definition conflicts #60464
Comments
This again? |
There's no solution. |
I mean... you already got an answer. Repeatedly opening the very same issue just because you don't like it will not really help. |
Is this a duplicate of #59439? Or something else? Seems like there's some relevant history here but it's not linked. |
@jcalz Related to an appreciable degree. I had to use That's wasn't really a solution to I observe quite a bit of exceptions for Node.js in the general TypeScript compiler options. I don't see options for runtime agnostic source code. I'm wondering if Microsoft TypeScript is interested in handling JavaScript runtime agnostic code that references multiple runtime globals, and might have conflicting types? |
@jcalz FWIW Taking the JavaScript runtime agnostic approach a step further
|
Good luck with that! When you're done, I suggest you also combine Chrome, Firefox, Safari, and Edge into a single executable to get a browser agnostic browser, solving the compatibility problems once and for all. |
Technically I can do the polyflot thing now using only subpprocesses. I've already started, in code. The browser landscape is simple. Eliminate Edge because that's just Chromium with Microsofy branding, eliminate Safari because nothing cutting edge is going on there. We'll keep Firefox just to demonstrate what Chromium should be doing in some cases, and keep Chromium to demonstrate the cutting edge of browser technologies. |
@guillaumebrunerie Something like this already works in JavaScript world https://github.com/guest271314/native-messaging-piper/blob/main/nm_piper.js#L94-L119. TypeScript would throw a fit
Here's a hack a did a while back to make use of Firefox Nightly for capturing speakers, and sending that audio to Chromium, because at the time Chromium authors refused to capture monitor devices Capture monitor device at Nightly stream to Chromium. |
@guillaumebrunerie My question is essentially does Microsoft TypeScript have an interest in handling runtime agnostic, polyglot scripts, where type definitions might, and probably do conflict. If not I can move on and leave TypeScript folks alone and do my own thing like I do anyway. There's a whole bunch of "compatibility" projects, such as WinterCG. But what if JavaScript runtimes didn't even have to concern themselves with "compatibility", specifically "Node.js" compatibility, and just did their own thing? They could eliminate the "Node.js compatibility" claims, which when vetted after beating grass in code, are generally always lacking in some way. Then JavaScript runtimes could focus on their respective features - without trying to be or "pretending" to be Node.js wintercg/runtime-keys#18 (comment)
|
God is joy! π |
NOTE: I'm not a member of the TS team, just an interested community member. Feel free to ignore me if you'd rather wait for Official Word. crosslinking to #21965, #36057, #52433, #53971, which all have to do with trying to support compiling for multiple runtimes. I'm not sure how such a thing could be implemented; even if we allow type predicates or assertion predicates to refer to external things (like in #43786), it seems like a huge lift that checking |
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
To me that is the only reason to use TypeScript. JavaScript runtime agnostic code. Right now Microsoft TypeScript is heavily weighted towards Node.js. There are dozens of JavaScript runtimes. I don't think Node.js, Deno, or Bun actually use Missed opportunity to expand coverage. Oh well, I tried. Thanks for hearing me out anyway. Good luck. |
π Search Terms
"conflicting types"
β Viability Checklist
β Suggestion
tsc
can't handle JavaScript runtime agnostic code. Where there might be conflicting declarations/definitions.π Motivating Example
Here's one relevant part of a piece of JavaScript runtime agnotic code that
tsc
Version 5.8.0-dev.20241109
throws errors for.The code works as expected as JavaScript, without any errors being thrown, becuase there are no errors in the JavaScript code.
@types/node/module.d.ts
has its own internal errors atdirname
andfilename
which I'm not really concerned aboutlib.dom.d.ts
and@types/node
and Bun's@types/bun
all declarefetch
It appears like there's no way for
tsc
to make a deicsion which type to apply forfetch
when the imported types all declarefetch
, and no option to instructtsc
to use X type when X, XX, XXX types from libraries all refer to the same named declaration.Of course the immediate solution is the use
--skipLibCheck
which makes using TypeScript utterly useless. We just use TypeScript syntax for the hell of it.Run
tsc
and see what happensπ» Use Cases
tsc
can't handle Node.js types declaringfetch
and Bun types declaringfetch
.--skipLibCheck
The text was updated successfully, but these errors were encountered: