(node: Node | undefined, method: string)
| 280 | } |
| 281 | |
| 282 | function checkInvalidScopeReference(node: Node | undefined, method: string) { |
| 283 | if (!node) return |
| 284 | walkIdentifiers(node, id => { |
| 285 | const binding = setupBindings[id.name] |
| 286 | if (binding && binding !== BindingTypes.LITERAL_CONST) { |
| 287 | ctx.error( |
| 288 | `\`${method}()\` in <script setup> cannot reference locally ` + |
| 289 | `declared variables because it will be hoisted outside of the ` + |
| 290 | `setup() function. If your component options require initialization ` + |
| 291 | `in the module scope, use a separate normal <script> to export ` + |
| 292 | `the options instead.`, |
| 293 | id, |
| 294 | ) |
| 295 | } |
| 296 | }) |
| 297 | } |
| 298 | |
| 299 | const scriptAst = ctx.scriptAst |
| 300 | const scriptSetupAst = ctx.scriptSetupAst! |
no test coverage detected