Merge pull request #8197 from Microsoft/transforms-skip-emit
Skip emit of this parameters
This commit is contained in:
commit
936b006156
3 changed files with 13 additions and 2 deletions
|
@ -2267,6 +2267,11 @@ namespace ts {
|
|||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
// If the parameter's name is 'this', then it is TypeScript syntax.
|
||||
if (node.name && (node.name as Identifier).originalKeywordKind === SyntaxKind.ThisKeyword) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript;
|
||||
}
|
||||
|
||||
// If a parameter has an accessibility modifier, then it is TypeScript syntax.
|
||||
if (hasModifier(node, ModifierFlags.AccessibilityModifier)) {
|
||||
transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.ContainsParameterPropertyAssignments;
|
||||
|
|
|
@ -359,6 +359,7 @@ namespace ts {
|
|||
// - accessibility modifiers
|
||||
// - the question mark (?) token for optional parameters
|
||||
// - type annotations
|
||||
// - this parameters
|
||||
return visitParameter(<ParameterDeclaration>node);
|
||||
|
||||
case SyntaxKind.ParenthesizedExpression:
|
||||
|
@ -2120,10 +2121,14 @@ namespace ts {
|
|||
* This function will be called when one of the following conditions are met:
|
||||
* - The node has an accessibility modifier.
|
||||
* - The node has a questionToken.
|
||||
* - The node's kind is ThisKeyword.
|
||||
*
|
||||
* @param node The parameter declaration node.
|
||||
*/
|
||||
function visitParameter(node: ParameterDeclaration) {
|
||||
if (node.name && (node.name as Identifier).originalKeywordKind === SyntaxKind.ThisKeyword) {
|
||||
return undefined;
|
||||
}
|
||||
const clone = getMutableClone(node);
|
||||
clone.decorators = undefined;
|
||||
clone.modifiers = undefined;
|
||||
|
|
|
@ -341,18 +341,19 @@ var ThisConstructor = (function () {
|
|||
return ThisConstructor;
|
||||
}());
|
||||
var thisConstructorType;
|
||||
function notFirst(a, this) { return this.n; }
|
||||
function notFirst(a) { return this.n; }
|
||||
///// parse errors /////
|
||||
function modifiers(, C) {
|
||||
if ( === void 0) { = this; }
|
||||
return this.n;
|
||||
}
|
||||
function restParam(, C) { return this.n; }
|
||||
function restParam(C) { return this.n; }
|
||||
function optional(C) { return this.n; }
|
||||
function decorated(, C) {
|
||||
if ( === void 0) { = this; }
|
||||
return this.n;
|
||||
}
|
||||
function initializer() { }
|
||||
new C();
|
||||
number;
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue