vuejs/vue

compiler-sfc: type.startsWith is not a function

linlinyang opened this issue · 1 comments

Version

2.7.14

Reproduction link

github.com

Steps to reproduce

if (isScriptSetup) {
const type = bindings[name];
if (type) {
console.log(typeof type); // function
}
if (type && type.startsWith('setup')) {
prefix = _setup.;
}
}

What is expected?

Change code:
if (type && type.startsWith('setup')) {
prefix = _setup.;
}
to:
if (typeof type === 'string' && type.startsWith('setup')) {
prefix = _setup.;
}

What is actually happening?

The type of bindings[name] can be 'function' in my project, and type.startsWith throw error.

Please don't open issues without reproductions