Ok, this is probably the craziest error I've ever seen.
Context
- vue 2.6.10
- typescript 4.4.3
- Built using webpack via
vue-cli-service build.
I was getting following error on build:
⠼ Building for production...
ERROR Failed to compile with 1 errors 10:49:11
error in [internal]
INTERNAL ERROR(undefined,undefined) Debug Failure.
stack trace:
Error: Debug Failure.
at /Users/user/path/to/repo/node_modules/typescript/lib/typescript.js:19487:89
at String.replace (<anonymous>)
at formatStringFromArgs (/Users/user/path/to/repo/node_modules/typescript/lib/typescript.js:19487:21)
at Object.createDetachedDiagnostic (/Users/user/path/to/repo/node_modules/typescript/lib/typescript.js:19503:20)
at parseErrorAtPosition (/Users/user/path/to/repo/node_modules/typescript/lib/typescript.js:30898:42)
at parseErrorAt (/Users/user/path/to/repo/node_modules/typescript/lib/typescript.js:30905:13)
at parseErrorAtCurrentToken (/Users/user/path/to/repo/node_modules/typescript/lib/typescript.js:30892:13)
at parseErrorForInvalidName (/Users/user/path/to/repo/node_modules/typescript/lib/typescript.js:31130:17)
at parseErrorForMissingSemicolonAfter (/Users/user/path/to/repo/node_modules/typescript/lib/typescript.js:31102:21)
at parseExpressionOrLabeledStatement (/Users/user/path/to/repo/node_modules/typescript/lib/typescript.js:34993:21)
ERROR Build failed with errors.
Solution
The error was an HTML text in Vue template.
<template>
...
Please type "{{ listName }}" to confirm.
...
</template>
I had to replace the word type with something else to fix the TypeScript error:
Please write "{{ listName }}" to confirm.
Update
After further experimenting, what's causing the issue is the following pattern in HTML text:
type "
Where anything can be between the double quotes, so type "", type "hello", etc, all cause this error.
Conversely, when I put anything between the type and ", it builds again, eg type a ".