diff --git a/packages/language-core/lib/codegen/template/elementProps.ts b/packages/language-core/lib/codegen/template/elementProps.ts index bc89699972..4901430045 100644 --- a/packages/language-core/lib/codegen/template/elementProps.ts +++ b/packages/language-core/lib/codegen/template/elementProps.ts @@ -68,7 +68,7 @@ export function* generateElementProps( if ( propName === undefined - || options.vueCompilerOptions.dataAttributes.some(pattern => minimatch(propName!, pattern)) + || options.vueCompilerOptions.dataAttributes.some(pattern => minimatch(propName, pattern)) || (propName === 'style' && ++styleAttrNum >= 2) || (propName === 'class' && ++classAttrNum >= 2) || (propName === 'name' && node.tagType === CompilerDOM.ElementTypes.SLOT) // #2308 @@ -82,7 +82,7 @@ export function* generateElementProps( const shouldCamelize = canCamelize && (!prop.arg || (prop.arg.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION && prop.arg.isStatic)) // isStatic && hyphenateAttr(propName) === propName - && !options.vueCompilerOptions.htmlAttributes.some(pattern => minimatch(propName!, pattern)); + && !options.vueCompilerOptions.htmlAttributes.some(pattern => minimatch(propName, pattern)); const codes = wrapWith( prop.loc.start.offset, diff --git a/packages/language-core/lib/plugins/file-html.ts b/packages/language-core/lib/plugins/file-html.ts index afd3c28e1f..72440aebc7 100644 --- a/packages/language-core/lib/plugins/file-html.ts +++ b/packages/language-core/lib/plugins/file-html.ts @@ -39,7 +39,7 @@ const plugin: VueLanguagePlugin = () => { const attrs = match[2]; const lang = attrs.match(langReg)?.[2]; const content = match[3]; - const contentStart = match.index! + matchText.indexOf(content); + const contentStart = match.index + matchText.indexOf(content); if (tag === 'style') { sfc.descriptor.styles.push({ @@ -70,7 +70,7 @@ const plugin: VueLanguagePlugin = () => { }; } - templateContent = templateContent.substring(0, match.index) + ' '.repeat(matchText.length) + templateContent.substring(match.index! + matchText.length); + templateContent = templateContent.substring(0, match.index) + ' '.repeat(matchText.length) + templateContent.substring(match.index + matchText.length); } sfc.descriptor.template = { diff --git a/packages/language-service/lib/plugins/vue-twoslash-queries.ts b/packages/language-service/lib/plugins/vue-twoslash-queries.ts index 093943a392..86987bdaab 100644 --- a/packages/language-service/lib/plugins/vue-twoslash-queries.ts +++ b/packages/language-service/lib/plugins/vue-twoslash-queries.ts @@ -26,7 +26,7 @@ export function create( const inlayHints: vscode.InlayHint[] = []; for (const pointer of document.getText(range).matchAll(twoslashReg)) { - const offset = pointer.index! + pointer[0].indexOf('^?') + document.offsetAt(range.start); + const offset = pointer.index + pointer[0].indexOf('^?') + document.offsetAt(range.start); const position = document.positionAt(offset); hoverOffsets.push([position, document.offsetAt({ line: position.line - 1,