From 00dc206d294a17765f626b6c34237843cb6ca683 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Thu, 14 Oct 2021 16:09:06 -0700 Subject: [PATCH] throw error if setOptions is called but not implemented --- src/harness/fourslashImpl.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/harness/fourslashImpl.ts b/src/harness/fourslashImpl.ts index 01f8113efe1..eea737837e2 100644 --- a/src/harness/fourslashImpl.ts +++ b/src/harness/fourslashImpl.ts @@ -2290,6 +2290,10 @@ namespace FourSlash { if (this.testType === FourSlashTestType.Server) { (this.languageService as ts.server.SessionClient).setFormattingOptions(this.formatCodeSettings); } + else { + throw Error(`'setFormatOptions' is not implemented for test type ${formatTestType(this.testType)}. +Try setting options via compiler options.`); + } return oldFormatCodeOptions; } @@ -4604,4 +4608,17 @@ namespace FourSlash { }); return emTarget; } + + function formatTestType(testType: FourSlashTestType): string { + switch (testType) { + case FourSlashTestType.Native: + return "Native"; + case FourSlashTestType.Shims: + return "Shims"; + case FourSlashTestType.ShimsWithPreprocess: + return "ShimsWithPreprocess"; + case FourSlashTestType.Server: + return "Server"; + } + } }