๐ Unexpected unused export when namespace used in array
mlahargou opened this issue ยท 2 comments
mlahargou commented
Prerequisites
- I'm using the latest version
- I've read the relevant documentation
- I've searched for existing issues
- I've checked the list of known issues
- I've read the issue reproduction guide
Reproduction url
https://stackblitz.com/edit/stackblitz-starters-evsylk?file=index.js
Reproduction access
- I've made sure the reproduction is publicly accessible
Description of the issue
I have a use case where I import a namespace. I then add that namespace to an array and pass it to a function. Knip is marking the namespace exports as unused. I've ensured that nsExports
is not included.
Repro:
// namespace.js
export const foo = 'foo';
export const bar = 'bar';
// index.js
import * as NS from './namespace.js';
// This does throw errors
console.log([NS]);
// This doesn't throw errors
// console.log(NS);
Output:
> npm exec knip
Unused exports (2)
foo NS unknown namespace.js:1:14
bar NS unknown namespace.js:2:14
webpro commented
Thanks for the report @mlahargou, fix will be in the next one!
webpro commented
๐ This issue has been resolved in v5.37.2. See Release 5.37.2 for release notes.
Using Knip in a commercial project? Please consider becoming a sponsor.