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
So I was trying to run knip on a larger project and was runing into errors that was not very clear to me at first.
file:///Z:/My_Large_Repo/node_modules/knip/dist/typescript/getImportsAndExports.js:298
for (const match of sourceFile.text.matchAll(new RegExp(item.identifier.replace(/\$/g, '\\$'), 'g'))) {
^
SyntaxError: Invalid regular expression: /+/g: Nothing to repeat
at new RegExp (<anonymous>)
at setRefs (file:///Z:/My_Large_Repo/node_modules/knip/dist/typescript/getImportsAndExports.js:298:54)
at getImportsAndExports (file:///Z:/My_Large_Repo/node_modules/knip/dist/typescript/getImportsAndExports.js:314:13)
at ProjectPrincipal.analyzeSourceFile (file:///Z:/My_Large_Repo/node_modules/knip/dist/ProjectPrincipal.js:140:47)
at analyzeSourceFile (file:///Z:/My_Large_Repo/node_modules/knip/dist/index.js:187:66)
at main (file:///Z:/My_Large_Repo/node_modules/knip/dist/index.js:268:17)
at async run (file:///Z:/My_Large_Repo/node_modules/knip/dist/cli.js:25:73)
at async file:///Z:/My_Large_Repo/node_modules/knip/dist/cli.js:85:1
After adding some logging into the getImportsAndExports.js I managed to find that it was choking parsing an enum we have to handle potential values of KeyboardEvent.key, including keys like * and +, which is arguably a terrible idea, but is allowed in Typescript, so I guess knip shouldn't fail on it either.
So I was trying to run
knip
on a larger project and was runing into errors that was not very clear to me at first.After adding some logging into the
getImportsAndExports.js
I managed to find that it was choking parsing an enum we have to handle potential values ofKeyboardEvent.key
, including keys like*
and+
, which is arguably a terrible idea, but is allowed in Typescript, so I guess knip shouldn't fail on it either.Here's a repro: https://stackblitz.com/edit/github-4tmeki?file=enum.ts%3AL21
I think it should be pretty easy to amend, I might send a PR too
The text was updated successfully, but these errors were encountered: