Closed mjbvz closed 6 years ago
Confirmed this happens with TypeScript 2.5.3 and 2.6.0-20171011
isExportDefaultSymbol
is returning false because the declaration has no default
modifier.
Related case: export { Test as default };
@andy-ms, I'm told you've been working in this area and might have some thoughts on what these default export helpers should do (i.e. how to divide the fix between the compiler and the services).
Here's a hackish solution to the cases we've identified so far. https://github.com/amcasey/TypeScript/tree/Scratch19115
I see four other callers to getLocalSymbolForExportDefault
and they basically all just want the local name of the default export. Possibly a helper returning that value is in order.
@amcasey That branch looks like it will work.
@andy-ms so don't update the other callers?
services/utilities.ts
and findAllReferences.ts
: Update is probably a good thingcompletions.ts
: Here we actually need a Symbol
and not just a name. I had a pull request #20987 relating to this, let me know if you find any more failure cases.checker.ts
: I don't think this one is necessary to change, because we're in resolveNameHelper
so we should have already found the local foo
if there's export default foo;
.The change in findAllReferences.ts
broke some tests. I'm still investigating. The failures looked like regressions, which makes me think that we might want to go the other way and pull out the default-export handling that's already there (because it's not clear why that one form would be special).
As far as I can tell, the occurrence in services/utilities.ts
doesn't matter - it's only used by rename and you can't rename default
.
For findAllReferences, I tested all three implementations (current, special case all default exports, special case no default exports) against all three types of default exports and the current implementation had the best behavior. Presumably, this means that the other two types of default exports (i.e. not handled by getLocalSymbolForExportDefault
) are handled downstream.
Thanks a lot @amcasey, excellent work!
From @methyl on October 10, 2017 7:25
Steps to Reproduce:
jsconfig.json
having checkJs: true in compilerOptionstest.js
with following content:test2.js
with following content:Actual behavior:
import Test from './test
appear.Correct behavior
import Test from './test
appear, just like whentest.js
haveexport default
inlined:Copied from original issue: Microsoft/vscode#35966