You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now seeing /// <reference types="..." /> directives getting generated with resolution-mode="require" in declaration emit.
Not everyone is using the same TS version, resolution options.
Need to either make TS more lenient or generate these resolution-mode attributes appear less-often.
TypeScript will generate these /// <reference types /> directives to ensure broader compatibility for consumers.
When TypeScript encounters /// <reference types="chai" /> from an ES module, we try to do an import to chai, not find a . export in chai's package.json, and fall back to the CommonJS types anyway.
Could we just support resolution-mode regardless of any settings?
Probably, and could even for import type.
Very weird that the types compiler option doesn't support this.
Tracking Recursion Identity of Homomorphic Mapped Types Based On Their Target Symbol
The DOM has a global fetch function and a few related global classes.
As of Node 20, Node.js has a compatible global fetch.
They're compatible, but not identical.
This is a problem because a lot of users with front-end projects accidentically end up including Node's types - either via misconfiguration or a "rogue" package in node_modules.
Two solutions.
One is through a level of indirection where the global types extend aliases from Unici. They are conditionally extended from Undici based on whether the global scope includes some amount of information from the DOM.
Downside: hard dependency on Undici, which is fairly large as a package. 1MB because it doesn't just include types. Have to worry about versioning.
Technically, Undici is shipped within Node.js, but only kinda exposed. Similarly, fs.rm is actually rimraf under the hood. (!)
Alternatively, duplicate all the contents of fetch. About 600 lines, so not small.
The text was updated successfully, but these errors were encountered:
This is a problem because a lot of users with front-end projects accidentically end up including Node's types
I don't want to nit-pick at all, but in case the intent of the above sentence is important: a lot of front-end projects intentionally include @types/node (usually transitively), because they want to use TS in build tooling that runs in Node -- think TS-flavored config files for Webpack, Jest, etc. Point being, any proposed solutions should assume that making TS "hide" @types/node in frontend projects will cause other problems.
Recognizing
Symbol.hasInstance
ininstanceof
Narrowing#55052
Symbol.hasInstance
when performing aninstanceof
.[Symbol.hasInstance]
-declared methods that are declared as type guards.any
.Improve portability of resolution-mode assertions automatically emitted in
nodenext
#55579
/// <reference types="..." />
directives getting generated withresolution-mode="require"
in declaration emit./// <reference types />
directives to ensure broader compatibility for consumers./// <reference types="chai" />
from an ES module, we try to do an import tochai
, not find a.
export inchai
'spackage.json
, and fall back to the CommonJS types anyway.resolution-mode
regardless of any settings?import type
.types
compiler option doesn't support this.Tracking Recursion Identity of Homomorphic Mapped Types Based On Their Target Symbol
#55638
When tracking if
Foo2
is compatible withFoo1
, we would say "We sawId<*Something*>
too many times".Id
itself when tracking recursive instantiation.Now, if
*Something*
is a type with a symbol, we use that as the identity.Breaks the raphael package on DefinitelyTyped. Can be fixed with
in out
.How does this work for nested mapped types?
Technically you can still hit issues between non-identical mapped types.
Enabling
fetch
in Node.jsDefinitelyTyped/DefinitelyTyped#60924
fetch
function and a few related global classes.fetch
.node_modules
.fs.rm
is actually rimraf under the hood. (!)fetch
. About 600 lines, so not small.The text was updated successfully, but these errors were encountered: