Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Allow JS multiple declarations of ctor properties#10123

Merged
sandersn merged 9 commits into
mastermicrosoft/TypeScript:masterfrom
allow-js-multiple-declaration-of-constructor-propertiesmicrosoft/TypeScript:allow-js-multiple-declaration-of-constructor-propertiesCopy head branch name to clipboard
Aug 17, 2016
Merged

Allow JS multiple declarations of ctor properties#10123
sandersn merged 9 commits into
mastermicrosoft/TypeScript:masterfrom
allow-js-multiple-declaration-of-constructor-propertiesmicrosoft/TypeScript:allow-js-multiple-declaration-of-constructor-propertiesCopy head branch name to clipboard

Conversation

@sandersn

@sandersn sandersn commented Aug 3, 2016

Copy link
Copy Markdown
Member

Fixes #9880

When a property is declared in the constructor and on the prototype of an ES6 class, the property's symbol is discarded in favour of the method's symbol. That because the usual use for this pattern is to bind an instance function: this.m = this.m.bind(this). In this case the type you want really is the method's type.

When a property is declared in the constructor and on the prototype of
an ES6 class, the property's symbol is discarded in favour of the
method's symbol. That because the usual use for this pattern is to bind
an instance function: `this.m = this.m.bind(this)`. In this case the
type you want really is the method's type.
@sandersn

sandersn commented Aug 3, 2016

Copy link
Copy Markdown
Member Author

@RyanCavanaugh @weswigham mind taking a look?

this.nothing();
};
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Need a test that does this in the opposite order (with the constructor below the method declarations)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

Comment thread src/compiler/types.ts Outdated
/* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol
/* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums
/* @internal */ isReferenced?: boolean; // True if the symbol is referenced elsewhere
/* @internal */ isDiscardable?: boolean; // True if a Javascript class property can be overwritten by a method

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: could you name the property ? (e.g isMethodOverwritable etc.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

done. I ended up with isReplaceableByMethod but tell if you want me to change it.

@sandersn

sandersn commented Aug 8, 2016

Copy link
Copy Markdown
Member Author

@weswigham I just got a test timeout failure on one of the linux workers with workerCount=4. 😿

@weswigham

weswigham commented Aug 8, 2016 via email

Copy link
Copy Markdown
Member

@yuit

yuit commented Aug 8, 2016

Copy link
Copy Markdown
Contributor

I like the new name 😸

@mhegazy

mhegazy commented Aug 16, 2016

Copy link
Copy Markdown
Contributor

👍

Also simply it considerably after noticing that it's *only* called for
Javascript files, so there was a lot of dead code for TS cases that
never happened.
@sandersn sandersn merged commit 9769718 into master Aug 17, 2016
@sandersn sandersn deleted the allow-js-multiple-declaration-of-constructor-properties branch August 17, 2016 17:58
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.