Commit graph

3 commits

Author SHA1 Message Date
Andrew Branch 736363b427
Use other files when necessary to determine import style in JS (#40879)
* Use other files when necessary to determine import style in JS

* Fix existing tests
2020-10-05 11:39:20 -07:00
Andrew Branch f9945f5acf
Full support for CommonJS auto-imports in JS (#37027)
* Support add new requires

* Always use destructuring for requiring default exports

* Add more tests

* Update existing fourslash tests

* Use `getExportsAndPropertiesOfModule`

* Add UMD test

* Apply suggestions from code review

Fix typos

Co-Authored-By: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-02-28 14:34:20 -08:00
Nathan Shively-Sanders a682a525b8
module.exports aliases have correct flags (#28303)
* module.exports aliases have correct flags

They are marked both as (1) alias and (2) assignment declaration. This
fixes alias resolution in cases where multiple module.exports
assignments exist, but differ in whether they are aliases or not:

```js
function f() { }
module.exports = f
module.exports = 23
```

Previously, this construct would fail to resolve the alias `f` because
the `export=` symbol would be marked as Alias | Value but not
Assignment. This change just adds Assignment so that the assignment
declaration alias-following rules apply: you should always follow the
alias, regardless of other flags.

Also, isAliasSymbolDeclaration needed to be tightened up. Previously, I
missed the condition that `module.exports =` aliases required an
EntityNameDeclaration on right-hand-side, just like `export default` and
`export =` aliases.

* Address PR comments

1. Rename test to be more accurate.
2. Always mark module.exports assignments with SymbolFlags.Assignment.
2018-11-02 09:08:04 -07:00