mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Merge branch 'master' of https://github.com/Microsoft/TypeScript
This commit is contained in:
@@ -1491,12 +1491,20 @@ namespace ts {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.Constructor:
|
||||
case SyntaxKind.IndexSignature:
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.SemicolonClassElement:
|
||||
return true;
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
// Method declarations are not necessarily reusable. An object-literal
|
||||
// may have a method calls "constructor(...)" and we must reparse that
|
||||
// into an actual .ConstructorDeclaration.
|
||||
let methodDeclaration = <MethodDeclaration>node;
|
||||
let nameIsConstructor = methodDeclaration.name.kind === SyntaxKind.Identifier &&
|
||||
(<Identifier>methodDeclaration.name).originalKeywordKind === SyntaxKind.ConstructorKeyword;
|
||||
|
||||
return !nameIsConstructor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1792,11 +1792,6 @@ namespace ts {
|
||||
sourceFile.moduleName = moduleName;
|
||||
}
|
||||
|
||||
// Store syntactic diagnostics
|
||||
if (diagnostics && sourceFile.parseDiagnostics) {
|
||||
diagnostics.push(...sourceFile.parseDiagnostics);
|
||||
}
|
||||
|
||||
let newLine = getNewLineCharacter(options);
|
||||
|
||||
// Output
|
||||
|
||||
@@ -713,6 +713,24 @@ module m3 { }\
|
||||
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4);
|
||||
});
|
||||
|
||||
it('Do not move constructors from class to object-literal.', () => {
|
||||
var source = "class C { public constructor() { } public constructor() { } public constructor() { } }"
|
||||
|
||||
var oldText = ScriptSnapshot.fromString(source);
|
||||
var newTextAndChange = withChange(oldText, 0, "class C".length, "var v =");
|
||||
|
||||
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0);
|
||||
});
|
||||
|
||||
it('Do not move methods called "constructor" from object literal to class', () => {
|
||||
var source = "var v = { public constructor() { } public constructor() { } public constructor() { } }"
|
||||
|
||||
var oldText = ScriptSnapshot.fromString(source);
|
||||
var newTextAndChange = withChange(oldText, 0, "var v =".length, "class C");
|
||||
|
||||
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0);
|
||||
});
|
||||
|
||||
it('Moving index signatures from class to interface',() => {
|
||||
var source = "class C { public [a: number]: string; public [a: number]: string; public [a: number]: string }"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user