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 produces broken code #7

Closed
fregante opened this issue Dec 11, 2019 · 2 comments
Closed

useDefineForClassFields produces broken code #7

fregante opened this issue Dec 11, 2019 · 2 comments

Comments

@fregante
Copy link
Contributor

fregante commented Dec 11, 2019

I can't reproduce online but here's the repro.

Bug: microsoft/TypeScript#35590
Also related: microsoft/TypeScript#35426

Input

{
	"compilerOptions": {
		"target": "es2017",
		"useDefineForClassFields": true
	}
}
export default class {
	private _form!: HTMLFormElement;
	constructor() {
		console.log(this._form)
	}
}

Output

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class default_1 {
    constructor() {
        Object.defineProperty(this, "_form", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: _form ///////////////// WRONG
        });
        console.log(this._form);
    }
}
exports.default = default_1;

Online that value is correctly set to void 0 instead of an undefined variable.

@fatcerberus
Copy link

I can't reproduce online

The bug was introduced in 3.7.3. The Playground is currently on 3.7.2; you can reproduce if you switch the Playground to Nightly.

@sindresorhus
Copy link
Owner

Ugh. Yeah, let's just disable it for now.

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

No branches or pull requests

3 participants