Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missed resolveSymbol in commonjs import resolution #41479

Merged
merged 1 commit into from Nov 10, 2020

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Nov 10, 2020

Fixes resolution of export aliases in the postfix-property-access case
of commonjs require:

const { x } = require('./foo').nested
x

This program would previously fail if x was an export alias.

Fixes #41422

Fixes resolution of export aliases in the postfix-property-access case
of commonjs require:

```js
const { x } = require('./foo').nested
x
```

This program would previously fail if `x` was an export alias.

Fixes #41422
@typescript-bot typescript-bot added the For Uncommitted Bug label Nov 10, 2020
@sandersn sandersn requested a review from weswigham Nov 10, 2020
@typescript-bot typescript-bot added For Milestone Bug and removed For Uncommitted Bug labels Nov 10, 2020
Copy link
Member

@weswigham weswigham left a comment

Is this all we were missing? clicks tongue man, if only we could track the alias-resolution state of a symbol in the type system and assert it at certain points; because I've fixed a couple other bugs in the same way this cycle.

@sandersn
Copy link
Member Author

@sandersn sandersn commented Nov 10, 2020

Yep, there are a set of Functions You Should Call on all resolved symbols, and they're not at all enforced.

@sandersn sandersn merged commit 9fb6acf into master Nov 10, 2020
11 checks passed
@sandersn sandersn deleted the fix-commonjs-nested-reexports branch Nov 10, 2020
@andrewbranch
Copy link
Member

@andrewbranch andrewbranch commented Nov 25, 2020

@typescript-bot cherry pick this to release-4.1

Open to hearing reasons why this isn’t a strong candidate to backport to a patch release, but the fix seems simple and innocuous and the bug seems pretty bad if you hit it, though I don’t expect to many people will. But at least one did: #41629

@andrewbranch
Copy link
Member

@andrewbranch andrewbranch commented Nov 25, 2020

@typescript-bot cherry-pick this to release-4.1

Does cherry-pick have to be hyphenated?

@typescript-bot
Copy link
Collaborator

@typescript-bot typescript-bot commented Nov 25, 2020

Heya @andrewbranch, I've started to run the task to cherry-pick this into release-4.1 on this PR at 3da5578. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

@typescript-bot typescript-bot commented Nov 25, 2020

Hey @andrewbranch, I couldn't open a PR with the cherry-pick. (You can check the log here). You may need to squash and pick this PR into release-4.1 manually.

andrewbranch pushed a commit to andrewbranch/TypeScript that referenced this issue Nov 25, 2020
Fixes resolution of export aliases in the postfix-property-access case
of commonjs require:

```js
const { x } = require('./foo').nested
x
```

This program would previously fail if `x` was an export alias.

Fixes microsoft#41422
andrewbranch added a commit that referenced this issue Dec 2, 2020
Fixes resolution of export aliases in the postfix-property-access case
of commonjs require:

```js
const { x } = require('./foo').nested
x
```

This program would previously fail if `x` was an export alias.

Fixes #41422

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants