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

useDefineForClassFields skips emit of ambient properties #35058

Merged

Conversation

sandersn
Copy link
Member

Previously:

class C {
  declare p
}

would incorrectly emit

class C {
    constructor() {
        Object.defineProperty(this, "p", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: void 0
        });
    }
}

when useDefineForClassFields was turned on (for targets <ESNext).

Fixes #34972

Previously:

```ts
class C {
  declare p
}
```

would incorrectly emit

```js
class C {
    constructor() {
        Object.defineProperty(this, "p", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: void 0
        });
    }
}
```

when useDefineForClassFields was turned on (for targets <ESNext).
@robpalme
Copy link

when useDefineForClassFields was turned on (for targets <ESNext).

Note the ESNext emit was also broken. Maybe that needs a snapshot test too?

This moves the check earlier in the pipeline.
@sandersn
Copy link
Member Author

@robpalme Thanks, that resulted in a better place to put the new check.

I also ported the new test definePropertyESNext from my other emit PR which fixes the order of defineProperty emit.

@DanielRosenwasser
Copy link
Member

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

@DanielRosenwasser
Copy link
Member

🔔 reviewers can we get some eyes on this so we can get 3.7.3 out sooner?

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request Nov 20, 2019
Component commits:
8ae5a8c useDefineForClassFields skips emit of ambient properties
Previously:

```ts
class C {
  declare p
}
```

would incorrectly emit

```js
class C {
    constructor() {
        Object.defineProperty(this, "p", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: void 0
        });
    }
}
```

when useDefineForClassFields was turned on (for targets <ESNext).

0ec9c04 Fix bug for ESNext as well
This moves the check earlier in the pipeline.

e1aa034 update baselines
@typescript-bot
Copy link
Collaborator

Hey @DanielRosenwasser, I've opened #35241 for you.

@DanielRosenwasser DanielRosenwasser merged commit 2075f74 into master Nov 22, 2019
@DanielRosenwasser DanielRosenwasser deleted the useDefineForClassFields-skip-emit-ambient-properties branch November 22, 2019 22:52
DanielRosenwasser pushed a commit that referenced this pull request Nov 22, 2019
Component commits:
8ae5a8c useDefineForClassFields skips emit of ambient properties
Previously:

```ts
class C {
  declare p
}
```

would incorrectly emit

```js
class C {
    constructor() {
        Object.defineProperty(this, "p", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: void 0
        });
    }
}
```

when useDefineForClassFields was turned on (for targets <ESNext).

0ec9c04 Fix bug for ESNext as well
This moves the check earlier in the pipeline.

e1aa034 update baselines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"useDefineForClassFields" breaks ambient public fields
5 participants