You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running unit tests on a module that uses native JavaScript bigints, the following error is generated:
SyntaxError: /calculate.ts: Identifier directly after number (8:18)
> 8 | const EXPONENT = 5n;
To Reproduce
Steps to reproduce the behavior:
Run any test that declares a native JavaScript bigint, e.g.:
const someValue = 3n
Expected behavior
Expected tests to handle native JavaScript bigint types. When running and building the application, bigints don't pose a problem.
Link to repo (highly encouraged)
Debug log:
The stacktrace seems to point to babel as the cuprit:
at Parser._raise (node_modules/@babel/parser/src/parser/location.js:233:45)
at Parser.raiseWithData (node_modules/@babel/parser/src/parser/location.js:228:17)
at Parser.raise (node_modules/@babel/parser/src/parser/location.js:212:17)
at Parser.readNumber (node_modules/@babel/parser/src/tokenizer/index.js:1092:18)
at Parser.getTokenFromCode (node_modules/@babel/parser/src/tokenizer/index.js:752:14)
at Parser.nextToken (node_modules/@babel/parser/src/tokenizer/index.js:240:12)
at Parser.next (node_modules/@babel/parser/src/tokenizer/index.js:154:10)
at Parser.eat (node_modules/@babel/parser/src/tokenizer/index.js:161:12)
at Parser.parseVar (node_modules/@babel/parser/src/parser/statement.js:974:16)
at Parser.parseVarStatement (node_modules/@babel/parser/src/parser/statement.js:688:10)
Just to update: the problem seems to be explicitly with collecting coverage, if I exclude the specified file from coverage collection, the error disappears. However, I found an easy workaround in using the following syntax:
const someValue = BigInt(3)
instead of:
const someValue = 3n
Using this workaround works perfectly for me, with caveats for other developers obviously, so I'm happy to close to the issue if you feel that's suitable.
🐛 Bug Report
When running unit tests on a module that uses native JavaScript bigints, the following error is generated:
To Reproduce
Steps to reproduce the behavior:
Run any test that declares a native JavaScript bigint, e.g.:
Expected behavior
Expected tests to handle native JavaScript bigint types. When running and building the application, bigints don't pose a problem.
Link to repo (highly encouraged)
Debug log:
The stacktrace seems to point to babel as the cuprit:
envinfo
The text was updated successfully, but these errors were encountered: