From 82be6d1746011f3a5e7a5fb0a2efa85a2a12226e Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 22 Dec 2016 11:03:20 +0900 Subject: [PATCH 1/7] Format destructuring by brace format option --- src/services/formatting/rules.ts | 12 ++++++++---- tests/cases/fourslash/formattingOptionsChange.ts | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index a6bec97ed53..7cb682e2ffa 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -292,10 +292,10 @@ namespace ts.formatting { this.SpaceBeforeOpenBraceInControl = new Rule(RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSingleLineBlockContext), RuleAction.Space)); - this.SpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSingleLineBlockContext), RuleAction.Space)); - this.NoSpaceAfterOpenBrace = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSingleLineBlockContext), RuleAction.Delete)); - this.NoSpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSingleLineBlockContext), RuleAction.Delete)); + this.SpaceAfterOpenBrace = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsBraceWrappedContext), RuleAction.Space)); + this.SpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsBraceWrappedContext), RuleAction.Space)); + this.NoSpaceAfterOpenBrace = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsBraceWrappedContext), RuleAction.Delete)); + this.NoSpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsBraceWrappedContext), RuleAction.Delete)); this.NoSpaceBetweenEmptyBraceBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), RuleAction.Delete)); // Insert new line after { and before } in multi-line contexts. @@ -615,6 +615,10 @@ namespace ts.formatting { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); } + static IsBraceWrappedContext(context: FormattingContext): boolean { + return context.contextNode.kind === SyntaxKind.ObjectBindingPattern || Rules.IsSingleLineBlockContext(context); + } + // This check is done before an open brace in a control construct, a function, or a typescript block declaration static IsBeforeMultilineBlockContext(context: FormattingContext): boolean { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); diff --git a/tests/cases/fourslash/formattingOptionsChange.ts b/tests/cases/fourslash/formattingOptionsChange.ts index 63d51eec0ca..5726a57da57 100644 --- a/tests/cases/fourslash/formattingOptionsChange.ts +++ b/tests/cases/fourslash/formattingOptionsChange.ts @@ -13,7 +13,7 @@ ////} /////*PlaceOpenBraceOnNewLineForControlBlocks*/if (true) { ////} -/////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces*/{ var t = 1}; +/////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces*/{ var t = 1}; var {a,b } = { a: 'sw', b:'r' }; runTest("InsertSpaceAfterCommaDelimiter", "[1, 2, 3];[72,];", "[1,2,3];[72,];"); runTest("InsertSpaceAfterSemicolonInForStatements", "for (i = 0; i; i++);", "for (i = 0;i;i++);"); @@ -26,7 +26,7 @@ runTest("InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces", "`${ 1 }` runTest("InsertSpaceAfterTypeAssertion", "const bar = Thing.getFoo();", "const bar = Thing.getFoo();"); runTest("PlaceOpenBraceOnNewLineForFunctions", "class foo", "class foo {"); runTest("PlaceOpenBraceOnNewLineForControlBlocks", "if ( true )", "if ( true ) {"); -runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces", "{ var t = 1 };", "{var t = 1};"); +runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces", "{ var t = 1 }; var { a, b } = { a: 'sw', b: 'r' };", "{var t = 1}; var {a, b} = {a: 'sw', b: 'r'};"); function runTest(propertyName: string, expectedStringWhenTrue: string, expectedStringWhenFalse: string) { From 273a0dbdfe4c609151c05b8c3efbc3ab060bdd44 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 22 Dec 2016 12:33:50 +0900 Subject: [PATCH 2/7] add getOption --- src/harness/fourslash.ts | 4 ++++ tests/cases/fourslash/formattingOptionsChange.ts | 8 +++++--- tests/cases/fourslash/fourslash.ts | 7 ++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 653b87236fd..35fa7734a58 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -3530,6 +3530,10 @@ namespace FourSlashInterface { public setOption(name: string, value: any): void { (this.state.formatCodeSettings)[name] = value; } + + public getOption(name: keyof ts.FormatCodeSettings) { + return this.state.formatCodeSettings[name]; + } } export class Cancellation { diff --git a/tests/cases/fourslash/formattingOptionsChange.ts b/tests/cases/fourslash/formattingOptionsChange.ts index 5726a57da57..b8d128acb79 100644 --- a/tests/cases/fourslash/formattingOptionsChange.ts +++ b/tests/cases/fourslash/formattingOptionsChange.ts @@ -13,7 +13,7 @@ ////} /////*PlaceOpenBraceOnNewLineForControlBlocks*/if (true) { ////} -/////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces*/{ var t = 1}; var {a,b } = { a: 'sw', b:'r' }; +/////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces*/{ var t = 1}; var {a,b } = { a: 'sw', b:'r' };function f( { a, b}) { } runTest("InsertSpaceAfterCommaDelimiter", "[1, 2, 3];[72,];", "[1,2,3];[72,];"); runTest("InsertSpaceAfterSemicolonInForStatements", "for (i = 0; i; i++);", "for (i = 0;i;i++);"); @@ -26,9 +26,9 @@ runTest("InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces", "`${ 1 }` runTest("InsertSpaceAfterTypeAssertion", "const bar = Thing.getFoo();", "const bar = Thing.getFoo();"); runTest("PlaceOpenBraceOnNewLineForFunctions", "class foo", "class foo {"); runTest("PlaceOpenBraceOnNewLineForControlBlocks", "if ( true )", "if ( true ) {"); -runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces", "{ var t = 1 }; var { a, b } = { a: 'sw', b: 'r' };", "{var t = 1}; var {a, b} = {a: 'sw', b: 'r'};"); - +runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces", "{ var t = 1 }; var { a, b } = { a: 'sw', b: 'r' }; function f({ a, b }) { }", "{var t = 1}; var {a, b} = {a: 'sw', b: 'r'}; function f({a, b}) {}"); +const defaultFormatOption = format.copyFormatOptions(); function runTest(propertyName: string, expectedStringWhenTrue: string, expectedStringWhenFalse: string) { // Go to the correct file goTo.marker(propertyName); @@ -52,4 +52,6 @@ function runTest(propertyName: string, expectedStringWhenTrue: string, expectedS // Verify goTo.marker(propertyName); verify.currentLineContentIs(expectedStringWhenTrue); + + format.setOption(propertyName, defaultFormatOption[propertyName]) } \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 745a746db11..dcb8ca47200 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -294,9 +294,10 @@ declare namespace FourSlashInterface { setFormatOptions(options: FormatCodeOptions): any; selection(startMarker: string, endMarker: string): void; onType(posMarker: string, key: string): void; - setOption(name: string, value: number): any; - setOption(name: string, value: string): any; - setOption(name: string, value: boolean): any; + setOption(name: string, value: number): void; + setOption(name: string, value: string): void; + setOption(name: string, value: boolean): void; + getOption(name: string): number|string|boolean; } class cancellation { resetCancelled(): void; From ebf46a77e96b39291897f9787bcd92b8ef92b4f2 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Sat, 17 Dec 2016 13:21:34 +0900 Subject: [PATCH 3/7] merge conflict --- src/harness/fourslash.ts | 10 ++-- .../fourslash/formattingOptionsChange.ts | 48 +++++++++---------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 35fa7734a58..0be7ecffc34 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -3524,11 +3524,11 @@ namespace FourSlashInterface { this.state.formatOnType(this.state.getMarkerByName(posMarker).position, key); } - public setOption(name: string, value: number): void; - public setOption(name: string, value: string): void; - public setOption(name: string, value: boolean): void; - public setOption(name: string, value: any): void { - (this.state.formatCodeSettings)[name] = value; + public setOption(name: keyof ts.FormatCodeSettings, value: number): void; + public setOption(name: keyof ts.FormatCodeSettings, value: string): void; + public setOption(name: keyof ts.FormatCodeSettings, value: boolean): void; + public setOption(name: keyof ts.FormatCodeSettings, value: any): void { + this.state.formatCodeSettings[name] = value; } public getOption(name: keyof ts.FormatCodeSettings) { diff --git a/tests/cases/fourslash/formattingOptionsChange.ts b/tests/cases/fourslash/formattingOptionsChange.ts index b8d128acb79..f8f7c270cd8 100644 --- a/tests/cases/fourslash/formattingOptionsChange.ts +++ b/tests/cases/fourslash/formattingOptionsChange.ts @@ -1,32 +1,32 @@ /// -/////*InsertSpaceAfterCommaDelimiter*/[1,2, 3];[ 72 , ]; -/////*InsertSpaceAfterSemicolonInForStatements*/for (i = 0;i; i++); -/////*InsertSpaceBeforeAndAfterBinaryOperators*/1+2- 3 -/////*InsertSpaceAfterKeywordsInControlFlowStatements*/if (true) { } -/////*InsertSpaceAfterFunctionKeywordForAnonymousFunctions*/(function () { }) -/////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis*/(1 ) -/////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets*/[1 ]; [ ]; []; [,]; -/////*InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces*/`${1}`;`${ 1 }` -/////*InsertSpaceAfterTypeAssertion*/const bar = Thing.getFoo(); -/////*PlaceOpenBraceOnNewLineForFunctions*/class foo { +/////*insertSpaceAfterCommaDelimiter*/[1,2, 3];[ 72 , ]; +/////*insertSpaceAfterSemicolonInForStatements*/for (i = 0;i; i++); +/////*insertSpaceBeforeAndAfterBinaryOperators*/1+2- 3 +/////*insertSpaceAfterKeywordsInControlFlowStatements*/if (true) { } +/////*insertSpaceAfterFunctionKeywordForAnonymousFunctions*/(function () { }) +/////*insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis*/(1 ) +/////*insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets*/[1 ]; [ ]; []; [,]; +/////*insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces*/`${1}`;`${ 1 }` +/////*insertSpaceAfterTypeAssertion*/const bar = Thing.getFoo(); +/////*placeOpenBraceOnNewLineForFunctions*/class foo { ////} -/////*PlaceOpenBraceOnNewLineForControlBlocks*/if (true) { +/////*placeOpenBraceOnNewLineForControlBlocks*/if (true) { ////} -/////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces*/{ var t = 1}; var {a,b } = { a: 'sw', b:'r' };function f( { a, b}) { } +/////*insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces*/{ var t = 1}; var {a,b } = { a: 'sw', b:'r' };function f( { a, b}) { } -runTest("InsertSpaceAfterCommaDelimiter", "[1, 2, 3];[72,];", "[1,2,3];[72,];"); -runTest("InsertSpaceAfterSemicolonInForStatements", "for (i = 0; i; i++);", "for (i = 0;i;i++);"); -runTest("InsertSpaceBeforeAndAfterBinaryOperators", "1 + 2 - 3", "1+2-3"); -runTest("InsertSpaceAfterKeywordsInControlFlowStatements", "if (true) { }", "if(true) { }"); -runTest("InsertSpaceAfterFunctionKeywordForAnonymousFunctions", "(function () { })", "(function() { })"); -runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis", " ( 1 )", " (1)"); -runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets", "[ 1 ];[];[];[ , ];", "[1];[];[];[,];"); -runTest("InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces", "`${ 1 }`; `${ 1 }`", "`${1}`; `${1}`"); -runTest("InsertSpaceAfterTypeAssertion", "const bar = Thing.getFoo();", "const bar = Thing.getFoo();"); -runTest("PlaceOpenBraceOnNewLineForFunctions", "class foo", "class foo {"); -runTest("PlaceOpenBraceOnNewLineForControlBlocks", "if ( true )", "if ( true ) {"); -runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces", "{ var t = 1 }; var { a, b } = { a: 'sw', b: 'r' }; function f({ a, b }) { }", "{var t = 1}; var {a, b} = {a: 'sw', b: 'r'}; function f({a, b}) {}"); +runTest("insertSpaceAfterCommaDelimiter", "[1, 2, 3];[72,];", "[1,2,3];[72,];"); +runTest("insertSpaceAfterSemicolonInForStatements", "for (i = 0; i; i++);", "for (i = 0;i;i++);"); +runTest("insertSpaceBeforeAndAfterBinaryOperators", "1 + 2 - 3", "1+2-3"); +runTest("insertSpaceAfterKeywordsInControlFlowStatements", "if (true) { }", "if(true) { }"); +runTest("insertSpaceAfterFunctionKeywordForAnonymousFunctions", "(function () { })", "(function() { })"); +runTest("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis", " ( 1 )", " (1)"); +runTest("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets", "[ 1 ];[];[];[ , ];", "[1];[];[];[,];"); +runTest("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces", "`${ 1 }`; `${ 1 }`", "`${1}`; `${1}`"); +runTest("insertSpaceAfterTypeAssertion", "const bar = Thing.getFoo();", "const bar = Thing.getFoo();"); +runTest("placeOpenBraceOnNewLineForFunctions", "class foo", "class foo {"); +runTest("placeOpenBraceOnNewLineForControlBlocks", "if ( true )", "if ( true ) {"); +runTest("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces", "{ var t = 1 }; var { a, b } = { a: 'sw', b: 'r' }; function f({ a, b }) { }", "{var t = 1}; var {a, b} = {a: 'sw', b: 'r'}; function f({a, b}) {}"); const defaultFormatOption = format.copyFormatOptions(); function runTest(propertyName: string, expectedStringWhenTrue: string, expectedStringWhenFalse: string) { From 6b48f3b551d56c0d88d4e94834f9ad9c0d555fd6 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 22 Dec 2016 12:41:35 +0900 Subject: [PATCH 4/7] cancel getOption --- src/harness/fourslash.ts | 4 ---- tests/cases/fourslash/fourslash.ts | 5 +---- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 0be7ecffc34..c28843327da 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -3530,10 +3530,6 @@ namespace FourSlashInterface { public setOption(name: keyof ts.FormatCodeSettings, value: any): void { this.state.formatCodeSettings[name] = value; } - - public getOption(name: keyof ts.FormatCodeSettings) { - return this.state.formatCodeSettings[name]; - } } export class Cancellation { diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index dcb8ca47200..63b38c337d7 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -294,10 +294,7 @@ declare namespace FourSlashInterface { setFormatOptions(options: FormatCodeOptions): any; selection(startMarker: string, endMarker: string): void; onType(posMarker: string, key: string): void; - setOption(name: string, value: number): void; - setOption(name: string, value: string): void; - setOption(name: string, value: boolean): void; - getOption(name: string): number|string|boolean; + setOption(name: string, value: number | string | boolean): void; } class cancellation { resetCancelled(): void; From 5fb82496fb5a62fd7891d1604397455c77aa5e50 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 22 Dec 2016 12:54:23 +0900 Subject: [PATCH 5/7] reposition defaultFormatOption --- src/server/utilities.ts | 1 + tests/cases/fourslash/formattingOptionsChange.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server/utilities.ts b/src/server/utilities.ts index 641ca128e63..d0790b93dba 100644 --- a/src/server/utilities.ts +++ b/src/server/utilities.ts @@ -86,6 +86,7 @@ namespace ts.server { insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, insertSpaceBeforeFunctionParenthesis: false, diff --git a/tests/cases/fourslash/formattingOptionsChange.ts b/tests/cases/fourslash/formattingOptionsChange.ts index f8f7c270cd8..0e731412ede 100644 --- a/tests/cases/fourslash/formattingOptionsChange.ts +++ b/tests/cases/fourslash/formattingOptionsChange.ts @@ -15,6 +15,8 @@ ////} /////*insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces*/{ var t = 1}; var {a,b } = { a: 'sw', b:'r' };function f( { a, b}) { } +const defaultFormatOption = format.copyFormatOptions(); + runTest("insertSpaceAfterCommaDelimiter", "[1, 2, 3];[72,];", "[1,2,3];[72,];"); runTest("insertSpaceAfterSemicolonInForStatements", "for (i = 0; i; i++);", "for (i = 0;i;i++);"); runTest("insertSpaceBeforeAndAfterBinaryOperators", "1 + 2 - 3", "1+2-3"); @@ -25,10 +27,9 @@ runTest("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets", "[ 1 ];[];[]; runTest("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces", "`${ 1 }`; `${ 1 }`", "`${1}`; `${1}`"); runTest("insertSpaceAfterTypeAssertion", "const bar = Thing.getFoo();", "const bar = Thing.getFoo();"); runTest("placeOpenBraceOnNewLineForFunctions", "class foo", "class foo {"); -runTest("placeOpenBraceOnNewLineForControlBlocks", "if ( true )", "if ( true ) {"); +runTest("placeOpenBraceOnNewLineForControlBlocks", "if (true)", "if (true) {"); runTest("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces", "{ var t = 1 }; var { a, b } = { a: 'sw', b: 'r' }; function f({ a, b }) { }", "{var t = 1}; var {a, b} = {a: 'sw', b: 'r'}; function f({a, b}) {}"); -const defaultFormatOption = format.copyFormatOptions(); function runTest(propertyName: string, expectedStringWhenTrue: string, expectedStringWhenFalse: string) { // Go to the correct file goTo.marker(propertyName); From 76c88b59cf0cedf959dbf7db6dda291a82227253 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 22 Dec 2016 13:04:37 +0900 Subject: [PATCH 6/7] union --- src/harness/fourslash.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c28843327da..4c1a716bc0b 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -3523,11 +3523,8 @@ namespace FourSlashInterface { public onType(posMarker: string, key: string) { this.state.formatOnType(this.state.getMarkerByName(posMarker).position, key); } - - public setOption(name: keyof ts.FormatCodeSettings, value: number): void; - public setOption(name: keyof ts.FormatCodeSettings, value: string): void; - public setOption(name: keyof ts.FormatCodeSettings, value: boolean): void; - public setOption(name: keyof ts.FormatCodeSettings, value: any): void { + + public setOption(name: keyof ts.FormatCodeSettings, value: number | string | boolean): void { this.state.formatCodeSettings[name] = value; } } From a1f88d2fcd52aaef52b5060f35b47c9738f7f2e2 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 22 Dec 2016 15:23:50 +0900 Subject: [PATCH 7/7] format fourslash.ts --- src/harness/fourslash.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 4c1a716bc0b..2a0d37d190b 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -479,7 +479,7 @@ namespace FourSlash { endPos = endMarker.position; } - errors.forEach(function(error: ts.Diagnostic) { + errors.forEach(function (error: ts.Diagnostic) { if (predicate(error.start, error.start + error.length, startPos, endPos)) { exists = true; } @@ -496,7 +496,7 @@ namespace FourSlash { Harness.IO.log("Unexpected error(s) found. Error list is:"); } - errors.forEach(function(error: ts.Diagnostic) { + errors.forEach(function (error: ts.Diagnostic) { Harness.IO.log(" minChar: " + error.start + ", limChar: " + (error.start + error.length) + ", message: " + ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine()) + "\n"); @@ -3523,7 +3523,7 @@ namespace FourSlashInterface { public onType(posMarker: string, key: string) { this.state.formatOnType(this.state.getMarkerByName(posMarker).position, key); } - + public setOption(name: keyof ts.FormatCodeSettings, value: number | string | boolean): void { this.state.formatCodeSettings[name] = value; }