Open
Description
TypeScript Version: 4.2.0-dev.20201126
Search Terms: TS2305
Code
// Must be in JS mode, works in TS mode
const { HttpUriPlugin } = require("webpack").experiments.schemes;
// TS2305: Module '"webpack"' has no exported member 'schemes'.
// Syntax equivalents that work:
const schemes = require("webpack").experiments.schemes;
const HttpUriPluginAlternative1 = require("webpack").experiments.schemes.HttpUriPlugin;
const { schemes: { HttpUriPlugin: HttpUriPluginAlternative2 } } = require("webpack").experiments;
console.log(HttpUriPlugin);
console.log(schemes.HttpUriPlugin);
console.log(HttpUriPluginAlternative1);
console.log(HttpUriPluginAlternative2);
Expected behavior:
Destructuring a nested namespace in JS mode doesn't lead to an error
Actual behavior:
An error is emitted.
The error also looks a bit weird:
Module '"webpack"' has no exported member 'schemes'.
Something like Namespace 'experiments' has no exported member 'schemes'.
would make more sense.
It seems like it looks up schemes
on the wrong type...
Playground Link: Link
Related Issues: