Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async / await #319

Closed
jgravois opened this issue Sep 12, 2018 · 1 comment
Closed

async / await #319

jgravois opened this issue Sep 12, 2018 · 1 comment
Assignees

Comments

@jgravois
Copy link
Contributor

need to investigate the impact on our UMD / ESM output.

@jgravois jgravois self-assigned this Sep 12, 2018
@jgravois
Copy link
Contributor Author

jgravois commented Sep 21, 2018

Pros:

  • typescript 2.1+ indeed transpiles async/await to ES5 anywhere Promise is available.
  • it looks nice!
export function setItemAccess(/**/): Promise<> {
    // ...
    return isOrgAdmin(requestOptions).then(admin => { 
       if (admin) { 

becomes

export async function setItemAccess(/**/): Promise<> {
    // ...
    const admin = await isOrgAdmin(requestOptions)
    if (admin) {

Cons:

  • the change above costs almost 1.5 KB.
┌─────────────────────────────────────────────────┐
│                                                 │
│   Destination: ./dist/umd/sharing.umd.min.js    │
│   Bundle size: 3.02 KB, Gzipped size: 1.25 KB   │
│                                                 │
└─────────────────────────────────────────────────┘

becomes

┌────────────────────────────────────────────────┐
│                                                │
│   Destination: ./dist/umd/sharing.umd.min.js   │
│   Bundle size: 4.4 KB, Gzipped size: 1.88 KB   │
│                                                │
└────────────────────────────────────────────────┘

The Async Await chapter of TypeScript Deep Dive 💯 by @basarat includes a helpful canned example of just how much ES5 transpiled code underpins the ✨ in .ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant