Vue3 源码中一个自相矛盾的地方?

Vue3源码(版本3.2.38)中的package/compiler-core/src/validateExpression.ts文件。
prohibitedKeywordRE中写的是禁止使用的单词里边有typeof,但是上边的注释里却说typeof是允许的 ?

// these keywords should not appear inside expressions, but operators like
// 省略
// typeof, instanceof and in are allowed
const prohibitedKeywordRE = new RegExp(
  '\\b' +
    (
      'do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,' +
      'super,throw,while,yield,delete,export,import,return,switch,default,' +
      'extends,finally,continue,debugger,function,arguments,typeof,void'
    )
      .split(',')
      .join('\\b|\\b') +
    '\\b'
)
阅读 1.2k
1 个回答

刚开始没有,后来维护慢慢新加的,然后注释忘了修改

vue3很多代码是从vue2迁移过去的,比如这里应该就是,vue2的时候这里是没有禁止typeof和void的

image.png

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题