- Error
- Reported by the lexer and parser
TS1351
An identifier or keyword cannot immediately follow a numeric literal.
A letter or keyword follows a number with no space, like `3in` or `1px`. Add a space or an operator, or quote the text.
What it means
A numeric literal must end before the next identifier or keyword starts. Text such as 10px or 3in is read as a number immediately followed by a name, which is a syntax error.
Example
export const width = 10px;
ts-r-check -p tsconfig.json --pretty false ts-r outputindex.ts(1,24): error TS1351: An identifier or keyword cannot immediately follow a numeric literal.
Recorded by node scripts/verify-examples.mjs with ts-r built from commit 6deaf01. The example uses the default tsconfig: strict, target: es2022, module: esnext, moduleResolution: bundler.
How to fix
- Make it a string if it's a CSS-style value:
"10px". - Add the missing operator or space if two tokens were meant.