Skip to content

Commit 381ca45

Browse files
author
Andy
authored
Use an enum for Msg (microsoft#19773)
1 parent d79c37c commit 381ca45

3 files changed

Lines changed: 18 additions & 19 deletions

File tree

src/server/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ namespace ts.server {
200200
return this.loggingEnabled() && this.level >= level;
201201
}
202202

203-
msg(s: string, type: Msg.Types = Msg.Err) {
203+
msg(s: string, type: Msg = Msg.Err) {
204204
if (!this.canWrite) return;
205205

206206
s = `[${nowString()}] ${s}\n`;

src/server/utilities.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,19 @@ namespace ts.server {
1919
info(s: string): void;
2020
startGroup(): void;
2121
endGroup(): void;
22-
msg(s: string, type?: Msg.Types): void;
22+
msg(s: string, type?: Msg): void;
2323
getLogFileName(): string;
2424
}
2525

26+
// TODO: Use a const enum (https://github.com/Microsoft/TypeScript/issues/16804)
27+
export enum Msg {
28+
Err = "Err",
29+
Info = "Info",
30+
Perf = "Perf",
31+
}
2632
export namespace Msg {
27-
// tslint:disable variable-name
28-
export type Err = "Err";
29-
export const Err: Err = "Err";
30-
export type Info = "Info";
31-
export const Info: Info = "Info";
32-
export type Perf = "Perf";
33-
export const Perf: Perf = "Perf";
34-
export type Types = Err | Info | Perf;
35-
// tslint:enable variable-name
33+
/** @deprecated Only here for backwards-compatibility. Prefer just `Msg`. */
34+
export type Types = Msg;
3635
}
3736

3837
function getProjectRootPath(project: Project): Path {

tests/baselines/reference/api/tsserverlibrary.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4779,17 +4779,17 @@ declare namespace ts.server {
47794779
info(s: string): void;
47804780
startGroup(): void;
47814781
endGroup(): void;
4782-
msg(s: string, type?: Msg.Types): void;
4782+
msg(s: string, type?: Msg): void;
47834783
getLogFileName(): string;
47844784
}
4785+
enum Msg {
4786+
Err = "Err",
4787+
Info = "Info",
4788+
Perf = "Perf",
4789+
}
47854790
namespace Msg {
4786-
type Err = "Err";
4787-
const Err: Err;
4788-
type Info = "Info";
4789-
const Info: Info;
4790-
type Perf = "Perf";
4791-
const Perf: Perf;
4792-
type Types = Err | Info | Perf;
4791+
/** @deprecated Only here for backwards-compatibility. Prefer just `Msg`. */
4792+
type Types = Msg;
47934793
}
47944794
function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>, cachePath?: string): DiscoverTypings;
47954795
namespace Errors {

0 commit comments

Comments
 (0)