mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-07-06 06:49:29 -05:00
Merge branch 'EmitStringEnumsInProtocol' into release-2.5
This commit is contained in:
81
lib/protocol.d.ts
vendored
81
lib/protocol.d.ts
vendored
@@ -1963,6 +1963,7 @@ declare namespace ts.server.protocol {
|
||||
System = "System",
|
||||
ES6 = "ES6",
|
||||
ES2015 = "ES2015",
|
||||
ESNext = "ESNext",
|
||||
}
|
||||
const enum ModuleResolutionKind {
|
||||
Classic = "Classic",
|
||||
@@ -1977,6 +1978,9 @@ declare namespace ts.server.protocol {
|
||||
ES5 = "ES5",
|
||||
ES6 = "ES6",
|
||||
ES2015 = "ES2015",
|
||||
ES2016 = "ES2016",
|
||||
ES2017 = "ES2017",
|
||||
ESNext = "ESNext",
|
||||
}
|
||||
}
|
||||
declare namespace ts.server.protocol {
|
||||
@@ -1998,6 +2002,81 @@ declare namespace ts.server.protocol {
|
||||
position: number;
|
||||
}
|
||||
|
||||
enum HighlightSpanKind {
|
||||
none = "none",
|
||||
definition = "definition",
|
||||
reference = "reference",
|
||||
writtenReference = "writtenReference",
|
||||
}
|
||||
|
||||
enum ScriptElementKind {
|
||||
unknown = "",
|
||||
warning = "warning",
|
||||
/** predefined type (void) or keyword (class) */
|
||||
keyword = "keyword",
|
||||
/** top level script node */
|
||||
scriptElement = "script",
|
||||
/** module foo {} */
|
||||
moduleElement = "module",
|
||||
/** class X {} */
|
||||
classElement = "class",
|
||||
/** var x = class X {} */
|
||||
localClassElement = "local class",
|
||||
/** interface Y {} */
|
||||
interfaceElement = "interface",
|
||||
/** type T = ... */
|
||||
typeElement = "type",
|
||||
/** enum E */
|
||||
enumElement = "enum",
|
||||
enumMemberElement = "enum member",
|
||||
/**
|
||||
* Inside module and script only
|
||||
* const v = ..
|
||||
*/
|
||||
variableElement = "var",
|
||||
/** Inside function */
|
||||
localVariableElement = "local var",
|
||||
/**
|
||||
* Inside module and script only
|
||||
* function f() { }
|
||||
*/
|
||||
functionElement = "function",
|
||||
/** Inside function */
|
||||
localFunctionElement = "local function",
|
||||
/** class X { [public|private]* foo() {} } */
|
||||
memberFunctionElement = "method",
|
||||
/** class X { [public|private]* [get|set] foo:number; } */
|
||||
memberGetAccessorElement = "getter",
|
||||
memberSetAccessorElement = "setter",
|
||||
/**
|
||||
* class X { [public|private]* foo:number; }
|
||||
* interface Y { foo:number; }
|
||||
*/
|
||||
memberVariableElement = "property",
|
||||
/** class X { constructor() { } } */
|
||||
constructorImplementationElement = "constructor",
|
||||
/** interface Y { ():number; } */
|
||||
callSignatureElement = "call",
|
||||
/** interface Y { []:number; } */
|
||||
indexSignatureElement = "index",
|
||||
/** interface Y { new():Y; } */
|
||||
constructSignatureElement = "construct",
|
||||
/** function foo(*Y*: string) */
|
||||
parameterElement = "parameter",
|
||||
typeParameterElement = "type parameter",
|
||||
primitiveType = "primitive type",
|
||||
label = "label",
|
||||
alias = "alias",
|
||||
constElement = "const",
|
||||
letElement = "let",
|
||||
directory = "directory",
|
||||
externalModuleName = "external module name",
|
||||
/**
|
||||
* <JsxTagName attribute1 attribute2={0} />
|
||||
*/
|
||||
jsxAttribute = "JSX attribute",
|
||||
}
|
||||
|
||||
interface TypeAcquisition {
|
||||
enableAutoDiscovery?: boolean;
|
||||
enable?: boolean;
|
||||
@@ -2033,8 +2112,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;
|
||||
|
||||
@@ -77866,6 +77866,7 @@ var ts;
|
||||
ModuleKind["System"] = "System";
|
||||
ModuleKind["ES6"] = "ES6";
|
||||
ModuleKind["ES2015"] = "ES2015";
|
||||
ModuleKind["ESNext"] = "ESNext";
|
||||
})(ModuleKind = protocol.ModuleKind || (protocol.ModuleKind = {}));
|
||||
var ModuleResolutionKind;
|
||||
(function (ModuleResolutionKind) {
|
||||
@@ -77883,6 +77884,9 @@ var ts;
|
||||
ScriptTarget["ES5"] = "ES5";
|
||||
ScriptTarget["ES6"] = "ES6";
|
||||
ScriptTarget["ES2015"] = "ES2015";
|
||||
ScriptTarget["ES2016"] = "ES2016";
|
||||
ScriptTarget["ES2017"] = "ES2017";
|
||||
ScriptTarget["ESNext"] = "ESNext";
|
||||
})(ScriptTarget = protocol.ScriptTarget || (protocol.ScriptTarget = {}));
|
||||
})(protocol = server.protocol || (server.protocol = {}));
|
||||
})(server = ts.server || (ts.server = {}));
|
||||
|
||||
4
lib/tsserverlibrary.d.ts
vendored
4
lib/tsserverlibrary.d.ts
vendored
@@ -4730,6 +4730,7 @@ declare namespace ts.server.protocol {
|
||||
System = "System",
|
||||
ES6 = "ES6",
|
||||
ES2015 = "ES2015",
|
||||
ESNext = "ESNext",
|
||||
}
|
||||
enum ModuleResolutionKind {
|
||||
Classic = "Classic",
|
||||
@@ -4744,6 +4745,9 @@ declare namespace ts.server.protocol {
|
||||
ES5 = "ES5",
|
||||
ES6 = "ES6",
|
||||
ES2015 = "ES2015",
|
||||
ES2016 = "ES2016",
|
||||
ES2017 = "ES2017",
|
||||
ESNext = "ESNext",
|
||||
}
|
||||
}
|
||||
declare namespace ts.server {
|
||||
|
||||
@@ -77209,6 +77209,7 @@ var ts;
|
||||
ModuleKind["System"] = "System";
|
||||
ModuleKind["ES6"] = "ES6";
|
||||
ModuleKind["ES2015"] = "ES2015";
|
||||
ModuleKind["ESNext"] = "ESNext";
|
||||
})(ModuleKind = protocol.ModuleKind || (protocol.ModuleKind = {}));
|
||||
var ModuleResolutionKind;
|
||||
(function (ModuleResolutionKind) {
|
||||
@@ -77226,6 +77227,9 @@ var ts;
|
||||
ScriptTarget["ES5"] = "ES5";
|
||||
ScriptTarget["ES6"] = "ES6";
|
||||
ScriptTarget["ES2015"] = "ES2015";
|
||||
ScriptTarget["ES2016"] = "ES2016";
|
||||
ScriptTarget["ES2017"] = "ES2017";
|
||||
ScriptTarget["ESNext"] = "ESNext";
|
||||
})(ScriptTarget = protocol.ScriptTarget || (protocol.ScriptTarget = {}));
|
||||
})(protocol = server.protocol || (server.protocol = {}));
|
||||
})(server = ts.server || (ts.server = {}));
|
||||
|
||||
@@ -7,11 +7,15 @@ function endsWith(s: string, suffix: string) {
|
||||
return s.lastIndexOf(suffix, s.length - suffix.length) !== -1;
|
||||
}
|
||||
|
||||
function isStringEnum(declaration: ts.EnumDeclaration) {
|
||||
return declaration.members.length && declaration.members.every(m => m.initializer && m.initializer.kind === ts.SyntaxKind.StringLiteral);
|
||||
}
|
||||
|
||||
class DeclarationsWalker {
|
||||
private visitedTypes: ts.Type[] = [];
|
||||
private text = "";
|
||||
private removedTypes: ts.Type[] = [];
|
||||
|
||||
|
||||
private constructor(private typeChecker: ts.TypeChecker, private protocolFile: ts.SourceFile) {
|
||||
}
|
||||
|
||||
@@ -19,7 +23,7 @@ class DeclarationsWalker {
|
||||
let text = "declare namespace ts.server.protocol {\n";
|
||||
var walker = new DeclarationsWalker(typeChecker, protocolFile);
|
||||
walker.visitTypeNodes(protocolFile);
|
||||
text = walker.text
|
||||
text = walker.text
|
||||
? `declare namespace ts.server.protocol {\n${walker.text}}`
|
||||
: "";
|
||||
if (walker.removedTypes) {
|
||||
@@ -52,7 +56,7 @@ class DeclarationsWalker {
|
||||
if (sourceFile === this.protocolFile || path.basename(sourceFile.fileName) === "lib.d.ts") {
|
||||
return;
|
||||
}
|
||||
if (decl.kind === ts.SyntaxKind.EnumDeclaration) {
|
||||
if (decl.kind === ts.SyntaxKind.EnumDeclaration && !isStringEnum(decl as ts.EnumDeclaration)) {
|
||||
this.removedTypes.push(type);
|
||||
return;
|
||||
}
|
||||
@@ -91,7 +95,7 @@ class DeclarationsWalker {
|
||||
for (const type of heritageClauses[0].types) {
|
||||
this.processTypeOfNode(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -110,7 +114,7 @@ class DeclarationsWalker {
|
||||
this.processType(type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function writeProtocolFile(outputFile: string, protocolTs: string, typeScriptServicesDts: string) {
|
||||
|
||||
@@ -2473,6 +2473,7 @@ namespace ts.server.protocol {
|
||||
System = "System",
|
||||
ES6 = "ES6",
|
||||
ES2015 = "ES2015",
|
||||
ESNext = "ESNext"
|
||||
}
|
||||
|
||||
export const enum ModuleResolutionKind {
|
||||
@@ -2490,5 +2491,8 @@ namespace ts.server.protocol {
|
||||
ES5 = "ES5",
|
||||
ES6 = "ES6",
|
||||
ES2015 = "ES2015",
|
||||
ES2016 = "ES2016",
|
||||
ES2017 = "ES2017",
|
||||
ESNext = "ESNext"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user