💻
How are you using Babel?
@babel/cli
Input code
REPL link
Configuration file name
No response
Configuration
No response
Current and expected behavior
- Write a
.ts file that contains an export of a negative number (e.g. export const SOME_NUMBER = -1;)
- Use
tsc to generate a type definition file of the .ts file, resulting in export declare const SOME_NUMBER = -1;
- Run Babel against the code
Expected:
Babel parses the typedef file successfully
Actual:
Babel returns an error:
/repl.tsx: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference. (1:38)
Babel can correctly parse a declared export of a positive number or zero, as well as the original export of a negative number in the .ts file.
Environment
Reproduces in REPL
Discoverd on:
- Babel versions:
- @babel/core@7.20.12
- @babel/parser@7.20.7
- Node version:
v16.13.2
- Yarn v3.2.0
- Lerna 3.16.4
- Ubuntu 18.04.5 LTS
Possible solution
No response
Additional context
Originally discovered by attempting to use jscodeshift to modify a .d.ts file containing a negative number, but successfully isolated to Babel.
💻
How are you using Babel?
@babel/cli
Input code
REPL link
Configuration file name
No response
Configuration
No response
Current and expected behavior
.tsfile that contains an export of a negative number (e.g.export const SOME_NUMBER = -1;)tscto generate a type definition file of the.tsfile, resulting inexport declare const SOME_NUMBER = -1;Expected:
Babel parses the typedef file successfully
Actual:
Babel returns an error:
Babel can correctly parse a declared export of a positive number or zero, as well as the original export of a negative number in the
.tsfile.Environment
Reproduces in REPL
Discoverd on:
v16.13.2Possible solution
No response
Additional context
Originally discovered by attempting to use
jscodeshiftto modify a.d.tsfile containing a negative number, but successfully isolated to Babel.