Skip to content

Declare property quick fix should add private properties (or be configurable)  #36249

Closed
@mjbvz

Description

TypeScript Version: 3.8.0-beta

Search Terms:

  • quick fix
  • declare property

Code
For the code:

class Foo { 
	constructor() { 
		this._bar = 1;
	}
}

new Foo().other = 'a';

Trigger the quick fix to declare a missing property on _bar.

Expected behavior:
The quick fix adds a private property _bar:

class Foo { 
	private _bar: number;     
	constructor() { 
		this._bar = 1;
	}
}

Actual behavior:
The quick fix adds a standard public property:

class Foo {
	_bar: number; 
	constructor() { 
		this._bar = 1;
	}
}

Playground Link:

Related Issues:

/cc @JacksonKearl

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Domain: Quick FixesEditor-provided fixes, often called code actions.In DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions