Use an enum for Msg (#19773)

This commit is contained in:
Andy 2017-11-06 18:10:02 -08:00 committed by GitHub
parent d79c37cd19
commit 381ca45787
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 19 deletions

View file

@ -200,7 +200,7 @@ namespace ts.server {
return this.loggingEnabled() && this.level >= level;
}
msg(s: string, type: Msg.Types = Msg.Err) {
msg(s: string, type: Msg = Msg.Err) {
if (!this.canWrite) return;
s = `[${nowString()}] ${s}\n`;

View file

@ -19,20 +19,19 @@ namespace ts.server {
info(s: string): void;
startGroup(): void;
endGroup(): void;
msg(s: string, type?: Msg.Types): void;
msg(s: string, type?: Msg): void;
getLogFileName(): string;
}
// TODO: Use a const enum (https://github.com/Microsoft/TypeScript/issues/16804)
export enum Msg {
Err = "Err",
Info = "Info",
Perf = "Perf",
}
export namespace Msg {
// tslint:disable variable-name
export type Err = "Err";
export const Err: Err = "Err";
export type Info = "Info";
export const Info: Info = "Info";
export type Perf = "Perf";
export const Perf: Perf = "Perf";
export type Types = Err | Info | Perf;
// tslint:enable variable-name
/** @deprecated Only here for backwards-compatibility. Prefer just `Msg`. */
export type Types = Msg;
}
function getProjectRootPath(project: Project): Path {

View file

@ -4779,17 +4779,17 @@ declare namespace ts.server {
info(s: string): void;
startGroup(): void;
endGroup(): void;
msg(s: string, type?: Msg.Types): void;
msg(s: string, type?: Msg): void;
getLogFileName(): string;
}
enum Msg {
Err = "Err",
Info = "Info",
Perf = "Perf",
}
namespace Msg {
type Err = "Err";
const Err: Err;
type Info = "Info";
const Info: Info;
type Perf = "Perf";
const Perf: Perf;
type Types = Err | Info | Perf;
/** @deprecated Only here for backwards-compatibility. Prefer just `Msg`. */
type Types = Msg;
}
function createInstallTypingsRequest(project: Project, typeAcquisition: TypeAcquisition, unresolvedImports: SortedReadonlyArray<string>, cachePath?: string): DiscoverTypings;
namespace Errors {