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

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 PR for untriaged, rejected, closed or missing bug label Nov 10, 2020
@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 10, 2020
Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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
@sandersn sandersn deleted the fix-commonjs-nested-reexports branch November 10, 2020 19:28
@andrewbranch
Copy link
Member

@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

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

Does cherry-pick have to be hyphenated?

@typescript-bot
Copy link
Collaborator

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

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 pull request 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 pull request 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 PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

commonjs nested re-exports are broken
4 participants