False positives on "barrel export" index files
See original GitHub issueSteps to Reproduce:
- Create directory structure
src/stuff - Create file
src/stuff/StringTypeAlias.tswith contentsexport type DogOrCat = 'dog' | 'cat'; - Create file
src/stuff/index.tswith contentsexport * from './StringTypeAlias'; - Create file
src/main.tswith contentsimport DogOrCat from 'stuff';
Expected Result:
No output for DogOrCat.
Actual Result:
Output of DogOrCat @ ./src/stuff/StringTypeAlias.
I’m not sure if this is specific to tsconfig with absolute import paths or not, but I’m using baseUrl in my tsconfig.json so it may very well be.
TSConfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "src/",
"jsx": "react",
"lib": ["es2017", "dom"],
"moduleResolution": "node",
"noErrorTruncation": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"allowUnreachableCode": false,
"resolveJsonModule": true,
"esModuleInterop": true,
"sourceMap": true,
"strict": true,
"target": "es6",
"module": "esNext",
"typeRoots": ["./typings", "./node_modules/@types"],
"paths": {
"test/*": ["../test/*"],
"stories/*": ["../stories/*"],
"i18n/*": ["../i18n/*"]
}
},
"include": [
"src/**/*",
"test/**/*",
"stories/**/*",
"i18n/**/*",
"typings/**/*"
]
}
Thank you!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Using barrel exports to organize React components
A barrel enables us to consolidate, or roll up, exports from multiple files or modules into one single module. Barrels streamline imports ...
Read more >Barrel files: to use or not to use? - Blog by Adrian Fâciu
Barrel files are a way to re-export all or some of these from one, single, convenient place. You can understand better what they...
Read more >How to fix/disable seemingly erroneous "No named exports ...
I believe the report is a false positive because when I run the code, everything works fine and I can indeed import the...
Read more >Everything you can do to reduce bundle size for webapps
One way to resolve this is to name all barrel files something easily identifiable, such as index.js or index.ts . Then a Webpack...
Read more >create-barrel-folder - npm Package Health Analysis - Snyk
create-barrel-folder. v1.0.3. Create a folder with a barrel index file and options to generate the following: - React Functional Component - ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I also tried
src/stuff/index.tswith contentsexport { DogOrCat } from './StringTypeAlias';, but still encountered the false positive output.Fixed by #41. Thanks @abirmingham and @ivosh.