microsoft / microsoft/TypeScript

Dynamic import breaks global onError with requirejs

Open
#32,103 0 comments 0 reactions 1 assignee View on GitHub

@rbuckton is already working on this.

Since Jun 26, 2019.

Needs Investigation
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

TypeScript Version: 3.2.2

Search Terms: dynamic import, requirejs, amd, onerror

Code

import('module').then(()=>{ /* some code*/ });

compiled to

new Promise(function (resolve_1, reject_1) {
   require(['module'], resolve_1, reject_1);
});

If require are called with 3 arguments then require.onError is not fired. Reject should be adeed only in case when we have a catch call after import.

Some propose:

//@ts-import-no-reject
import('module').then(()=>{ /* some code*/ });
new Promise(function (resolve_1) {
   require(['module'], resolve_1);
});

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.