Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
<script>
let test = 0;

$: promise = Promise.resolve({ data: 1 });
</script>

{#await promise then { data }}
{#if data}
<button on:click={() => (test = 1)}>Test</button>
{:else}data is {data}{/if}
{/await}

Error compiling component

WebAssembly.instantiateStreaming(): value type opcode @+13
/* App.svelte generated by Svelte v3.29.3 */
import {
SvelteComponent,
detach,
element,
empty,
handle_promise,
init,
insert,
listen,
noop,
safe_not_equal,
set_data,
text
} from "svelte/internal";

function get_then_context(ctx) {
ctx[3] = ctx[4].data;
}

// (1:0) <script> let test = 0; $: promise = Promise.resolve({ data: 1 }
function create_catch_block(ctx) {
return { c: noop, m: noop, p: noop, d: noop };
}

// (7:30) {#if data}
function create_then_block(ctx) {
get_then_context(ctx);
let if_block_anchor;

function select_block_type(ctx, dirty) {
if (/*data*/ ctx[3]) return create_if_block;
return create_else_block;
}

let current_block_type = select_block_type(ctx, -1);
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • {
    • html: Fragment {...}
      • start: 80
      • end: 211
      • type: "Fragment"
      • children: [...] (2)
        • Text {...}
          • start: 78
          • end: 80
          • type: "Text"
          • raw: "\n\n"
          • data: "\n\n"
          }
        • AwaitBlock {...}
          • start: 80
          • end: 211
          • type: "AwaitBlock"
          • expression: Identifier {...}
            • type: "Identifier"
            • start: 88
            • end: 95
            • loc: {...}
              • start: {...}
                • line: 7
                • column: 8
                }
              • end: {...}
                • line: 7
                • column: 15
                }
              }
            • name: "promise"
            }
          • value: ObjectPattern {...}
            • type: "ObjectPattern"
            • start: 101
            • end: 109
            • loc: {...}
              • start: {...}
                • line: 7
                • column: 22
                }
              • end: {...}
                • line: 7
                • column: 30
                }
              }
            • properties: [...] (1)
              • Property {...}
                • type: "Property"
                • start: 103
                • end: 107
                • loc: {...}
                  • start: {...}
                    • line: 7
                    • column: 24
                    }
                  • end: {...}
                    • line: 7
                    • column: 28
                    }
                  }
                • method: false
                • shorthand: true
                • computed: false
                • key: Identifier {...}
                  • type: "Identifier"
                  • start: 103
                  • end: 107
                  • loc: {...}
                    • start: {...}
                      • line: 7
                      • column: 24
                      }
                    • end: {...}
                      • line: 7
                      • column: 28
                      }
                    }
                  • name: "data"
                  }
                • kind: "init"
                • value: Identifier {...}
                  • type: "Identifier"
                  • start: 103
                  • end: 107
                  • loc: {...}
                    • start: {...}
                      • line: 7
                      • column: 24
                      }
                    • end: {...}
                      • line: 7
                      • column: 28
                      }
                    }
                  • name: "data"
                  }
                }
              ]
            }
          • error: null
          • pending: PendingBlock {...}
            • start: null
            • end: null
            • type: "PendingBlock"
            • children: []
            • skip: true
            }
          • then: ThenBlock {...}
            • start: 110
            • end: 203
            • type: "ThenBlock"
            • children: [...] (3)
              • Text {...}
                • start: 110
                • end: 112
                • type: "Text"
                • raw: "\n\t"
                • data: "\n\t"
                }
              • IfBlock {...}
                • start: 112
                • end: 202
                • type: "IfBlock"
                • expression: Identifier {...}
                  • type: "Identifier"
                  • start: 117
                  • end: 121
                  • loc: {...}
                    • start: {...}
                      • line: 8
                      • column: 6
                      }
                    • end: {...}
                      • line: 8
                      • column: 10
                      }
                    }
                  • name: "data"
                  }
                • children: [...] (1)
                  • Element {...}
                    • start: 125
                    • end: 174
                    • type: "Element"
                    • name: "button"
                    • attributes: [...] (1)
                      • EventHandler {...}
                        • start: 133
                        • end: 160
                        • type: "EventHandler"
                        • name: "click"
                        • modifiers: []
                        • expression: ArrowFunctionExpression {...}
                          • type: "ArrowFunctionExpression"
                          • start: 143
                          • end: 159
                          • loc: {...}
                            • start: {...}
                              • line: 9
                              • column: 20
                              }
                            • end: {...}
                              • line: 9
                              • column: 36
                              }
                            }
                          • id: null
                          • expression: true
                          • generator: false
                          • async: false
                          • params: []
                          • body: CallExpression {...}
                            • type: "CallExpression"
                            • start: 0
                            • end: 69
                            • callee: Identifier {...}
                              • type: "Identifier"
                              • start: 0
                              • end: 12
                              • name: "$$invalidate"
                              }
                            • arguments: [...] (2)
                              • Literal {...}
                                • type: "Literal"
                                • value: 0
                                }
                              • AssignmentExpression {...}
                                • type: "AssignmentExpression"
                                • start: 150
                                • end: 158
                                • loc: {...}
                                  • start: {...}
                                    • line: 9
                                    • column: 27
                                    }
                                  • end: {...}
                                    • line: 9
                                    • column: 35
                                    }
                                  }
                                • operator: "="
                                • left: Identifier {...}
                                  • type: "Identifier"
                                  • start: 150
                                  • end: 154
                                  • loc: {...}
                                    • start: {...}
                                      • line: 9
                                      • column: 27
                                      }
                                    • end: {...}
                                      • line: 9
                                      • column: 31
                                      }
                                    }
                                  • name: "test"
                                  }
                                • right: Literal {...}
                                  • type: "Literal"
                                  • start: 157
                                  • end: 158
                                  • loc: {...}
                                    • start: {...}
                                      • line: 9
                                      • column: 34
                                      }
                                    • end: {...}
                                      • line: 9
                                      • column: 35
                                      }
                                    }
                                  • value: 1
                                  • raw: "1"
                                  }
                                }
                              ]
                            • optional: false
                            }
                          }
                        }
                      ]
                    • children: [...] (1)
                      • Text {...}
                        • start: 161
                        • end: 165
                        • type: "Text"
                        • raw: "Test"
                        • data: "Test"
                        }
                      ]
                    }
                  ]
                • else: ElseBlock {...}
                  • start: 183
                  • end: 197
                  • type: "ElseBlock"
                  • children: [...] (2)
                    • Text {...}
                      • start: 183
                      • end: 191
                      • type: "Text"
                      • raw: "data is "
                      • data: "data is "
                      }
                    • MustacheTag {...}
                      • start: 191
                      • end: 197
                      • type: "MustacheTag"
                      • expression: Identifier {...}
                        • type: "Identifier"
                        • start: 192
                        • end: 196
                        • loc: {...}
                          • start: {...}
                            • line: 10
                            • column: 17
                            }
                          • end: {...}
                            • line: 10
                            • column: 21
                            }
                          }
                        • name: "data"
                        }
                      }
                    ]
                  }
                }
              • Text {...}
                • start: 202
                • end: 203
                • type: "Text"
                • raw: "\n"
                • data: "\n"
                }
              ]
            • skip: false
            }
          • catch: CatchBlock {...}
            • start: null
            • end: null
            • type: "CatchBlock"
            • children: []
            • skip: true
            }
          }
        ]
      }
    • css: undefined
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 78
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 69
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 5
            • column: 0
            }
          }
        • body: [...] (2)
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 10
            • end: 23
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 14
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 14
                • end: 22
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 5
                    }
                  • end: {...}
                    • line: 2
                    • column: 13
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 14
                  • end: 18
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 5
                      }
                    • end: {...}
                      • line: 2
                      • column: 9
                      }
                    }
                  • name: "test"
                  }
                • init: Literal {...}
                  • type: "Literal"
                  • start: 21
                  • end: 22
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 12
                      }
                    • end: {...}
                      • line: 2
                      • column: 13
                      }
                    }
                  • value: 0
                  • raw: "0"
                  }
                }
              ]
            • kind: "let"
            }
          • LabeledStatement {...}
            • type: "LabeledStatement"
            • start: 26
            • end: 68
            • loc: {...}
              • start: {...}
                • line: 4
                • column: 1
                }
              • end: {...}
                • line: 4
                • column: 43
                }
              }
            • body: ExpressionStatement {...}
              • type: "ExpressionStatement"
              • start: 29
              • end: 68
              • loc: {...}
                • start: {...}
                  • line: 4
                  • column: 4
                  }
                • end: {...}
                  • line: 4
                  • column: 43
                  }
                }
              • expression: AssignmentExpression {...}
                • type: "AssignmentExpression"
                • start: 29
                • end: 67
                • loc: {...}
                  • start: {...}
                    • line: 4
                    • column: 4
                    }
                  • end: {...}
                    • line: 4
                    • column: 42
                    }
                  }
                • operator: "="
                • left: Identifier {...}
                  • type: "Identifier"
                  • start: 29
                  • end: 36
                  • loc: {...}
                    • start: {...}
                      • line: 4
                      • column: 4
                      }
                    • end: {...}
                      • line: 4
                      • column: 11
                      }
                    }
                  • name: "promise"
                  }
                • right: CallExpression {...}
                  • type: "CallExpression"
                  • start: 39
                  • end: 67
                  • loc: {...}
                    • start: {...}
                      • line: 4
                      • column: 14
                      }
                    • end: {...}
                      • line: 4
                      • column: 42
                      }
                    }
                  • callee: MemberExpression {...}
                    • type: "MemberExpression"
                    • start: 39
                    • end: 54
                    • loc: {...}
                      • start: {...}
                        • line: 4
                        • column: 14
                        }
                      • end: {...}
                        • line: 4
                        • column: 29
                        }
                      }
                    • object: Identifier {...}
                      • type: "Identifier"
                      • start: 39
                      • end: 46
                      • loc: {...}
                        • start: {...}
                          • line: 4
                          • column: 14
                          }
                        • end: {...}
                          • line: 4
                          • column: 21
                          }
                        }
                      • name: "Promise"
                      }
                    • property: Identifier {...}
                      • type: "Identifier"
                      • start: 47
                      • end: 54
                      • loc: {...}
                        • start: {...}
                          • line: 4
                          • column: 22
                          }
                        • end: {...}
                          • line: 4
                          • column: 29
                          }
                        }
                      • name: "resolve"
                      }
                    • computed: false
                    • optional: false
                    }
                  • arguments: [...] (1)
                    • ObjectExpression {...}
                      • type: "ObjectExpression"
                      • start: 55
                      • end: 66
                      • loc: {...}
                        • start: {...}
                          • line: 4
                          • column: 30
                          }
                        • end: {...}
                          • line: 4
                          • column: 41
                          }
                        }
                      • properties: [...] (1)
                        • Property {...}
                          • type: "Property"
                          • start: 57
                          • end: 64
                          • loc: {...}
                            • start: {...}
                              • line: 4
                              • column: 32
                              }
                            • end: {...}
                              • line: 4
                              • column: 39
                              }
                            }
                          • method: false
                          • shorthand: false
                          • computed: false
                          • key: Identifier {...}
                            • type: "Identifier"
                            • start: 57
                            • end: 61
                            • loc: {...}
                              • start: {...}
                                • line: 4
                                • column: 32
                                }
                              • end: {...}
                                • line: 4
                                • column: 36
                                }
                              }
                            • name: "data"
                            }
                          • value: Literal {...}
                            • type: "Literal"
                            • start: 63
                            • end: 64
                            • loc: {...}
                              • start: {...}
                                • line: 4
                                • column: 38
                                }
                              • end: {...}
                                • line: 4
                                • column: 39
                                }
                              }
                            • value: 1
                            • raw: "1"
                            }
                          • kind: "init"
                          }
                        ]
                      }
                    ]
                  • optional: false
                  }
                }
              }
            • label: Identifier {...}
              • type: "Identifier"
              • start: 26
              • end: 27
              • loc: {...}
                • start: {...}
                  • line: 4
                  • column: 1
                  }
                • end: {...}
                  • line: 4
                  • column: 2
                  }
                }
              • name: "$"
              }
            }
          ]
        • sourceType: "module"
        }
      }
    • module: undefined
    }
The AST is not public API and may change at any point in time