question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

False positives on "barrel export" index files

See original GitHub issue

Steps to Reproduce:

  1. Create directory structure src/stuff
  2. Create file src/stuff/StringTypeAlias.ts with contents export type DogOrCat = 'dog' | 'cat';
  3. Create file src/stuff/index.ts with contents export * from './StringTypeAlias';
  4. Create file src/main.ts with contents import 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:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
abirminghamcommented, Sep 17, 2019

I also tried src/stuff/index.ts with contents export { DogOrCat } from './StringTypeAlias';, but still encountered the false positive output.

0reactions
nadeeshacommented, Oct 19, 2019

Fixed by #41. Thanks @abirmingham and @ivosh.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found