convertToResolveOptions = resolveOptionsWithDepType => {
	const { dependencyType, plugins, ...remaining } = resolveOptionsWithDepType;

	// check type compat
	/** @type {Partial<ResolveOptionsWithDependencyType>} */
	const partialOptions = {
		...remaining,
		plugins:
			plugins &&
			/** @type {ResolvePluginInstance[]} */ (
				plugins.filter(item => item !== "...")
			)
	};

	if (!partialOptions.fileSystem) {
		throw new Error(
			"fileSystem is missing in resolveOptions, but it's required for enhanced-resolve"
		);
	}
	// These weird types validate that we checked all non-optional properties
	const options =
		/** @type {Partial<ResolveOptionsWithDependencyType> & Pick<ResolveOptionsWithDependencyType, "fileSystem">} */ (
			partialOptions
		);

	return /** @type {ResolveOptions} */ (
		removeOperations(
			resolveByProperty(options, "byDependency", dependencyType),
			// Keep the `unsafeCache` because it can be a `Proxy`
			["unsafeCache"]
		)
	);
}
@param {ResolveOptionsWithDependencyType} resolveOptionsWithDepType enhanced options
@returns {ResolveOptions} merged options