typescript optional property with a getter
This is a simplified example:
class PersonParms{
name:string;
lastName:string;
age?:number;
get fullName(){return this.name + " "+this.lastName;}
}
class Person{
constructor(prms:PersonParms){
}
}
new Person({name:'John',lastName:'Doe'}) // ts error: Property 'fullName' is missing in type '{ name: string; lastName: string; }'.
The idea is to pass a literal object as the intizalizer of PersonParms but having that getter you can neither declare the getter optional or add the property to the object literal. Is there another way to achieve it?
typescript optional getter object-literal
add a comment |
This is a simplified example:
class PersonParms{
name:string;
lastName:string;
age?:number;
get fullName(){return this.name + " "+this.lastName;}
}
class Person{
constructor(prms:PersonParms){
}
}
new Person({name:'John',lastName:'Doe'}) // ts error: Property 'fullName' is missing in type '{ name: string; lastName: string; }'.
The idea is to pass a literal object as the intizalizer of PersonParms but having that getter you can neither declare the getter optional or add the property to the object literal. Is there another way to achieve it?
typescript optional getter object-literal
2
Consider defining an interfaceinterface IPersonParms { name:string; lastName:string; age?:number; readonly fullName?: string; }
. Casting object literal to class doesn't seem to be useful - getter won't magically appear there anyway, you'll need to create an instance of aPersonParms
class.
– Aleksey L.
Feb 11 '18 at 6:47
add a comment |
This is a simplified example:
class PersonParms{
name:string;
lastName:string;
age?:number;
get fullName(){return this.name + " "+this.lastName;}
}
class Person{
constructor(prms:PersonParms){
}
}
new Person({name:'John',lastName:'Doe'}) // ts error: Property 'fullName' is missing in type '{ name: string; lastName: string; }'.
The idea is to pass a literal object as the intizalizer of PersonParms but having that getter you can neither declare the getter optional or add the property to the object literal. Is there another way to achieve it?
typescript optional getter object-literal
This is a simplified example:
class PersonParms{
name:string;
lastName:string;
age?:number;
get fullName(){return this.name + " "+this.lastName;}
}
class Person{
constructor(prms:PersonParms){
}
}
new Person({name:'John',lastName:'Doe'}) // ts error: Property 'fullName' is missing in type '{ name: string; lastName: string; }'.
The idea is to pass a literal object as the intizalizer of PersonParms but having that getter you can neither declare the getter optional or add the property to the object literal. Is there another way to achieve it?
typescript optional getter object-literal
typescript optional getter object-literal
asked Feb 10 '18 at 21:48
tru7tru7
1,52811632
1,52811632
2
Consider defining an interfaceinterface IPersonParms { name:string; lastName:string; age?:number; readonly fullName?: string; }
. Casting object literal to class doesn't seem to be useful - getter won't magically appear there anyway, you'll need to create an instance of aPersonParms
class.
– Aleksey L.
Feb 11 '18 at 6:47
add a comment |
2
Consider defining an interfaceinterface IPersonParms { name:string; lastName:string; age?:number; readonly fullName?: string; }
. Casting object literal to class doesn't seem to be useful - getter won't magically appear there anyway, you'll need to create an instance of aPersonParms
class.
– Aleksey L.
Feb 11 '18 at 6:47
2
2
Consider defining an interface
interface IPersonParms { name:string; lastName:string; age?:number; readonly fullName?: string; }
. Casting object literal to class doesn't seem to be useful - getter won't magically appear there anyway, you'll need to create an instance of a PersonParms
class.– Aleksey L.
Feb 11 '18 at 6:47
Consider defining an interface
interface IPersonParms { name:string; lastName:string; age?:number; readonly fullName?: string; }
. Casting object literal to class doesn't seem to be useful - getter won't magically appear there anyway, you'll need to create an instance of a PersonParms
class.– Aleksey L.
Feb 11 '18 at 6:47
add a comment |
6 Answers
6
active
oldest
votes
I found this solution which is ok for me:
class Person {
name?:string;
lastName?:string;
age?: number;
fullName?:string;
constructor(public config: { name: string, lastName: string }) {
Object.defineProperty(this,'fullName',{
get(){return this.name + " " + this.lastName;}
});
}
add a comment |
Very interesting. I think, you should report an issue to TypeScript, because methods can be optional (see below), but property getters not. It is strange.. As a workaround I can suggest two variants. A nice one:
class PersonParms {
name:string;
lastName:string;
age?: number;
getFullName?() {return this.name + " "+this.lastName;}
}
And a second one, that is hacky, because there we make all the properties optional when passing to constructor.
class PersonParms {
name:string;
lastName:string;
age?: number;
get fullName(){return this.name + " "+this.lastName;}
}
class Person{
constructor(prms: Partial<PersonParms>){
}
}
I second that. It is quite misleading to have to assign a value to a property that's (intentionally) read-only in the initialization - and that's effectively where the case described here takes us.
– Wojtek
Jul 19 '18 at 19:21
add a comment |
Is there another way to achieve it?
Here is how I would do it:
class Person {
constructor(public config: { name: string, lastName: string }) {}
age?: number;
get fullName() { return this.config.name + " " + this.config.lastName; }
}
new Person({ name: 'John', lastName: 'Doe' })
Yes but I will use PersonParms as base in several other classes so the optional getter should be in PersonParns to not have to repeat it in all the subclasses.
– tru7
Feb 10 '18 at 23:00
add a comment |
If you creates a new instance of PersonParms then the error will be gone.
class PersonParms{
name:string;
lastName:string;
age?:number;
get fullName(){return this.name + " "+this.lastName;}
}
class Person{
constructor(prms:PersonParms){
}
}
const personParams = new PersonParms();
personParams.name = 'John';
personParams.lastName = 'John';
new Person(personParams) // No error because this is an instance of PersonParams
I am not sure where/how do you use PersonParms.fullname but in your case I would use this:
interface PersonParms{
name:string;
lastName:string;
age?:number;
}
class Person implements PersonParms{
name: string;
lastName: string;
age?:number
constructor(prms: PersonParms) {
this.name = prms.name;
this.lastName = prms.lastName;
this.age = prms.age;
}
get fullName(){return this.name + " "+this.lastName;}
}
const person = new Person({ name: 'John', lastName: 'Doe' });
console.log(person.fullName); // John Doe
add a comment |
class PersonParms {
name: string;
lastName: string;
age?: number;
fullName?: string = this.name + ' ' + this.lastName;
}
class Person {
constructor(prms: PersonParms) {
}
}
new Person({ name: 'John', lastName: 'Doe' });
Hi Akshay, instead of just showing the code you should also explain what you've changed and why it solves the problem.
– JJJ
Nov 24 '18 at 7:14
Here I made only one change. fullName?: string = this.name + ' ' + this.lastName;
– Akshay
Nov 24 '18 at 7:23
It's working then why should I use getter for this?
– Akshay
Nov 24 '18 at 7:37
add a comment |
class PersonParms {
name: string;
lastName: string;
age?: number;
getFullName?(): string | null { return this.name + ' ' + this.lastName; }
}
class Person {
constructor(prms: PersonParms) {
}
}
new Person({ name: 'John', lastName: 'Doe' });
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48725916%2ftypescript-optional-property-with-a-getter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
I found this solution which is ok for me:
class Person {
name?:string;
lastName?:string;
age?: number;
fullName?:string;
constructor(public config: { name: string, lastName: string }) {
Object.defineProperty(this,'fullName',{
get(){return this.name + " " + this.lastName;}
});
}
add a comment |
I found this solution which is ok for me:
class Person {
name?:string;
lastName?:string;
age?: number;
fullName?:string;
constructor(public config: { name: string, lastName: string }) {
Object.defineProperty(this,'fullName',{
get(){return this.name + " " + this.lastName;}
});
}
add a comment |
I found this solution which is ok for me:
class Person {
name?:string;
lastName?:string;
age?: number;
fullName?:string;
constructor(public config: { name: string, lastName: string }) {
Object.defineProperty(this,'fullName',{
get(){return this.name + " " + this.lastName;}
});
}
I found this solution which is ok for me:
class Person {
name?:string;
lastName?:string;
age?: number;
fullName?:string;
constructor(public config: { name: string, lastName: string }) {
Object.defineProperty(this,'fullName',{
get(){return this.name + " " + this.lastName;}
});
}
edited Nov 24 '18 at 8:07
answered Nov 24 '18 at 6:30
BogdanBogdan
151217
151217
add a comment |
add a comment |
Very interesting. I think, you should report an issue to TypeScript, because methods can be optional (see below), but property getters not. It is strange.. As a workaround I can suggest two variants. A nice one:
class PersonParms {
name:string;
lastName:string;
age?: number;
getFullName?() {return this.name + " "+this.lastName;}
}
And a second one, that is hacky, because there we make all the properties optional when passing to constructor.
class PersonParms {
name:string;
lastName:string;
age?: number;
get fullName(){return this.name + " "+this.lastName;}
}
class Person{
constructor(prms: Partial<PersonParms>){
}
}
I second that. It is quite misleading to have to assign a value to a property that's (intentionally) read-only in the initialization - and that's effectively where the case described here takes us.
– Wojtek
Jul 19 '18 at 19:21
add a comment |
Very interesting. I think, you should report an issue to TypeScript, because methods can be optional (see below), but property getters not. It is strange.. As a workaround I can suggest two variants. A nice one:
class PersonParms {
name:string;
lastName:string;
age?: number;
getFullName?() {return this.name + " "+this.lastName;}
}
And a second one, that is hacky, because there we make all the properties optional when passing to constructor.
class PersonParms {
name:string;
lastName:string;
age?: number;
get fullName(){return this.name + " "+this.lastName;}
}
class Person{
constructor(prms: Partial<PersonParms>){
}
}
I second that. It is quite misleading to have to assign a value to a property that's (intentionally) read-only in the initialization - and that's effectively where the case described here takes us.
– Wojtek
Jul 19 '18 at 19:21
add a comment |
Very interesting. I think, you should report an issue to TypeScript, because methods can be optional (see below), but property getters not. It is strange.. As a workaround I can suggest two variants. A nice one:
class PersonParms {
name:string;
lastName:string;
age?: number;
getFullName?() {return this.name + " "+this.lastName;}
}
And a second one, that is hacky, because there we make all the properties optional when passing to constructor.
class PersonParms {
name:string;
lastName:string;
age?: number;
get fullName(){return this.name + " "+this.lastName;}
}
class Person{
constructor(prms: Partial<PersonParms>){
}
}
Very interesting. I think, you should report an issue to TypeScript, because methods can be optional (see below), but property getters not. It is strange.. As a workaround I can suggest two variants. A nice one:
class PersonParms {
name:string;
lastName:string;
age?: number;
getFullName?() {return this.name + " "+this.lastName;}
}
And a second one, that is hacky, because there we make all the properties optional when passing to constructor.
class PersonParms {
name:string;
lastName:string;
age?: number;
get fullName(){return this.name + " "+this.lastName;}
}
class Person{
constructor(prms: Partial<PersonParms>){
}
}
answered Feb 11 '18 at 8:03
PavelPavel
1,5271022
1,5271022
I second that. It is quite misleading to have to assign a value to a property that's (intentionally) read-only in the initialization - and that's effectively where the case described here takes us.
– Wojtek
Jul 19 '18 at 19:21
add a comment |
I second that. It is quite misleading to have to assign a value to a property that's (intentionally) read-only in the initialization - and that's effectively where the case described here takes us.
– Wojtek
Jul 19 '18 at 19:21
I second that. It is quite misleading to have to assign a value to a property that's (intentionally) read-only in the initialization - and that's effectively where the case described here takes us.
– Wojtek
Jul 19 '18 at 19:21
I second that. It is quite misleading to have to assign a value to a property that's (intentionally) read-only in the initialization - and that's effectively where the case described here takes us.
– Wojtek
Jul 19 '18 at 19:21
add a comment |
Is there another way to achieve it?
Here is how I would do it:
class Person {
constructor(public config: { name: string, lastName: string }) {}
age?: number;
get fullName() { return this.config.name + " " + this.config.lastName; }
}
new Person({ name: 'John', lastName: 'Doe' })
Yes but I will use PersonParms as base in several other classes so the optional getter should be in PersonParns to not have to repeat it in all the subclasses.
– tru7
Feb 10 '18 at 23:00
add a comment |
Is there another way to achieve it?
Here is how I would do it:
class Person {
constructor(public config: { name: string, lastName: string }) {}
age?: number;
get fullName() { return this.config.name + " " + this.config.lastName; }
}
new Person({ name: 'John', lastName: 'Doe' })
Yes but I will use PersonParms as base in several other classes so the optional getter should be in PersonParns to not have to repeat it in all the subclasses.
– tru7
Feb 10 '18 at 23:00
add a comment |
Is there another way to achieve it?
Here is how I would do it:
class Person {
constructor(public config: { name: string, lastName: string }) {}
age?: number;
get fullName() { return this.config.name + " " + this.config.lastName; }
}
new Person({ name: 'John', lastName: 'Doe' })
Is there another way to achieve it?
Here is how I would do it:
class Person {
constructor(public config: { name: string, lastName: string }) {}
age?: number;
get fullName() { return this.config.name + " " + this.config.lastName; }
}
new Person({ name: 'John', lastName: 'Doe' })
answered Feb 10 '18 at 21:58
basaratbasarat
138k25255363
138k25255363
Yes but I will use PersonParms as base in several other classes so the optional getter should be in PersonParns to not have to repeat it in all the subclasses.
– tru7
Feb 10 '18 at 23:00
add a comment |
Yes but I will use PersonParms as base in several other classes so the optional getter should be in PersonParns to not have to repeat it in all the subclasses.
– tru7
Feb 10 '18 at 23:00
Yes but I will use PersonParms as base in several other classes so the optional getter should be in PersonParns to not have to repeat it in all the subclasses.
– tru7
Feb 10 '18 at 23:00
Yes but I will use PersonParms as base in several other classes so the optional getter should be in PersonParns to not have to repeat it in all the subclasses.
– tru7
Feb 10 '18 at 23:00
add a comment |
If you creates a new instance of PersonParms then the error will be gone.
class PersonParms{
name:string;
lastName:string;
age?:number;
get fullName(){return this.name + " "+this.lastName;}
}
class Person{
constructor(prms:PersonParms){
}
}
const personParams = new PersonParms();
personParams.name = 'John';
personParams.lastName = 'John';
new Person(personParams) // No error because this is an instance of PersonParams
I am not sure where/how do you use PersonParms.fullname but in your case I would use this:
interface PersonParms{
name:string;
lastName:string;
age?:number;
}
class Person implements PersonParms{
name: string;
lastName: string;
age?:number
constructor(prms: PersonParms) {
this.name = prms.name;
this.lastName = prms.lastName;
this.age = prms.age;
}
get fullName(){return this.name + " "+this.lastName;}
}
const person = new Person({ name: 'John', lastName: 'Doe' });
console.log(person.fullName); // John Doe
add a comment |
If you creates a new instance of PersonParms then the error will be gone.
class PersonParms{
name:string;
lastName:string;
age?:number;
get fullName(){return this.name + " "+this.lastName;}
}
class Person{
constructor(prms:PersonParms){
}
}
const personParams = new PersonParms();
personParams.name = 'John';
personParams.lastName = 'John';
new Person(personParams) // No error because this is an instance of PersonParams
I am not sure where/how do you use PersonParms.fullname but in your case I would use this:
interface PersonParms{
name:string;
lastName:string;
age?:number;
}
class Person implements PersonParms{
name: string;
lastName: string;
age?:number
constructor(prms: PersonParms) {
this.name = prms.name;
this.lastName = prms.lastName;
this.age = prms.age;
}
get fullName(){return this.name + " "+this.lastName;}
}
const person = new Person({ name: 'John', lastName: 'Doe' });
console.log(person.fullName); // John Doe
add a comment |
If you creates a new instance of PersonParms then the error will be gone.
class PersonParms{
name:string;
lastName:string;
age?:number;
get fullName(){return this.name + " "+this.lastName;}
}
class Person{
constructor(prms:PersonParms){
}
}
const personParams = new PersonParms();
personParams.name = 'John';
personParams.lastName = 'John';
new Person(personParams) // No error because this is an instance of PersonParams
I am not sure where/how do you use PersonParms.fullname but in your case I would use this:
interface PersonParms{
name:string;
lastName:string;
age?:number;
}
class Person implements PersonParms{
name: string;
lastName: string;
age?:number
constructor(prms: PersonParms) {
this.name = prms.name;
this.lastName = prms.lastName;
this.age = prms.age;
}
get fullName(){return this.name + " "+this.lastName;}
}
const person = new Person({ name: 'John', lastName: 'Doe' });
console.log(person.fullName); // John Doe
If you creates a new instance of PersonParms then the error will be gone.
class PersonParms{
name:string;
lastName:string;
age?:number;
get fullName(){return this.name + " "+this.lastName;}
}
class Person{
constructor(prms:PersonParms){
}
}
const personParams = new PersonParms();
personParams.name = 'John';
personParams.lastName = 'John';
new Person(personParams) // No error because this is an instance of PersonParams
I am not sure where/how do you use PersonParms.fullname but in your case I would use this:
interface PersonParms{
name:string;
lastName:string;
age?:number;
}
class Person implements PersonParms{
name: string;
lastName: string;
age?:number
constructor(prms: PersonParms) {
this.name = prms.name;
this.lastName = prms.lastName;
this.age = prms.age;
}
get fullName(){return this.name + " "+this.lastName;}
}
const person = new Person({ name: 'John', lastName: 'Doe' });
console.log(person.fullName); // John Doe
answered Jan 19 at 20:52
distantedistante
1,0841434
1,0841434
add a comment |
add a comment |
class PersonParms {
name: string;
lastName: string;
age?: number;
fullName?: string = this.name + ' ' + this.lastName;
}
class Person {
constructor(prms: PersonParms) {
}
}
new Person({ name: 'John', lastName: 'Doe' });
Hi Akshay, instead of just showing the code you should also explain what you've changed and why it solves the problem.
– JJJ
Nov 24 '18 at 7:14
Here I made only one change. fullName?: string = this.name + ' ' + this.lastName;
– Akshay
Nov 24 '18 at 7:23
It's working then why should I use getter for this?
– Akshay
Nov 24 '18 at 7:37
add a comment |
class PersonParms {
name: string;
lastName: string;
age?: number;
fullName?: string = this.name + ' ' + this.lastName;
}
class Person {
constructor(prms: PersonParms) {
}
}
new Person({ name: 'John', lastName: 'Doe' });
Hi Akshay, instead of just showing the code you should also explain what you've changed and why it solves the problem.
– JJJ
Nov 24 '18 at 7:14
Here I made only one change. fullName?: string = this.name + ' ' + this.lastName;
– Akshay
Nov 24 '18 at 7:23
It's working then why should I use getter for this?
– Akshay
Nov 24 '18 at 7:37
add a comment |
class PersonParms {
name: string;
lastName: string;
age?: number;
fullName?: string = this.name + ' ' + this.lastName;
}
class Person {
constructor(prms: PersonParms) {
}
}
new Person({ name: 'John', lastName: 'Doe' });
class PersonParms {
name: string;
lastName: string;
age?: number;
fullName?: string = this.name + ' ' + this.lastName;
}
class Person {
constructor(prms: PersonParms) {
}
}
new Person({ name: 'John', lastName: 'Doe' });
answered Nov 24 '18 at 6:51
AkshayAkshay
362
362
Hi Akshay, instead of just showing the code you should also explain what you've changed and why it solves the problem.
– JJJ
Nov 24 '18 at 7:14
Here I made only one change. fullName?: string = this.name + ' ' + this.lastName;
– Akshay
Nov 24 '18 at 7:23
It's working then why should I use getter for this?
– Akshay
Nov 24 '18 at 7:37
add a comment |
Hi Akshay, instead of just showing the code you should also explain what you've changed and why it solves the problem.
– JJJ
Nov 24 '18 at 7:14
Here I made only one change. fullName?: string = this.name + ' ' + this.lastName;
– Akshay
Nov 24 '18 at 7:23
It's working then why should I use getter for this?
– Akshay
Nov 24 '18 at 7:37
Hi Akshay, instead of just showing the code you should also explain what you've changed and why it solves the problem.
– JJJ
Nov 24 '18 at 7:14
Hi Akshay, instead of just showing the code you should also explain what you've changed and why it solves the problem.
– JJJ
Nov 24 '18 at 7:14
Here I made only one change. fullName?: string = this.name + ' ' + this.lastName;
– Akshay
Nov 24 '18 at 7:23
Here I made only one change. fullName?: string = this.name + ' ' + this.lastName;
– Akshay
Nov 24 '18 at 7:23
It's working then why should I use getter for this?
– Akshay
Nov 24 '18 at 7:37
It's working then why should I use getter for this?
– Akshay
Nov 24 '18 at 7:37
add a comment |
class PersonParms {
name: string;
lastName: string;
age?: number;
getFullName?(): string | null { return this.name + ' ' + this.lastName; }
}
class Person {
constructor(prms: PersonParms) {
}
}
new Person({ name: 'John', lastName: 'Doe' });
add a comment |
class PersonParms {
name: string;
lastName: string;
age?: number;
getFullName?(): string | null { return this.name + ' ' + this.lastName; }
}
class Person {
constructor(prms: PersonParms) {
}
}
new Person({ name: 'John', lastName: 'Doe' });
add a comment |
class PersonParms {
name: string;
lastName: string;
age?: number;
getFullName?(): string | null { return this.name + ' ' + this.lastName; }
}
class Person {
constructor(prms: PersonParms) {
}
}
new Person({ name: 'John', lastName: 'Doe' });
class PersonParms {
name: string;
lastName: string;
age?: number;
getFullName?(): string | null { return this.name + ' ' + this.lastName; }
}
class Person {
constructor(prms: PersonParms) {
}
}
new Person({ name: 'John', lastName: 'Doe' });
answered Nov 24 '18 at 7:39
AkshayAkshay
362
362
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f48725916%2ftypescript-optional-property-with-a-getter%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Consider defining an interface
interface IPersonParms { name:string; lastName:string; age?:number; readonly fullName?: string; }
. Casting object literal to class doesn't seem to be useful - getter won't magically appear there anyway, you'll need to create an instance of aPersonParms
class.– Aleksey L.
Feb 11 '18 at 6:47