throw error if setOptions is called but not implemented

This commit is contained in:
Gabriela Araujo Britto
2021-10-14 16:09:06 -07:00
parent 952aac1cdc
commit 00dc206d29

View File

@@ -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";
}
}
}