Subscribe on changes!

Variable is undeclared but can be used

avatar
Feb 8th 2022

Version

3.2.27

Reproduction link

codesandbox.io

Steps to reproduce

  1. setup function console.log visiable
  2. let { visiable } = useEffectFn()

What is expected?

Variable undeclared should throw error directly

What is actually happening?

Variable undeclared should throw error directly

变量未声明可以直接使用 应该抛出错误

setup() {
    let state = reactive({
      visible: false,
    });
    console.log(visibleVar); // 此处应该抛出错误  而不是undefined    should throw error but get undefined
    let { visibleVar } = useEffectFn();
    const toggle = () => {
      state.visible = !state.visible;
    };
    return {
      ...toRefs(state),
      toggle,
    };
  },
avatar
Feb 8th 2022

You can copy the same code into main.js and it behaves the same.

So this is not related to Vue but to the build system you are using, likely.

avatar
Feb 8th 2022

@LinusBorg Do you mean it is caused by webpack or vite compilation?

avatar
Feb 8th 2022

Yes.