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
// Must be in JS mode, works in TS modeconst{ HttpUriPlugin }=require("webpack").experiments.schemes;// TS2305: Module '"webpack"' has no exported member 'schemes'.// Syntax equivalents that work:constschemes=require("webpack").experiments.schemes;constHttpUriPluginAlternative1=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...
I couldn't find any other code bases that try the combination of property accesses and destructuring. This is indeed an incorrect outcome that neither the ad-hoc alias resolution code nor the synthetic-type fallback correctly handle, but I'm not sure it's worth complicating the already-bizarre code unless we find out that lots of people want to write this code.
TypeScript Version: 4.2.0-dev.20201126
Search Terms: TS2305
Code
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:
The text was updated successfully, but these errors were encountered: