4
にワイルドカードの輸入を列挙:はあなたが持つことができるES2015で、だから、ES2015
// Module A
export const FOO = 0;
export const BAR = 1;
// Module B
import * as AExports from 'ModuleA';
console.log(AExports.FOO); // Prints 0
実行時にModuleAの輸出を列挙する公式の方法は何ですか?
import * as AExports from 'ModuleA';
// Are these values guaranteed to be something?
Object.keys(AExports); // If so, should I look at enumerable values?
[...AExports]; // Iterable values?
Object.getOwnPropertyNames(AExports); // Here?
私の知る限り、specはImportedBindingとしてこれを説明するが、私はそれからより多くの何を推測することはできません。
NameSpaceImport : * as ImportedBinding
Let localName be the StringValue of ImportedBinding.
Let entry be the Record {[[ModuleRequest]]: module, [[ImportName]]: "*", [[LocalName]]: localName }.
Return a new List containing entry.
余分なリンクもありがとう - 次回のために仕様を理解しやすくなりました。 – AnilRedshift