Description
For TypeScript 4.7, we pulled back the resolution-mode
import assertion from import type
syntax. This was based in part on feedback around the feature being a bit outside the spirit of import assertion syntax (#48644); however, we also just don't want to add features if we're not 100% convinced that they're going to be used. This was discussed a bit at #48686.
So if you try to use resolution-mode
as follows
// Resolve `pkg` as if we were importing with a CommonJS `require()`
import type { TypeFromRequire } from "pkg" assert {
"resolution-mode": "require"
};
// Resolve `pkg` as if we were importing with an ES module `import`
import type { TypeFromImport } from "pkg" assert {
"resolution-mode": "import"
};
export interface MergedType extends TypeFromRequire, TypeFromImport {}
you'll get the following error:
Resolution mode assertions are unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'.
Maybe you're using this because you're trying to bridge a CJS/ESM codebase, or maybe you're trying to provide some sort of meta-library that does that. We're not entirely sure!
So if you run into this error, what are you trying to do? What do you need it for? Is there a syntax you'd prefer to use, or is it fine as-is?