Skip to content

Commit

Permalink
Revert string enum changes (#16569)
Browse files Browse the repository at this point in the history
* Revert "Convert Extension to a string enum (#16425)"

This reverts commit 09321b3.

* Revert "Also convert ClassificationTypeNames and CommandTypes/CommandNames"

This reverts commit f94818d.

* Revert "Make ScriptElementKind and HighlightSpanKind string enums"

This reverts commit b162097.

* Revert "Make ScriptElementKind and HighlightSpanKind string enums"

This reverts commit b162097.

# Conflicts:
#	lib/lib.d.ts
#	lib/lib.es2016.full.d.ts
#	lib/lib.es2017.full.d.ts
#	lib/lib.es5.d.ts
#	lib/lib.es6.d.ts
#	lib/lib.esnext.full.d.ts
#	lib/tsc.js
#	lib/tsserver.js
#	lib/tsserverlibrary.d.ts
#	lib/tsserverlibrary.js
#	lib/typescript.d.ts
#	lib/typescript.js
#	lib/typescriptServices.d.ts
#	lib/typescriptServices.js
#	lib/typingsInstaller.js

* Update LKG

* Revert "Make CommandTypes a const enum and use `allCommandTypes` for unit test"

This reverts commit f6240cb.
  • Loading branch information
mhegazy committed Jun 15, 2017
1 parent 096f8cc commit 0968ed9
Show file tree
Hide file tree
Showing 37 changed files with 2,441 additions and 2,291 deletions.
188 changes: 97 additions & 91 deletions lib/protocol.d.ts
Expand Up @@ -2,53 +2,54 @@
* Declaration module describing the TypeScript Server protocol
*/
declare namespace ts.server.protocol {
const enum CommandTypes {
Brace = "brace",
BraceCompletion = "braceCompletion",
Change = "change",
Close = "close",
Completions = "completions",
CompletionDetails = "completionEntryDetails",
CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList",
CompileOnSaveEmitFile = "compileOnSaveEmitFile",
Configure = "configure",
Definition = "definition",
Implementation = "implementation",
Exit = "exit",
Format = "format",
Formatonkey = "formatonkey",
Geterr = "geterr",
GeterrForProject = "geterrForProject",
SemanticDiagnosticsSync = "semanticDiagnosticsSync",
SyntacticDiagnosticsSync = "syntacticDiagnosticsSync",
NavBar = "navbar",
Navto = "navto",
NavTree = "navtree",
NavTreeFull = "navtree-full",
Occurrences = "occurrences",
DocumentHighlights = "documentHighlights",
Open = "open",
Quickinfo = "quickinfo",
References = "references",
Reload = "reload",
Rename = "rename",
Saveto = "saveto",
SignatureHelp = "signatureHelp",
TypeDefinition = "typeDefinition",
ProjectInfo = "projectInfo",
ReloadProjects = "reloadProjects",
Unknown = "unknown",
OpenExternalProject = "openExternalProject",
OpenExternalProjects = "openExternalProjects",
CloseExternalProject = "closeExternalProject",
TodoComments = "todoComments",
Indentation = "indentation",
DocCommentTemplate = "docCommentTemplate",
CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects",
GetCodeFixes = "getCodeFixes",
GetSupportedCodeFixes = "getSupportedCodeFixes",
GetApplicableRefactors = "getApplicableRefactors",
GetEditsForRefactor = "getEditsForRefactor",
namespace CommandTypes {
type Brace = "brace";
type BraceCompletion = "braceCompletion";
type Change = "change";
type Close = "close";
type Completions = "completions";
type CompletionDetails = "completionEntryDetails";
type CompileOnSaveAffectedFileList = "compileOnSaveAffectedFileList";
type CompileOnSaveEmitFile = "compileOnSaveEmitFile";
type Configure = "configure";
type Definition = "definition";
type Implementation = "implementation";
type Exit = "exit";
type Format = "format";
type Formatonkey = "formatonkey";
type Geterr = "geterr";
type GeterrForProject = "geterrForProject";
type SemanticDiagnosticsSync = "semanticDiagnosticsSync";
type SyntacticDiagnosticsSync = "syntacticDiagnosticsSync";
type NavBar = "navbar";
type Navto = "navto";
type NavTree = "navtree";
type NavTreeFull = "navtree-full";
type Occurrences = "occurrences";
type DocumentHighlights = "documentHighlights";
type Open = "open";
type Quickinfo = "quickinfo";
type References = "references";
type Reload = "reload";
type Rename = "rename";
type Saveto = "saveto";
type SignatureHelp = "signatureHelp";
type TypeDefinition = "typeDefinition";
type ProjectInfo = "projectInfo";
type ReloadProjects = "reloadProjects";
type Unknown = "unknown";
type OpenExternalProject = "openExternalProject";
type OpenExternalProjects = "openExternalProjects";
type CloseExternalProject = "closeExternalProject";
type TodoComments = "todoComments";
type Indentation = "indentation";
type DocCommentTemplate = "docCommentTemplate";
type CompilerOptionsForInferredProjects = "compilerOptionsForInferredProjects";
type GetCodeFixes = "getCodeFixes";
type GetSupportedCodeFixes = "getSupportedCodeFixes";
type GetApplicableRefactors = "getApplicableRefactors";
type GetRefactorCodeActions = "getRefactorCodeActions";
type GetEditsForRefactor = "getEditsForRefactor";
}
/**
* A TypeScript Server message
Expand Down Expand Up @@ -571,9 +572,10 @@ declare namespace ts.server.protocol {
}
/**
* Span augmented with extra information that denotes the kind of the highlighting to be used for span.
* Kind is taken from HighlightSpanKind type.
*/
interface HighlightSpan extends TextSpan {
kind: HighlightSpanKind;
kind: string;
}
/**
* Represents a set of highligh spans for a give name
Expand Down Expand Up @@ -691,7 +693,7 @@ declare namespace ts.server.protocol {
/**
* The items's kind (such as 'className' or 'parameterName' or plain 'text').
*/
kind: ScriptElementKind;
kind: string;
/**
* Optional modifiers for the kind (such as 'public').
*/
Expand Down Expand Up @@ -1039,7 +1041,7 @@ declare namespace ts.server.protocol {
/**
* The symbol's kind (such as 'className' or 'parameterName' or plain 'text').
*/
kind: ScriptElementKind;
kind: string;
/**
* Optional modifiers for the kind (such as 'public').
*/
Expand Down Expand Up @@ -1225,7 +1227,7 @@ declare namespace ts.server.protocol {
/**
* The symbol's kind (such as 'className' or 'parameterName').
*/
kind: ScriptElementKind;
kind: string;
/**
* Optional modifiers for the kind (such as 'public').
*/
Expand All @@ -1252,7 +1254,7 @@ declare namespace ts.server.protocol {
/**
* The symbol's kind (such as 'className' or 'parameterName').
*/
kind: ScriptElementKind;
kind: string;
/**
* Optional modifiers for the kind (such as 'public').
*/
Expand Down Expand Up @@ -1645,7 +1647,7 @@ declare namespace ts.server.protocol {
/**
* The symbol's kind (such as 'className' or 'parameterName').
*/
kind: ScriptElementKind;
kind: string;
/**
* exact, substring, or prefix.
*/
Expand Down Expand Up @@ -1678,7 +1680,7 @@ declare namespace ts.server.protocol {
/**
* Kind of symbol's container symbol (if any).
*/
containerKind?: ScriptElementKind;
containerKind?: string;
}
/**
* Navto response message. Body is an array of navto items. Each
Expand Down Expand Up @@ -1742,7 +1744,7 @@ declare namespace ts.server.protocol {
/**
* The symbol's kind (such as 'className' or 'parameterName').
*/
kind: ScriptElementKind;
kind: string;
/**
* Optional modifiers for the kind (such as 'public').
*/
Expand All @@ -1763,7 +1765,7 @@ declare namespace ts.server.protocol {
/** protocol.NavigationTree is identical to ts.NavigationTree, except using protocol.TextSpan instead of ts.TextSpan */
interface NavigationTree {
text: string;
kind: ScriptElementKind;
kind: string;
kindModifiers: string;
spans: TextSpan[];
childItems?: NavigationTree[];
Expand Down Expand Up @@ -1838,11 +1840,12 @@ declare namespace ts.server.protocol {
interface NavTreeResponse extends Response {
body?: NavigationTree;
}
const enum IndentStyle {
None = "None",
Block = "Block",
Smart = "Smart",
namespace IndentStyle {
type None = "None";
type Block = "Block";
type Smart = "Smart";
}
type IndentStyle = IndentStyle.None | IndentStyle.Block | IndentStyle.Smart;
interface EditorSettings {
baseIndentSize?: number;
indentSize?: number;
Expand Down Expand Up @@ -1936,35 +1939,40 @@ declare namespace ts.server.protocol {
typeRoots?: string[];
[option: string]: CompilerOptionsValue | undefined;
}
const enum JsxEmit {
None = "None",
Preserve = "Preserve",
ReactNative = "ReactNative",
React = "React",
}
const enum ModuleKind {
None = "None",
CommonJS = "CommonJS",
AMD = "AMD",
UMD = "UMD",
System = "System",
ES6 = "ES6",
ES2015 = "ES2015",
}
const enum ModuleResolutionKind {
Classic = "Classic",
Node = "Node",
}
const enum NewLineKind {
Crlf = "Crlf",
Lf = "Lf",
}
const enum ScriptTarget {
ES3 = "ES3",
ES5 = "ES5",
ES6 = "ES6",
ES2015 = "ES2015",
}
namespace JsxEmit {
type None = "None";
type Preserve = "Preserve";
type ReactNative = "ReactNative";
type React = "React";
}
type JsxEmit = JsxEmit.None | JsxEmit.Preserve | JsxEmit.React | JsxEmit.ReactNative;
namespace ModuleKind {
type None = "None";
type CommonJS = "CommonJS";
type AMD = "AMD";
type UMD = "UMD";
type System = "System";
type ES6 = "ES6";
type ES2015 = "ES2015";
}
type ModuleKind = ModuleKind.None | ModuleKind.CommonJS | ModuleKind.AMD | ModuleKind.UMD | ModuleKind.System | ModuleKind.ES6 | ModuleKind.ES2015;
namespace ModuleResolutionKind {
type Classic = "Classic";
type Node = "Node";
}
type ModuleResolutionKind = ModuleResolutionKind.Classic | ModuleResolutionKind.Node;
namespace NewLineKind {
type Crlf = "Crlf";
type Lf = "Lf";
}
type NewLineKind = NewLineKind.Crlf | NewLineKind.Lf;
namespace ScriptTarget {
type ES3 = "ES3";
type ES5 = "ES5";
type ES6 = "ES6";
type ES2015 = "ES2015";
}
type ScriptTarget = ScriptTarget.ES3 | ScriptTarget.ES5 | ScriptTarget.ES6 | ScriptTarget.ES2015;
}
declare namespace ts.server.protocol {

Expand Down Expand Up @@ -2020,8 +2028,6 @@ declare namespace ts.server.protocol {
}
declare namespace ts {
// these types are empty stubs for types from services and should not be used directly
export type HighlightSpanKind = never;
export type ScriptElementKind = never;
export type ScriptKind = never;
export type IndentStyle = never;
export type JsxEmit = never;
Expand Down
53 changes: 38 additions & 15 deletions lib/tsc.js
Expand Up @@ -80,6 +80,15 @@ var ts;
ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
ModuleKind[ModuleKind["ESNext"] = 6] = "ESNext";
})(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {}));
var Extension;
(function (Extension) {
Extension[Extension["Ts"] = 0] = "Ts";
Extension[Extension["Tsx"] = 1] = "Tsx";
Extension[Extension["Dts"] = 2] = "Dts";
Extension[Extension["Js"] = 3] = "Js";
Extension[Extension["Jsx"] = 4] = "Jsx";
Extension[Extension["LastTypeScriptExtension"] = 2] = "LastTypeScriptExtension";
})(Extension = ts.Extension || (ts.Extension = {}));
})(ts || (ts = {}));
var ts;
(function (ts) {
Expand Down Expand Up @@ -2123,7 +2132,7 @@ var ts;
}
ts.positionIsSynthesized = positionIsSynthesized;
function extensionIsTypeScript(ext) {
return ext === ".ts" || ext === ".tsx" || ext === ".d.ts";
return ext <= ts.Extension.LastTypeScriptExtension;
}
ts.extensionIsTypeScript = extensionIsTypeScript;
function extensionFromPath(path) {
Expand All @@ -2135,7 +2144,21 @@ var ts;
}
ts.extensionFromPath = extensionFromPath;
function tryGetExtensionFromPath(path) {
return find(ts.supportedTypescriptExtensionsForExtractExtension, function (e) { return fileExtensionIs(path, e); }) || find(ts.supportedJavascriptExtensions, function (e) { return fileExtensionIs(path, e); });
if (fileExtensionIs(path, ".d.ts")) {
return ts.Extension.Dts;
}
if (fileExtensionIs(path, ".ts")) {
return ts.Extension.Ts;
}
if (fileExtensionIs(path, ".tsx")) {
return ts.Extension.Tsx;
}
if (fileExtensionIs(path, ".js")) {
return ts.Extension.Js;
}
if (fileExtensionIs(path, ".jsx")) {
return ts.Extension.Jsx;
}
}
ts.tryGetExtensionFromPath = tryGetExtensionFromPath;
function isCheckJsEnabledForFile(sourceFile, compilerOptions) {
Expand Down Expand Up @@ -21555,14 +21578,14 @@ var ts;
}
switch (extensions) {
case Extensions.DtsOnly:
return tryExtension(".d.ts");
return tryExtension(".d.ts", ts.Extension.Dts);
case Extensions.TypeScript:
return tryExtension(".ts") || tryExtension(".tsx") || tryExtension(".d.ts");
return tryExtension(".ts", ts.Extension.Ts) || tryExtension(".tsx", ts.Extension.Tsx) || tryExtension(".d.ts", ts.Extension.Dts);
case Extensions.JavaScript:
return tryExtension(".js") || tryExtension(".jsx");
return tryExtension(".js", ts.Extension.Js) || tryExtension(".jsx", ts.Extension.Jsx);
}
function tryExtension(extension) {
var path = tryFile(candidate + extension, failedLookupLocations, onlyRecordFailures, state);
function tryExtension(ext, extension) {
var path = tryFile(candidate + ext, failedLookupLocations, onlyRecordFailures, state);
return path && { path: path, extension: extension };
}
}
Expand Down Expand Up @@ -21632,11 +21655,11 @@ var ts;
function extensionIsOk(extensions, extension) {
switch (extensions) {
case Extensions.JavaScript:
return extension === ".js" || extension === ".jsx";
return extension === ts.Extension.Js || extension === ts.Extension.Jsx;
case Extensions.TypeScript:
return extension === ".ts" || extension === ".tsx" || extension === ".d.ts";
return extension === ts.Extension.Ts || extension === ts.Extension.Tsx || extension === ts.Extension.Dts;
case Extensions.DtsOnly:
return extension === ".d.ts";
return extension === ts.Extension.Dts;
}
}
function pathToPackageJson(directory) {
Expand Down Expand Up @@ -56483,14 +56506,14 @@ var ts;
function getResolutionDiagnostic(options, _a) {
var extension = _a.extension;
switch (extension) {
case ".ts":
case ".d.ts":
case ts.Extension.Ts:
case ts.Extension.Dts:
return undefined;
case ".tsx":
case ts.Extension.Tsx:
return needJsx();
case ".jsx":
case ts.Extension.Jsx:
return needJsx() || needAllowJs();
case ".js":
case ts.Extension.Js:
return needAllowJs();
}
function needJsx() {
Expand Down

0 comments on commit 0968ed9

Please sign in to comment.