Skip to content

Instantly share code, notes, and snippets.

@MichaelFedora
Created July 29, 2017 16:26
Show Gist options
  • Save MichaelFedora/c3b521845a671d3ef9a7399cd97b2514 to your computer and use it in GitHub Desktop.
Save MichaelFedora/c3b521845a671d3ef9a7399cd97b2514 to your computer and use it in GitHub Desktop.
dynamic import test
(async () => {
let foo = (i: number): [number, Promise<any>] => {
switch(i) {
case 0: return [4, import('./test')];
default: return [0, Promise.resolve(null)];
}
}
const res = foo(0);
console.log(res[0], await res[1]);
// should output `4 { default: { greeting: 'Hello World!' } }`
})();
export default { greeting: 'Hello World!' };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment