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
// A *self-contained* demonstration of the problem follows...// --module esnext --allowSyntheticDefaultImports (or with --module system)import('jquery').then(({default: $})=>$('div'));
Expected behavior:
The shape of the dynamically imported jquery's module namespace object includes a default member having the type JQueryStatic<HTMLElement> as it does when using the static import syntax as in
import{defaultas$}from'jquery';$('div');
under --module system or with --allowSyntheticDefaultImports
Actual behavior:
error TS2459: Type 'JQueryStatic<HTMLElement>' has no property 'default' and no string index signature.
Note that this is tricky since the expected mapping does not quite correspond to that of a static import since import('jquery').then($ => $('div')); probably should not work, but the default member should be present.
The text was updated successfully, but these errors were encountered:
I'd recommend just never using dynamic import with a commonjs module.
Do you mean that modules transpiled from ESNext to CommonJS should never use dynamic import, that modules in CommonJS format should never be imported using the construct, or both?
While we are stuck in a transpiling world, it’s safe to import transpiled
modules (that don’t do add-module-exports shenanigans), but it will not
work with transpiled modules either in real module implementation.
On Sat, Jul 29, 2017 at 4:53 Aluan Haddad ***@***.***> wrote:
I'd recommend just never using dynamic import with a commonjs module.
Do you mean that modules transpiled from ESNext to CommonJS should never
use dynamic import, that modules in CommonJS format should never be
imported using the construct, or both?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#17444 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEdfSs4V_7RiYeFp_TCR_r4ehmut9Ihks5sSjwugaJpZM4OkvHt>
.
TypeScript Version: 2.5.0-dev.20170725
Code
Expected behavior:
The shape of the dynamically imported
jquery
's module namespace object includes adefault
member having the typeJQueryStatic<HTMLElement>
as it does when using the static import syntax as inunder
--module system
or with--allowSyntheticDefaultImports
Actual behavior:
Note that this is tricky since the expected mapping does not quite correspond to that of a static import since
import('jquery').then($ => $('div'));
probably should not work, but thedefault
member should be present.The text was updated successfully, but these errors were encountered: