TypeScript.NET
TypeScript.NET copied to clipboard
Shall you remove "default" from ReadOnlyCollectionWrapper export?
Here is the class
https://github.com/electricessence/TypeScript.NET/blob/master/source/System/Collections/ReadOnlyCollectionWrapper.ts
If I have the import
import { ReadOnlyCollectionWrapper } from 'typescript-dotnet/source/System/Collections/ReadOnlyCollectionWrapper';
The VS code complains
Module '"../../../../../../../Users/my-name/Documents/Projects/my-project/node_modules/typescript-dotnet/source/System/Collections/ReadOnlyCollectionWrapper"' has no exported member 'ReadOnlyCollectionWrapper'.ts(2305)
And according to https://basarat.gitbooks.io/typescript/content/docs/tips/defaultIsBad.html the "default" should be avoided because of "Poor Discoverability".
The code still works, I think.
Thoughts?
I struggled with this idea of "Discoverability" for quite some time because it did seem to be true at the time. This IMO is obsolete information as editors like WebStorm do quite well at discovering default. At one point, I included both. After some time I found that level of redundancy perplexing as you could potentially have double references...
In the end, I decided that files that export the same thing as their file name, should simply use default.
I would be surprised if VS Code doesn't recognize default properly. Basarat's comments are valid, but I don't think it's an absolute mandate. For this library, I made this decision at one point and haven't really turned back. I only expose explicit exports if they're supplementary.