Merge pull request #2399 from Microsoft/decorators_min

This commit is contained in:
Ron Buckton
2015-03-24 19:57:21 -07:00
162 changed files with 6114 additions and 1712 deletions

View File

@@ -115,11 +115,17 @@ module ts {
let globalIterableType: ObjectType;
let anyArrayType: Type;
let globalTypedPropertyDescriptorType: ObjectType;
let globalClassDecoratorType: ObjectType;
let globalParameterDecoratorType: ObjectType;
let globalPropertyDecoratorType: ObjectType;
let globalMethodDecoratorType: ObjectType;
let tupleTypes: Map<TupleType> = {};
let unionTypes: Map<UnionType> = {};
let stringLiteralTypes: Map<StringLiteralType> = {};
let emitExtends = false;
let emitDecorate = false;
let mergedSymbols: Symbol[] = [];
let symbolLinks: SymbolLinks[] = [];
@@ -326,6 +332,7 @@ module ts {
let lastLocation: Node;
let propertyWithInvalidInitializer: Node;
let errorLocation = location;
let grandparent: Node;
loop: while (location) {
// Locals of a source file are not in scope (because they get merged into the global symbol table)
@@ -391,7 +398,7 @@ module ts {
// }
//
case SyntaxKind.ComputedPropertyName:
let grandparent = location.parent.parent;
grandparent = location.parent.parent;
if (grandparent.kind === SyntaxKind.ClassDeclaration || grandparent.kind === SyntaxKind.InterfaceDeclaration) {
// A reference to this grandparent's type parameters would be an error
if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & SymbolFlags.Type)) {
@@ -423,6 +430,28 @@ module ts {
break loop;
}
break;
case SyntaxKind.Decorator:
// Decorators are resolved at the class declaration. Resolving at the parameter
// or member would result in looking up locals in the method.
//
// function y() {}
// class C {
// method(@y x, y) {} // <-- decorator y should be resolved at the class declaration, not the parameter.
// }
//
if (location.parent && location.parent.kind === SyntaxKind.Parameter) {
location = location.parent;
}
//
// function y() {}
// class C {
// @y method(x, y) {} // <-- decorator y should be resolved at the class declaration, not the method.
// }
//
if (location.parent && isClassElement(location.parent)) {
location = location.parent;
}
break;
}
lastLocation = location;
location = location.parent;
@@ -7947,7 +7976,7 @@ module ts {
// strict mode FunctionLikeDeclaration or FunctionExpression(13.1)
// Grammar checking
checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, <Identifier>node.name);
checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEvalOrArgumentsInStrictMode(node, <Identifier>node.name);
checkVariableLikeDeclaration(node);
let func = getContainingFunction(node);
@@ -8049,7 +8078,7 @@ module ts {
function checkPropertyDeclaration(node: PropertyDeclaration) {
// Grammar checking
checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name);
checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarProperty(node) || checkGrammarComputedPropertyName(node.name);
checkVariableLikeDeclaration(node);
}
@@ -8188,6 +8217,10 @@ module ts {
checkFunctionLikeDeclaration(node);
}
function checkMissingDeclaration(node: Node) {
checkDecorators(node);
}
function checkTypeReference(node: TypeReferenceNode) {
// Grammar checking
checkGrammarTypeArguments(node, node.typeArguments);
@@ -8579,6 +8612,60 @@ module ts {
}
}
/** Check a decorator */
function checkDecorator(node: Decorator): void {
let expression: Expression = node.expression;
let exprType = checkExpression(expression);
switch (node.parent.kind) {
case SyntaxKind.ClassDeclaration:
let classSymbol = getSymbolOfNode(node.parent);
let classConstructorType = getTypeOfSymbol(classSymbol);
let classDecoratorType = instantiateSingleCallFunctionType(globalClassDecoratorType, [classConstructorType]);
checkTypeAssignableTo(exprType, classDecoratorType, node);
break;
case SyntaxKind.PropertyDeclaration:
checkTypeAssignableTo(exprType, globalPropertyDecoratorType, node);
break;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
let methodType = getTypeOfNode(node.parent);
let methodDecoratorType = instantiateSingleCallFunctionType(globalMethodDecoratorType, [methodType]);
checkTypeAssignableTo(exprType, methodDecoratorType, node);
break;
case SyntaxKind.Parameter:
checkTypeAssignableTo(exprType, globalParameterDecoratorType, node);
break;
}
}
/** Check the decorators of a node */
function checkDecorators(node: Node): void {
if (!node.decorators) {
return;
}
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.Parameter:
emitDecorate = true;
break;
default:
return;
}
forEach(node.decorators, checkDecorator);
}
function checkFunctionDeclaration(node: FunctionDeclaration): void {
if (produceDiagnostics) {
checkFunctionLikeDeclaration(node) ||
@@ -8593,6 +8680,7 @@ module ts {
}
function checkFunctionLikeDeclaration(node: FunctionLikeDeclaration): void {
checkDecorators(node);
checkSignatureDeclaration(node);
// Do not use hasDynamicName here, because that returns false for well known symbols.
@@ -8875,6 +8963,7 @@ module ts {
// Check variable, parameter, or property declaration
function checkVariableLikeDeclaration(node: VariableLikeDeclaration) {
checkDecorators(node);
checkSourceElement(node.type);
// For a computed property, just check the initializer and exit
// Do not use hasDynamicName here, because that returns false for well known symbols.
@@ -8947,7 +9036,7 @@ module ts {
function checkVariableStatement(node: VariableStatement) {
// Grammar checking
checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node);
checkGrammarDecorators(node) || checkGrammarDisallowedModifiersInBlockOrObjectLiteralExpression(node) || checkGrammarModifiers(node) || checkGrammarVariableDeclarationList(node.declarationList) || checkGrammarForDisallowedLetOrConstStatement(node);
forEach(node.declarationList.declarations, checkSourceElement);
}
@@ -9578,7 +9667,7 @@ module ts {
function checkClassDeclaration(node: ClassDeclaration) {
// Grammar checking
checkGrammarClassDeclarationHeritageClauses(node);
checkDecorators(node);
if (node.name) {
checkTypeNameIsReserved(node.name, Diagnostics.Class_name_cannot_be_0);
checkCollisionWithCapturedThisVariable(node, node.name);
@@ -9783,7 +9872,7 @@ module ts {
function checkInterfaceDeclaration(node: InterfaceDeclaration) {
// Grammar checking
checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarInterfaceDeclaration(node);
checkTypeParameters(node.typeParameters);
if (produceDiagnostics) {
@@ -9820,7 +9909,7 @@ module ts {
function checkTypeAliasDeclaration(node: TypeAliasDeclaration) {
// Grammar checking
checkGrammarModifiers(node);
checkGrammarDecorators(node) || checkGrammarModifiers(node);
checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0);
checkSourceElement(node.type);
@@ -10002,7 +10091,7 @@ module ts {
}
// Grammar checking
checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarEnumDeclaration(node);
checkTypeNameIsReserved(node.name, Diagnostics.Enum_name_cannot_be_0);
checkCollisionWithCapturedThisVariable(node, node.name);
@@ -10068,7 +10157,7 @@ module ts {
function checkModuleDeclaration(node: ModuleDeclaration) {
if (produceDiagnostics) {
// Grammar checking
if (!checkGrammarModifiers(node)) {
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node)) {
if (!isInAmbientContext(node) && node.name.kind === SyntaxKind.StringLiteral) {
grammarErrorOnNode(node.name, Diagnostics.Only_ambient_modules_can_use_quoted_names);
}
@@ -10163,7 +10252,7 @@ module ts {
}
function checkImportDeclaration(node: ImportDeclaration) {
if (!checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
grammarErrorOnFirstToken(node, Diagnostics.An_import_declaration_cannot_have_modifiers);
}
if (checkExternalImportOrExportDeclaration(node)) {
@@ -10185,7 +10274,7 @@ module ts {
}
function checkImportEqualsDeclaration(node: ImportEqualsDeclaration) {
checkGrammarModifiers(node);
checkGrammarDecorators(node) || checkGrammarModifiers(node);
if (isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
checkImportBinding(node);
if (node.flags & NodeFlags.Export) {
@@ -10216,7 +10305,7 @@ module ts {
}
function checkExportDeclaration(node: ExportDeclaration) {
if (!checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
grammarErrorOnFirstToken(node, Diagnostics.An_export_declaration_cannot_have_modifiers);
}
if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
@@ -10240,7 +10329,7 @@ module ts {
return;
}
// Grammar checking
if (!checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers);
}
if (node.expression) {
@@ -10418,6 +10507,8 @@ module ts {
case SyntaxKind.DebuggerStatement:
checkGrammarStatementInAmbientContext(node);
return;
case SyntaxKind.MissingDeclaration:
return checkMissingDeclaration(node);
}
}
@@ -10544,6 +10635,10 @@ module ts {
links.flags |= NodeCheckFlags.EmitExtends;
}
if (emitDecorate) {
links.flags |= NodeCheckFlags.EmitDecorate;
}
links.flags |= NodeCheckFlags.TypeChecked;
}
}
@@ -11189,6 +11284,20 @@ module ts {
return undefined;
}
function instantiateSingleCallFunctionType(functionType: Type, typeArguments: Type[]): Type {
if (functionType === unknownType) {
return unknownType;
}
let signature = getSingleCallSignature(functionType);
if (!signature) {
return unknownType;
}
let instantiatedSignature = getSignatureInstantiation(signature, typeArguments);
return getOrCreateTypeFromSignature(instantiatedSignature);
}
function createResolver(): EmitResolver {
return {
getExpressionNameSubstitution,
@@ -11238,6 +11347,11 @@ module ts {
globalNumberType = getGlobalType("Number");
globalBooleanType = getGlobalType("Boolean");
globalRegExpType = getGlobalType("RegExp");
globalTypedPropertyDescriptorType = getTypeOfGlobalSymbol(getGlobalTypeSymbol("TypedPropertyDescriptor"), 1);
globalClassDecoratorType = getGlobalType("ClassDecorator");
globalPropertyDecoratorType = getGlobalType("PropertyDecorator");
globalMethodDecoratorType = getGlobalType("MethodDecorator");
globalParameterDecoratorType = getGlobalType("ParameterDecorator");
// If we're in ES6 mode, load the TemplateStringsArray.
// Otherwise, default to 'unknown' for the purposes of type checking in LS scenarios.
@@ -11262,6 +11376,25 @@ module ts {
// GRAMMAR CHECKING
function checkGrammarDecorators(node: Node): boolean {
if (!node.decorators) {
return false;
}
if (!nodeCanBeDecorated(node)) {
return grammarErrorOnNode(node, Diagnostics.Decorators_are_not_valid_here);
}
else if (languageVersion < ScriptTarget.ES5) {
return grammarErrorOnNode(node, Diagnostics.Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher);
}
else if (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor) {
let accessors = mergeAccessorDeclarations((<ClassDeclaration>node.parent).members, <AccessorDeclaration>node);
if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) {
return grammarErrorOnNode(node, Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
}
}
return false;
}
function checkGrammarModifiers(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.GetAccessor:
@@ -11458,7 +11591,7 @@ module ts {
function checkGrammarFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean {
// Prevent cascading error by short-circuit
let file = getSourceFileOfNode(node);
return checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) ||
return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node, node.typeParameters, file) ||
checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file);
}
@@ -11515,7 +11648,7 @@ module ts {
function checkGrammarIndexSignature(node: SignatureDeclaration) {
// Prevent cascading error by short-circuit
checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node);
return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarIndexSignatureParameters(node) || checkGrammarForIndexSignatureModifier(node);
}
function checkGrammarForAtLeastOneTypeArgument(node: Node, typeArguments: NodeArray<TypeNode>): boolean {
@@ -11564,7 +11697,7 @@ module ts {
let seenExtendsClause = false;
let seenImplementsClause = false;
if (!checkGrammarModifiers(node) && node.heritageClauses) {
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) {
for (let heritageClause of node.heritageClauses) {
if (heritageClause.token === SyntaxKind.ExtendsKeyword) {
if (seenExtendsClause) {

View File

@@ -162,6 +162,39 @@ module ts {
return ~low;
}
export function foldLeft<T>(array: T[], f: (a: T, x: T) => T): T;
export function foldLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
export function foldLeft<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
if (array) {
var count = array.length;
if (count > 0) {
var pos = 0;
var result = arguments.length <= 2 ? array[pos++] : initial;
while (pos < count) {
result = f(<U>result, array[pos++]);
}
return <U>result;
}
}
return initial;
}
export function foldRight<T>(array: T[], f: (a: T, x: T) => T): T;
export function foldRight<T, U>(array: T[], f: (a: U, x: T) => U, initial: U): U;
export function foldRight<T, U>(array: T[], f: (a: U, x: T) => U, initial?: U): U {
if (array) {
var pos = array.length - 1;
if (pos >= 0) {
var result = arguments.length <= 2 ? array[pos--] : initial;
while (pos >= 0) {
result = f(<U>result, array[pos--]);
}
return <U>result;
}
}
return initial;
}
let hasOwnProperty = Object.prototype.hasOwnProperty;
export function hasProperty<T>(map: Map<T>, key: string): boolean {

View File

@@ -162,6 +162,9 @@ module ts {
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." },
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." },
Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." },
Decorators_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1205, category: DiagnosticCategory.Error, key: "Decorators are only available when targeting ECMAScript 5 and higher." },
Decorators_are_not_valid_here: { code: 1206, category: DiagnosticCategory.Error, key: "Decorators are not valid here." },
Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: { code: 1207, category: DiagnosticCategory.Error, key: "Decorators cannot be applied to multiple get/set accessors of the same name." },
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },

View File

@@ -639,6 +639,18 @@
"category": "Error",
"code": 1204
},
"Decorators are only available when targeting ECMAScript 5 and higher.": {
"category": "Error",
"code": 1205
},
"Decorators are not valid here.": {
"category": "Error",
"code": 1206
},
"Decorators cannot be applied to multiple get/set accessors of the same name.": {
"category": "Error",
"code": 1207
},
"Duplicate identifier '{0}'.": {
"category": "Error",

View File

@@ -21,6 +21,7 @@ module ts {
// flag enum used to request and track usages of few dedicated temp variables
// enum values are used to set/check bit values and thus should not have bit collisions.
let accessors = getAllAccessorDeclarations((<ClassDeclaration>node.parent).members, node);
const enum TempVariableKind {
auto = 0,
_i = 1,
@@ -102,9 +103,10 @@ module ts {
let generatedNameSet: Map<string>;
let nodeToGeneratedName: string[];
let blockScopedVariableToGeneratedName: string[];
let computedPropertyNamesToGeneratedNames: string[];
let extendsEmitted = false;
let decorateEmitted = false;
let tempCount = 0;
let tempVariables: Identifier[];
let tempParameters: Identifier[];
@@ -1160,6 +1162,38 @@ module ts {
emitLiteral(<LiteralExpression>node);
}
else if (node.kind === SyntaxKind.ComputedPropertyName) {
// if this is a decorated computed property, we will need to capture the result
// of the property expression so that we can apply decorators later. This is to ensure
// we don't introduce unintended side effects:
//
// class C {
// [_a = x]() { }
// }
//
// The emit for the decorated computed property decorator is:
//
// Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)));
//
if (nodeIsDecorated(node.parent)) {
if (!computedPropertyNamesToGeneratedNames) {
computedPropertyNamesToGeneratedNames = [];
}
let generatedName = computedPropertyNamesToGeneratedNames[node.id];
if (generatedName) {
// we have already generated a variable for this node, write that value instead.
write(generatedName);
return;
}
let generatedVariable = createTempVariable(node);
generatedName = generatedVariable.text;
recordTempDeclaration(generatedVariable);
computedPropertyNamesToGeneratedNames[node.id] = generatedName;
write(generatedName);
write(" = ");
}
emit((<ComputedPropertyName>node).expression);
}
else {
@@ -1463,7 +1497,7 @@ module ts {
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
let { firstAccessor, getAccessor, setAccessor } = getAllAccessorDeclarations(objectLiteral.properties, <AccessorDeclaration>property);
let { firstAccessor, getAccessor, setAccessor } = mergeAccessorDeclarations(objectLiteral.properties, <AccessorDeclaration>property);
// Only emit the first accessor.
if (firstAccessor !== property) {
@@ -1629,7 +1663,7 @@ module ts {
function emitComputedPropertyName(node: ComputedPropertyName) {
write("[");
emit(node.expression);
emitExpressionForPropertyName(node);
write("]");
}
@@ -3281,10 +3315,7 @@ module ts {
emitLeadingComments(member);
emitStart(member);
emitStart((<MethodDeclaration>member).name);
emitDeclarationName(node);
if (!(member.flags & NodeFlags.Static)) {
write(".prototype");
}
emitClassMemberPrefix(node, member);
emitMemberAccessForPropertyName((<MethodDeclaration>member).name);
emitEnd((<MethodDeclaration>member).name);
write(" = ");
@@ -3296,16 +3327,13 @@ module ts {
emitTrailingComments(member);
}
else if (member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) {
let accessors = getAllAccessorDeclarations(node.members, <AccessorDeclaration>member);
let accessors = mergeAccessorDeclarations(node.members, <AccessorDeclaration>member);
if (member === accessors.firstAccessor) {
writeLine();
emitStart(member);
write("Object.defineProperty(");
emitStart((<AccessorDeclaration>member).name);
emitDeclarationName(node);
if (!(member.flags & NodeFlags.Static)) {
write(".prototype");
}
emitClassMemberPrefix(node, member);
write(", ");
emitExpressionForPropertyName((<AccessorDeclaration>member).name);
emitEnd((<AccessorDeclaration>member).name);
@@ -3497,25 +3525,100 @@ module ts {
tempParameters = saveTempParameters;
}
function emitClassDeclaration(node: ClassDeclaration) {
if (languageVersion < ScriptTarget.ES6) {
emitClassDeclarationBelowES6(<ClassDeclaration>node);
}
else {
emitClassDeclarationForES6AndHigher(<ClassDeclaration>node);
}
}
function emitClassDeclarationForES6AndHigher(node: ClassDeclaration) {
if (isES6ModuleMemberDeclaration(node)) {
write("export ");
let thisNodeIsDecorated = nodeIsDecorated(node);
if (thisNodeIsDecorated) {
// To preserve the correct runtime semantics when decorators are applied to the class,
// the emit needs to follow one of the following rules:
//
// * For a local class declaration:
//
// @dec class C {
// }
//
// The emit should be:
//
// let C = class {
// };
// Object.defineProperty(C, "name", { value: "C", configurable: true });
// C = __decorate([dec], C);
//
// * For an exported class declaration:
//
// @dec export class C {
// }
//
// The emit should be:
//
// export let C = class {
// };
// Object.defineProperty(C, "name", { value: "C", configurable: true });
// C = __decorate([dec], C);
//
// * For a default export of a class declaration with a name:
//
// @dec default export class C {
// }
//
// The emit should be:
//
// let C = class {
// }
// Object.defineProperty(C, "name", { value: "C", configurable: true });
// C = __decorate([dec], C);
// export default C;
//
// * For a default export of a class declaration without a name:
//
// @dec default export class {
// }
//
// The emit should be:
//
// let _default = class {
// }
// _default = __decorate([dec], _default);
// export default _default;
//
if (isES6ModuleMemberDeclaration(node) && !(node.flags & NodeFlags.Default)) {
write("export ");
}
write("let ");
emitDeclarationName(node);
write(" = ");
}
else if (isES6ModuleMemberDeclaration(node)) {
write("export ");
if (node.flags & NodeFlags.Default) {
write("default ");
}
}
write("class ");
// check if this is an "export default class" as it may not have a name
if (node.name || !(node.flags & NodeFlags.Default)) {
write("class");
// check if this is an "export default class" as it may not have a name. Do not emit the name if the class is decorated.
if ((node.name || !(node.flags & NodeFlags.Default)) && !thisNodeIsDecorated) {
write(" ");
emitDeclarationName(node);
}
var baseTypeNode = getClassBaseTypeNode(node);
if (baseTypeNode) {
write(" extends ");
emit(baseTypeNode.typeName);
}
write(" {");
increaseIndent();
scopeEmitStart(node);
@@ -3527,6 +3630,26 @@ module ts {
emitToken(SyntaxKind.CloseBraceToken, node.members.end);
scopeEmitEnd();
// For a decorated class, we need to assign its name (if it has one). This is because we emit
// the class as a class expression to avoid the double-binding of the identifier:
//
// let C = class {
// }
// Object.defineProperty(C, "name", { value: "C", configurable: true });
//
if (thisNodeIsDecorated) {
write(";");
if (node.name) {
writeLine();
write("Object.defineProperty(");
emitDeclarationName(node);
write(", \"name\", { value: \"");
emitDeclarationName(node);
write("\", configurable: true });");
writeLine();
}
}
// Emit static property assignment. Because classDeclaration is lexically evaluated,
// it is safe to emit static property assignment after classDeclaration
// From ES6 specification:
@@ -3534,10 +3657,11 @@ module ts {
// a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
writeLine();
emitMemberAssignments(node, NodeFlags.Static);
emitDecoratorsOfClass(node);
// If this is an exported class, but not on the top level (i.e. on an internal
// module), export it
if (!isES6ModuleMemberDeclaration(node) && (node.flags & NodeFlags.Export)) {
// If this is an exported class, but not on the top level (i.e. on an internal
// module), export it
writeLine();
emitStart(node);
emitModuleMemberName(node);
@@ -3546,6 +3670,13 @@ module ts {
emitEnd(node);
write(";");
}
else if (isES6ModuleMemberDeclaration(node) && (node.flags & NodeFlags.Default) && thisNodeIsDecorated) {
// if this is a top level default export of decorated class, write the export after the declaration.
writeLine();
write("export default ");
emitDeclarationName(node);
write(";");
}
}
function emitClassDeclarationBelowES6(node: ClassDeclaration) {
@@ -3557,6 +3688,14 @@ module ts {
write("_super");
}
write(") {");
let saveTempCount = tempCount;
let saveTempVariables = tempVariables;
let saveTempParameters = tempParameters;
let saveComputedPropertyNamesToGeneratedNames = computedPropertyNamesToGeneratedNames;
tempCount = 0;
tempVariables = undefined;
tempParameters = undefined;
computedPropertyNamesToGeneratedNames = undefined;
increaseIndent();
scopeEmitStart(node);
if (baseTypeNode) {
@@ -3572,11 +3711,18 @@ module ts {
emitMemberFunctionsForES5AndLower(node);
emitMemberAssignments(node, NodeFlags.Static);
writeLine();
emitDecoratorsOfClass(node);
writeLine();
emitToken(SyntaxKind.CloseBraceToken, node.members.end, () => {
write("return ");
emitDeclarationName(node);
});
write(";");
emitTempDeclarations(/*newLine*/ true);
tempCount = saveTempCount;
tempVariables = saveTempVariables;
tempParameters = saveTempParameters;
computedPropertyNamesToGeneratedNames = saveComputedPropertyNamesToGeneratedNames;
decreaseIndent();
writeLine();
emitToken(SyntaxKind.CloseBraceToken, node.members.end);
@@ -3604,6 +3750,225 @@ module ts {
}
}
function emitClassMemberPrefix(node: ClassDeclaration, member: Node) {
emitDeclarationName(node);
if (!(member.flags & NodeFlags.Static)) {
write(".prototype");
}
}
function emitDecoratorsOfClass(node: ClassDeclaration) {
if (languageVersion < ScriptTarget.ES5) {
return;
}
emitDecoratorsOfMembers(node, /*staticFlag*/ 0);
emitDecoratorsOfMembers(node, NodeFlags.Static);
emitDecoratorsOfConstructor(node);
}
function emitDecoratorsOfConstructor(node: ClassDeclaration) {
let constructor = getFirstConstructorWithBody(node);
if (constructor) {
emitDecoratorsOfParameters(node, constructor);
}
if (!nodeIsDecorated(node)) {
return;
}
// Emit the call to __decorate. Given the class:
//
// @dec
// class C {
// }
//
// The emit for the class is:
//
// C = __decorate([dec], C);
//
writeLine();
emitStart(node);
emitDeclarationName(node);
write(" = ");
emitDecorateStart(node.decorators);
emitDeclarationName(node);
write(");");
emitEnd(node);
writeLine();
}
function emitDecoratorsOfMembers(node: ClassDeclaration, staticFlag: NodeFlags) {
forEach(node.members, member => {
if ((member.flags & NodeFlags.Static) !== staticFlag) {
return;
}
let decorators: NodeArray<Decorator>;
switch (member.kind) {
case SyntaxKind.MethodDeclaration:
// emit decorators of the method's parameters
emitDecoratorsOfParameters(node, <MethodDeclaration>member);
decorators = member.decorators;
break;
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
let accessors = mergeAccessorDeclarations(node.members, <AccessorDeclaration>member);
if (member !== accessors.firstAccessor) {
// skip the second accessor as we processed it with the first.
return;
}
if (accessors.setAccessor) {
// emit decorators of the set accessor parameter
emitDecoratorsOfParameters(node, <AccessorDeclaration>accessors.setAccessor);
}
// get the decorators from the first decorated accessor.
decorators = accessors.firstAccessor.decorators;
if (!decorators && accessors.secondAccessor) {
decorators = accessors.secondAccessor.decorators;
}
break;
case SyntaxKind.PropertyDeclaration:
decorators = member.decorators;
break;
default:
// Constructor cannot be decorated, and its parameters are handled in emitDecoratorsOfConstructor
// Other members (i.e. IndexSignature) cannot be decorated.
return;
}
if (!decorators) {
return;
}
// Emit the call to __decorate. Given the following:
//
// class C {
// @dec method() {}
// @dec get accessor() {}
// @dec prop;
// }
//
// The emit for a method is:
//
// Object.defineProperty(C.prototype, "method", __decorate([dec], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method")));
//
// The emit for an accessor is:
//
// Object.defineProperty(C.prototype, "accessor", __decorate([dec], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor")));
//
// The emit for a property is:
//
// __decorate([dec], C.prototype, "prop");
//
writeLine();
emitStart(member);
if (member.kind !== SyntaxKind.PropertyDeclaration) {
write("Object.defineProperty(");
emitStart(member.name);
emitClassMemberPrefix(node, member);
write(", ");
emitExpressionForPropertyName(member.name);
emitEnd(member.name);
write(", ");
}
emitDecorateStart(decorators);
emitStart(member.name);
emitClassMemberPrefix(node, member);
write(", ");
emitExpressionForPropertyName(member.name);
emitEnd(member.name);
if (member.kind !== SyntaxKind.PropertyDeclaration) {
write(", Object.getOwnPropertyDescriptor(");
emitStart(member.name);
emitClassMemberPrefix(node, member);
write(", ");
emitExpressionForPropertyName(member.name);
emitEnd(member.name);
write("))");
}
write(");");
emitEnd(member);
writeLine();
});
}
function emitDecoratorsOfParameters(node: ClassDeclaration, member: FunctionLikeDeclaration) {
forEach(member.parameters, (parameter, parameterIndex) => {
if (!nodeIsDecorated(parameter)) {
return;
}
// Emit the decorators for a parameter. Given the following:
//
// class C {
// constructor(@dec p) { }
// method(@dec p) { }
// set accessor(@dec value) { }
// }
//
// The emit for a constructor is:
//
// __decorate([dec], C, void 0, 0);
//
// The emit for a parameter is:
//
// __decorate([dec], C.prototype, "method", 0);
//
// The emit for an accessor is:
//
// __decorate([dec], C.prototype, "accessor", 0);
//
writeLine();
emitStart(parameter);
emitDecorateStart(parameter.decorators);
emitStart(parameter.name);
if (member.kind === SyntaxKind.Constructor) {
emitDeclarationName(node);
write(", void 0");
}
else {
emitClassMemberPrefix(node, member);
write(", ");
emitExpressionForPropertyName(member.name);
}
write(", ");
write(String(parameterIndex));
emitEnd(parameter.name);
write(");");
emitEnd(parameter);
writeLine();
});
}
function emitDecorateStart(decorators: Decorator[]): void {
write("__decorate([");
let decoratorCount = decorators.length;
for (let i = 0; i < decoratorCount; i++) {
if (i > 0) {
write(", ");
}
let decorator = decorators[i];
emitStart(decorator);
emit(decorator.expression);
emitEnd(decorator);
}
write("], ");
}
function emitInterfaceDeclaration(node: InterfaceDeclaration) {
emitOnlyPinnedOrTripleSlashComments(node);
}
@@ -4256,6 +4621,17 @@ module ts {
return statements.length;
}
function writeHelper(text: string): void {
let lines = text.split(/\r\n|\r|\n/g);
for (let i = 0; i < lines.length; ++i) {
let line = lines[i];
if (line.length) {
writeLine();
write(line);
}
}
}
function emitSourceFileNode(node: SourceFile) {
// Start new file on new line
writeLine();
@@ -4282,6 +4658,23 @@ module ts {
write("};");
extendsEmitted = true;
}
if (!decorateEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitDecorate) {
writeHelper(`
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};`);
decorateEmitted = true;
}
if (isExternalModule(node)) {
if (languageVersion >= ScriptTarget.ES6) {
emitES6Module(node, startIndex);
@@ -4500,7 +4893,7 @@ module ts {
case SyntaxKind.VariableDeclaration:
return emitVariableDeclaration(<VariableDeclaration>node);
case SyntaxKind.ClassDeclaration:
return languageVersion < ScriptTarget.ES6 ? emitClassDeclarationBelowES6(<ClassDeclaration>node) : emitClassDeclarationForES6AndHigher(<ClassDeclaration>node);
return emitClassDeclaration(<ClassDeclaration>node);
case SyntaxKind.InterfaceDeclaration:
return emitInterfaceDeclaration(<InterfaceDeclaration>node);
case SyntaxKind.EnumDeclaration:

View File

@@ -64,7 +64,8 @@ module ts {
case SyntaxKind.ShorthandPropertyAssignment:
case SyntaxKind.VariableDeclaration:
case SyntaxKind.BindingElement:
return visitNodes(cbNodes, node.modifiers) ||
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<VariableLikeDeclaration>node).propertyName) ||
visitNode(cbNode, (<VariableLikeDeclaration>node).dotDotDotToken) ||
visitNode(cbNode, (<VariableLikeDeclaration>node).name) ||
@@ -76,7 +77,8 @@ module ts {
case SyntaxKind.CallSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.IndexSignature:
return visitNodes(cbNodes, node.modifiers) ||
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNodes(cbNodes, (<SignatureDeclaration>node).typeParameters) ||
visitNodes(cbNodes, (<SignatureDeclaration>node).parameters) ||
visitNode(cbNode, (<SignatureDeclaration>node).type);
@@ -88,7 +90,8 @@ module ts {
case SyntaxKind.FunctionExpression:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.ArrowFunction:
return visitNodes(cbNodes, node.modifiers) ||
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<FunctionLikeDeclaration>node).asteriskToken) ||
visitNode(cbNode, (<FunctionLikeDeclaration>node).name) ||
visitNode(cbNode, (<FunctionLikeDeclaration>node).questionToken) ||
@@ -171,7 +174,8 @@ module ts {
return visitNodes(cbNodes, (<SourceFile>node).statements) ||
visitNode(cbNode, (<SourceFile>node).endOfFileToken);
case SyntaxKind.VariableStatement:
return visitNodes(cbNodes, node.modifiers) ||
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<VariableStatement>node).declarationList);
case SyntaxKind.VariableDeclarationList:
return visitNodes(cbNodes, (<VariableDeclarationList>node).declarations);
@@ -230,39 +234,48 @@ module ts {
case SyntaxKind.CatchClause:
return visitNode(cbNode, (<CatchClause>node).variableDeclaration) ||
visitNode(cbNode, (<CatchClause>node).block);
case SyntaxKind.Decorator:
return visitNode(cbNode, (<Decorator>node).expression);
case SyntaxKind.ClassDeclaration:
return visitNodes(cbNodes, node.modifiers) ||
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<ClassDeclaration>node).name) ||
visitNodes(cbNodes, (<ClassDeclaration>node).typeParameters) ||
visitNodes(cbNodes, (<ClassDeclaration>node).heritageClauses) ||
visitNodes(cbNodes, (<ClassDeclaration>node).members);
case SyntaxKind.InterfaceDeclaration:
return visitNodes(cbNodes, node.modifiers) ||
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<InterfaceDeclaration>node).name) ||
visitNodes(cbNodes, (<InterfaceDeclaration>node).typeParameters) ||
visitNodes(cbNodes, (<ClassDeclaration>node).heritageClauses) ||
visitNodes(cbNodes, (<InterfaceDeclaration>node).members);
case SyntaxKind.TypeAliasDeclaration:
return visitNodes(cbNodes, node.modifiers) ||
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<TypeAliasDeclaration>node).name) ||
visitNode(cbNode, (<TypeAliasDeclaration>node).type);
case SyntaxKind.EnumDeclaration:
return visitNodes(cbNodes, node.modifiers) ||
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<EnumDeclaration>node).name) ||
visitNodes(cbNodes, (<EnumDeclaration>node).members);
case SyntaxKind.EnumMember:
return visitNode(cbNode, (<EnumMember>node).name) ||
visitNode(cbNode, (<EnumMember>node).initializer);
case SyntaxKind.ModuleDeclaration:
return visitNodes(cbNodes, node.modifiers) ||
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<ModuleDeclaration>node).name) ||
visitNode(cbNode, (<ModuleDeclaration>node).body);
case SyntaxKind.ImportEqualsDeclaration:
return visitNodes(cbNodes, node.modifiers) ||
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<ImportEqualsDeclaration>node).name) ||
visitNode(cbNode, (<ImportEqualsDeclaration>node).moduleReference);
case SyntaxKind.ImportDeclaration:
return visitNodes(cbNodes, node.modifiers) ||
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<ImportDeclaration>node).importClause) ||
visitNode(cbNode, (<ImportDeclaration>node).moduleSpecifier);
case SyntaxKind.ImportClause:
@@ -274,7 +287,8 @@ module ts {
case SyntaxKind.NamedExports:
return visitNodes(cbNodes, (<NamedImportsOrExports>node).elements);
case SyntaxKind.ExportDeclaration:
return visitNodes(cbNodes, node.modifiers) ||
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<ExportDeclaration>node).exportClause) ||
visitNode(cbNode, (<ExportDeclaration>node).moduleSpecifier);
case SyntaxKind.ImportSpecifier:
@@ -282,7 +296,8 @@ module ts {
return visitNode(cbNode, (<ImportOrExportSpecifier>node).propertyName) ||
visitNode(cbNode, (<ImportOrExportSpecifier>node).name);
case SyntaxKind.ExportAssignment:
return visitNodes(cbNodes, node.modifiers) ||
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<ExportAssignment>node).expression) ||
visitNode(cbNode, (<ExportAssignment>node).type);
case SyntaxKind.TemplateExpression:
@@ -295,6 +310,8 @@ module ts {
return visitNodes(cbNodes, (<HeritageClause>node).types);
case SyntaxKind.ExternalModuleReference:
return visitNode(cbNode, (<ExternalModuleReference>node).expression);
case SyntaxKind.MissingDeclaration:
return visitNodes(cbNodes, node.decorators);
}
}
@@ -987,6 +1004,8 @@ module ts {
}
function parseSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, syntaxCursor: SyntaxCursor, setParentNodes = false): SourceFile {
const disallowInAndDecoratorContext = ParserContextFlags.DisallowIn | ParserContextFlags.Decorator;
let parsingContext: ParsingContext = 0;
let identifiers: Map<string> = {};
let identifierCount = 0;
@@ -1130,6 +1149,23 @@ module ts {
setContextFlag(val, ParserContextFlags.GeneratorParameter);
}
function setDecoratorContext(val: boolean) {
setContextFlag(val, ParserContextFlags.Decorator);
}
function doOutsideOfContext<T>(flags: ParserContextFlags, func: () => T): T {
let currentContextFlags = contextFlags & flags;
if (currentContextFlags) {
setContextFlag(false, currentContextFlags);
let result = func();
setContextFlag(true, currentContextFlags);
return result;
}
// no need to do anything special as we are not in any of the requested contexts
return func();
}
function allowInAnd<T>(func: () => T): T {
if (contextFlags & ParserContextFlags.DisallowIn) {
setDisallowInContext(false);
@@ -1178,6 +1214,18 @@ module ts {
return func();
}
function doInDecoratorContext<T>(func: () => T): T {
if (contextFlags & ParserContextFlags.Decorator) {
// no need to do anything special if we're already in the [Decorator] context.
return func();
}
setDecoratorContext(true);
let result = func();
setDecoratorContext(false);
return result;
}
function inYieldContext() {
return (contextFlags & ParserContextFlags.Yield) !== 0;
}
@@ -1194,6 +1242,10 @@ module ts {
return (contextFlags & ParserContextFlags.DisallowIn) !== 0;
}
function inDecoratorContext() {
return (contextFlags & ParserContextFlags.Decorator) !== 0;
}
function parseErrorAtCurrentToken(message: DiagnosticMessage, arg0?: any): void {
let start = scanner.getTokenPos();
let length = scanner.getTextPos() - start;
@@ -1403,7 +1455,7 @@ module ts {
return node;
}
function createMissingNode(kind: SyntaxKind, reportAtCurrentPosition: boolean, diagnosticMessage: DiagnosticMessage, arg0?: any): Node {
if (reportAtCurrentPosition) {
parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0);
@@ -2273,7 +2325,7 @@ module ts {
}
function isStartOfParameter(): boolean {
return token === SyntaxKind.DotDotDotToken || isIdentifierOrPattern() || isModifier(token);
return token === SyntaxKind.DotDotDotToken || isIdentifierOrPattern() || isModifier(token) || token === SyntaxKind.AtToken;
}
function setModifiers(node: Node, modifiers: ModifiersArray) {
@@ -2285,6 +2337,7 @@ module ts {
function parseParameter(): ParameterDeclaration {
let node = <ParameterDeclaration>createNode(SyntaxKind.Parameter);
node.decorators = parseDecorators();
setModifiers(node, parseModifiers());
node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken);
@@ -2473,9 +2526,9 @@ module ts {
return token === SyntaxKind.ColonToken || token === SyntaxKind.CommaToken || token === SyntaxKind.CloseBracketToken;
}
function parseIndexSignatureDeclaration(modifiers: ModifiersArray): IndexSignatureDeclaration {
let fullStart = modifiers ? modifiers.pos : scanner.getStartPos();
function parseIndexSignatureDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): IndexSignatureDeclaration {
let node = <IndexSignatureDeclaration>createNode(SyntaxKind.IndexSignature, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
node.parameters = parseBracketedList(ParsingContext.Parameters, parseParameter, SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
node.type = parseTypeAnnotation();
@@ -2552,7 +2605,7 @@ module ts {
case SyntaxKind.OpenBracketToken:
// Indexer or computed property
return isIndexSignature()
? parseIndexSignatureDeclaration(/*modifiers:*/ undefined)
? parseIndexSignatureDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers:*/ undefined)
: parsePropertyOrMethodSignature();
case SyntaxKind.NewKeyword:
if (lookAhead(isStartOfConstructSignature)) {
@@ -2583,9 +2636,11 @@ module ts {
}
function parseIndexSignatureWithModifiers() {
let fullStart = scanner.getStartPos();
let decorators = parseDecorators();
let modifiers = parseModifiers();
return isIndexSignature()
? parseIndexSignatureDeclaration(modifiers)
? parseIndexSignatureDeclaration(fullStart, decorators, modifiers)
: undefined;
}
@@ -2841,7 +2896,7 @@ module ts {
function isStartOfExpressionStatement(): boolean {
// As per the grammar, neither '{' nor 'function' can start an expression statement.
return token !== SyntaxKind.OpenBraceToken && token !== SyntaxKind.FunctionKeyword && isStartOfExpression();
return token !== SyntaxKind.OpenBraceToken && token !== SyntaxKind.FunctionKeyword && token !== SyntaxKind.AtToken && isStartOfExpression();
}
function parseExpression(): Expression {
@@ -2849,11 +2904,21 @@ module ts {
// AssignmentExpression[in]
// Expression[in] , AssignmentExpression[in]
// clear the decorator context when parsing Expression, as it should be unambiguous when parsing a decorator
let saveDecoratorContext = inDecoratorContext();
if (saveDecoratorContext) {
setDecoratorContext(false);
}
let expr = parseAssignmentExpressionOrHigher();
let operatorToken: Node;
while ((operatorToken = parseOptionalToken(SyntaxKind.CommaToken))) {
expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher());
}
if (saveDecoratorContext) {
setDecoratorContext(true);
}
return expr;
}
@@ -3209,7 +3274,7 @@ module ts {
let node = <ConditionalExpression>createNode(SyntaxKind.ConditionalExpression, leftOperand.pos);
node.condition = leftOperand;
node.questionToken = questionToken;
node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher);
node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher);
node.colonToken = parseExpectedToken(SyntaxKind.ColonToken, /*reportAtCurrentPosition:*/ false,
Diagnostics._0_expected, tokenToString(SyntaxKind.ColonToken));
node.whenFalse = parseAssignmentExpressionOrHigher();
@@ -3500,7 +3565,8 @@ module ts {
continue;
}
if (parseOptional(SyntaxKind.OpenBracketToken)) {
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
if (!inDecoratorContext() && parseOptional(SyntaxKind.OpenBracketToken)) {
let indexedAccess = <ElementAccessExpression>createNode(SyntaxKind.ElementAccessExpression, expression.pos);
indexedAccess.expression = expression;
@@ -3536,7 +3602,6 @@ module ts {
function parseCallExpressionRest(expression: LeftHandSideExpression): LeftHandSideExpression {
while (true) {
expression = parseMemberExpressionRest(expression);
if (token === SyntaxKind.LessThanToken) {
// See if this is the start of a generic invocation. If so, consume it and
// keep checking for postfix expressions. Otherwise, it's just a '<' that's
@@ -3683,7 +3748,7 @@ module ts {
}
function parseArgumentExpression(): Expression {
return allowInAnd(parseArgumentOrArrayLiteralElement);
return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
}
function parseArrayLiteralExpression(): ArrayLiteralExpression {
@@ -3695,12 +3760,12 @@ module ts {
return finishNode(node);
}
function tryParseAccessorDeclaration(fullStart: number, modifiers: ModifiersArray): AccessorDeclaration {
function tryParseAccessorDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): AccessorDeclaration {
if (parseContextualModifier(SyntaxKind.GetKeyword)) {
return parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, modifiers);
return parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, decorators, modifiers);
}
else if (parseContextualModifier(SyntaxKind.SetKeyword)) {
return parseAccessorDeclaration(SyntaxKind.SetAccessor, fullStart, modifiers);
return parseAccessorDeclaration(SyntaxKind.SetAccessor, fullStart, decorators, modifiers);
}
return undefined;
@@ -3708,9 +3773,10 @@ module ts {
function parseObjectLiteralElement(): ObjectLiteralElement {
let fullStart = scanner.getStartPos();
let decorators = parseDecorators();
let modifiers = parseModifiers();
let accessor = tryParseAccessorDeclaration(fullStart, modifiers);
let accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers);
if (accessor) {
return accessor;
}
@@ -3723,7 +3789,7 @@ module ts {
// Disallowing of optional property assignments happens in the grammar checker.
let questionToken = parseOptionalToken(SyntaxKind.QuestionToken);
if (asteriskToken || token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
return parseMethodDeclaration(fullStart, modifiers, asteriskToken, propertyName, questionToken);
return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken);
}
// Parse to check if it is short-hand property assignment or normal property assignment
@@ -3760,12 +3826,19 @@ module ts {
// function * BindingIdentifier[Yield]opt (FormalParameters[Yield, GeneratorParameter]) { GeneratorBody[Yield] }
// FunctionExpression:
// function BindingIdentifieropt(FormalParameters) { FunctionBody }
let saveDecoratorContext = inDecoratorContext();
if (saveDecoratorContext) {
setDecoratorContext(false);
}
let node = <FunctionExpression>createNode(SyntaxKind.FunctionExpression);
parseExpected(SyntaxKind.FunctionKeyword);
node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
node.name = node.asteriskToken ? doInYieldContext(parseOptionalIdentifier) : parseOptionalIdentifier();
fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ !!node.asteriskToken, /*requireCompleteParameterList:*/ false, node);
node.body = parseFunctionBlock(/*allowYield:*/ !!node.asteriskToken, /* ignoreMissingOpenBrace */ false);
if (saveDecoratorContext) {
setDecoratorContext(true);
}
return finishNode(node);
}
@@ -3802,8 +3875,19 @@ module ts {
let savedYieldContext = inYieldContext();
setYieldContext(allowYield);
// We may be in a [Decorator] context when parsing a function expression or
// arrow function. The body of the function is not in [Decorator] context.
let saveDecoratorContext = inDecoratorContext();
if (saveDecoratorContext) {
setDecoratorContext(false);
}
let block = parseBlock(ignoreMissingOpenBrace, /*checkForStrictMode*/ true, diagnosticMessage);
if (saveDecoratorContext) {
setDecoratorContext(true);
}
setYieldContext(savedYieldContext);
return block;
@@ -4051,7 +4135,7 @@ module ts {
// as the parser will produce the same FunctionDeclaraiton or VariableStatement if it has
// the same text regardless of whether it is inside a block or not.
if (isModifier(token)) {
let result = lookAhead(parseVariableStatementOrFunctionDeclarationWithModifiers);
let result = lookAhead(parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers);
if (result) {
return true;
}
@@ -4135,9 +4219,9 @@ module ts {
case SyntaxKind.VarKeyword:
case SyntaxKind.ConstKeyword:
// const here should always be parsed as const declaration because of check in 'isStatement'
return parseVariableStatement(scanner.getStartPos(), /*modifiers:*/ undefined);
return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers:*/ undefined);
case SyntaxKind.FunctionKeyword:
return parseFunctionDeclaration(scanner.getStartPos(), /*modifiers:*/ undefined);
return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers:*/ undefined);
case SyntaxKind.SemicolonToken:
return parseEmptyStatement();
case SyntaxKind.IfKeyword:
@@ -4170,7 +4254,7 @@ module ts {
case SyntaxKind.LetKeyword:
// If let follows identifier on the same line, it is declaration parse it as variable statement
if (isLetDeclaration()) {
return parseVariableStatement(scanner.getStartPos(), /*modifiers:*/ undefined);
return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers:*/ undefined);
}
// Else parse it like identifier - fall through
default:
@@ -4180,8 +4264,10 @@ module ts {
// work properly when incrementally parsing as the parser will produce the
// same FunctionDeclaraiton or VariableStatement if it has the same text
// regardless of whether it is inside a block or not.
if (isModifier(token)) {
let result = tryParse(parseVariableStatementOrFunctionDeclarationWithModifiers);
// Even though variable statements and function declarations cannot have decorators,
// we parse them here to provide better error recovery.
if (isModifier(token) || token === SyntaxKind.AtToken) {
let result = tryParse(parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers);
if (result) {
return result;
}
@@ -4191,8 +4277,9 @@ module ts {
}
}
function parseVariableStatementOrFunctionDeclarationWithModifiers(): FunctionDeclaration | VariableStatement {
function parseVariableStatementOrFunctionDeclarationWithDecoratorsOrModifiers(): FunctionDeclaration | VariableStatement {
let start = scanner.getStartPos();
let decorators = parseDecorators();
let modifiers = parseModifiers();
switch (token) {
case SyntaxKind.ConstKeyword:
@@ -4200,18 +4287,18 @@ module ts {
if (nextTokenIsEnum) {
return undefined;
}
return parseVariableStatement(start, modifiers);
return parseVariableStatement(start, decorators, modifiers);
case SyntaxKind.LetKeyword:
if (!isLetDeclaration()) {
return undefined;
}
return parseVariableStatement(start, modifiers);
return parseVariableStatement(start, decorators, modifiers);
case SyntaxKind.VarKeyword:
return parseVariableStatement(start, modifiers);
return parseVariableStatement(start, decorators, modifiers);
case SyntaxKind.FunctionKeyword:
return parseFunctionDeclaration(start, modifiers);
return parseFunctionDeclaration(start, decorators, modifiers);
}
return undefined;
@@ -4341,16 +4428,18 @@ module ts {
return nextTokenIsIdentifier() && nextToken() === SyntaxKind.CloseParenToken;
}
function parseVariableStatement(fullStart: number, modifiers: ModifiersArray): VariableStatement {
function parseVariableStatement(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): VariableStatement {
let node = <VariableStatement>createNode(SyntaxKind.VariableStatement, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer:*/ false);
parseSemicolon();
return finishNode(node);
}
function parseFunctionDeclaration(fullStart: number, modifiers: ModifiersArray): FunctionDeclaration {
function parseFunctionDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): FunctionDeclaration {
let node = <FunctionDeclaration>createNode(SyntaxKind.FunctionDeclaration, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
parseExpected(SyntaxKind.FunctionKeyword);
node.asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
@@ -4360,8 +4449,9 @@ module ts {
return finishNode(node);
}
function parseConstructorDeclaration(pos: number, modifiers: ModifiersArray): ConstructorDeclaration {
function parseConstructorDeclaration(pos: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ConstructorDeclaration {
let node = <ConstructorDeclaration>createNode(SyntaxKind.Constructor, pos);
node.decorators = decorators;
setModifiers(node, modifiers);
parseExpected(SyntaxKind.ConstructorKeyword);
fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ false, /*requireCompleteParameterList:*/ false, node);
@@ -4369,8 +4459,9 @@ module ts {
return finishNode(node);
}
function parseMethodDeclaration(fullStart: number, modifiers: ModifiersArray, asteriskToken: Node, name: DeclarationName, questionToken: Node, diagnosticMessage?: DiagnosticMessage): MethodDeclaration {
function parseMethodDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, asteriskToken: Node, name: DeclarationName, questionToken: Node, diagnosticMessage?: DiagnosticMessage): MethodDeclaration {
let method = <MethodDeclaration>createNode(SyntaxKind.MethodDeclaration, fullStart);
method.decorators = decorators;
setModifiers(method, modifiers);
method.asteriskToken = asteriskToken;
method.name = name;
@@ -4380,25 +4471,30 @@ module ts {
return finishNode(method);
}
function parsePropertyOrMethodDeclaration(fullStart: number, modifiers: ModifiersArray): ClassElement {
function parsePropertyDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, name: DeclarationName, questionToken: Node): ClassElement {
let property = <PropertyDeclaration>createNode(SyntaxKind.PropertyDeclaration, fullStart);
property.decorators = decorators;
setModifiers(property, modifiers);
property.name = name;
property.questionToken = questionToken;
property.type = parseTypeAnnotation();
property.initializer = allowInAnd(parseNonParameterInitializer);
parseSemicolon();
return finishNode(property);
}
function parsePropertyOrMethodDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ClassElement {
let asteriskToken = parseOptionalToken(SyntaxKind.AsteriskToken);
let name = parsePropertyName();
// Note: this is not legal as per the grammar. But we allow it in the parser and
// report an error in the grammar checker.
let questionToken = parseOptionalToken(SyntaxKind.QuestionToken);
if (asteriskToken || token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
return parseMethodDeclaration(fullStart, modifiers, asteriskToken, name, questionToken, Diagnostics.or_expected);
return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, Diagnostics.or_expected);
}
else {
let property = <PropertyDeclaration>createNode(SyntaxKind.PropertyDeclaration, fullStart);
setModifiers(property, modifiers);
property.name = name;
property.questionToken = questionToken;
property.type = parseTypeAnnotation();
property.initializer = allowInAnd(parseNonParameterInitializer);
parseSemicolon();
return finishNode(property);
return parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken);
}
}
@@ -4406,8 +4502,9 @@ module ts {
return parseInitializer(/*inParameter*/ false);
}
function parseAccessorDeclaration(kind: SyntaxKind, fullStart: number, modifiers: ModifiersArray): AccessorDeclaration {
function parseAccessorDeclaration(kind: SyntaxKind, fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): AccessorDeclaration {
let node = <AccessorDeclaration>createNode(kind, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
node.name = parsePropertyName();
fillSignature(SyntaxKind.ColonToken, /*yieldAndGeneratorParameterContext:*/ false, /*requireCompleteParameterList:*/ false, node);
@@ -4418,6 +4515,10 @@ module ts {
function isClassMemberStart(): boolean {
let idToken: SyntaxKind;
if (token === SyntaxKind.AtToken) {
return true;
}
// Eat up all modifiers, but hold on to the last one in case it is actually an identifier.
while (isModifier(token)) {
idToken = token;
@@ -4469,6 +4570,29 @@ module ts {
return false;
}
function parseDecorators(): NodeArray<Decorator> {
let decorators: NodeArray<Decorator>;
while (true) {
let decoratorStart = getNodePos();
if (!parseOptional(SyntaxKind.AtToken)) {
break;
}
if (!decorators) {
decorators = <NodeArray<Decorator>>[];
decorators.pos = scanner.getStartPos();
}
let decorator = <Decorator>createNode(SyntaxKind.Decorator, decoratorStart);
decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher);
decorators.push(finishNode(decorator));
}
if (decorators) {
decorators.end = getNodeEnd();
}
return decorators;
}
function parseModifiers(): ModifiersArray {
let flags = 0;
let modifiers: ModifiersArray;
@@ -4496,19 +4620,20 @@ module ts {
function parseClassElement(): ClassElement {
let fullStart = getNodePos();
let decorators = parseDecorators();
let modifiers = parseModifiers();
let accessor = tryParseAccessorDeclaration(fullStart, modifiers);
let accessor = tryParseAccessorDeclaration(fullStart, decorators, modifiers);
if (accessor) {
return accessor;
}
if (token === SyntaxKind.ConstructorKeyword) {
return parseConstructorDeclaration(fullStart, modifiers);
return parseConstructorDeclaration(fullStart, decorators, modifiers);
}
if (isIndexSignature()) {
return parseIndexSignatureDeclaration(modifiers);
return parseIndexSignatureDeclaration(fullStart, decorators, modifiers);
}
// It is very important that we check this *after* checking indexers because
@@ -4519,14 +4644,20 @@ module ts {
token === SyntaxKind.AsteriskToken ||
token === SyntaxKind.OpenBracketToken) {
return parsePropertyOrMethodDeclaration(fullStart, modifiers);
return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers);
}
if (decorators) {
// treat this as a property declaration with a missing name.
let name = <Identifier>createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected);
return parsePropertyDeclaration(fullStart, decorators, modifiers, name, /*questionToken*/ undefined);
}
// 'isClassMemberStart' should have hinted not to attempt parsing.
Debug.fail("Should not have attempted to parse class member declaration.");
}
function parseClassDeclaration(fullStart: number, modifiers: ModifiersArray): ClassDeclaration {
function parseClassDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ClassDeclaration {
// In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code
let savedStrictModeContext = inStrictModeContext();
if (languageVersion >= ScriptTarget.ES6) {
@@ -4534,6 +4665,7 @@ module ts {
}
var node = <ClassDeclaration>createNode(SyntaxKind.ClassDeclaration, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
parseExpected(SyntaxKind.ClassKeyword);
node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier();
@@ -4597,8 +4729,9 @@ module ts {
return parseList(ParsingContext.ClassMembers, /*checkForStrictMode*/ false, parseClassElement);
}
function parseInterfaceDeclaration(fullStart: number, modifiers: ModifiersArray): InterfaceDeclaration {
function parseInterfaceDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): InterfaceDeclaration {
let node = <InterfaceDeclaration>createNode(SyntaxKind.InterfaceDeclaration, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
parseExpected(SyntaxKind.InterfaceKeyword);
node.name = parseIdentifier();
@@ -4608,8 +4741,9 @@ module ts {
return finishNode(node);
}
function parseTypeAliasDeclaration(fullStart: number, modifiers: ModifiersArray): TypeAliasDeclaration {
function parseTypeAliasDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): TypeAliasDeclaration {
let node = <TypeAliasDeclaration>createNode(SyntaxKind.TypeAliasDeclaration, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
parseExpected(SyntaxKind.TypeKeyword);
node.name = parseIdentifier();
@@ -4630,8 +4764,9 @@ module ts {
return finishNode(node);
}
function parseEnumDeclaration(fullStart: number, modifiers: ModifiersArray): EnumDeclaration {
function parseEnumDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): EnumDeclaration {
let node = <EnumDeclaration>createNode(SyntaxKind.EnumDeclaration, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
parseExpected(SyntaxKind.EnumKeyword);
node.name = parseIdentifier();
@@ -4657,30 +4792,32 @@ module ts {
return finishNode(node);
}
function parseInternalModuleTail(fullStart: number, modifiers: ModifiersArray, flags: NodeFlags): ModuleDeclaration {
function parseInternalModuleTail(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray, flags: NodeFlags): ModuleDeclaration {
let node = <ModuleDeclaration>createNode(SyntaxKind.ModuleDeclaration, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
node.flags |= flags;
node.name = parseIdentifier();
node.body = parseOptional(SyntaxKind.DotToken)
? parseInternalModuleTail(getNodePos(), /*modifiers:*/undefined, NodeFlags.Export)
? parseInternalModuleTail(getNodePos(), /*decorators*/ undefined, /*modifiers:*/undefined, NodeFlags.Export)
: parseModuleBlock();
return finishNode(node);
}
function parseAmbientExternalModuleDeclaration(fullStart: number, modifiers: ModifiersArray): ModuleDeclaration {
function parseAmbientExternalModuleDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ModuleDeclaration {
let node = <ModuleDeclaration>createNode(SyntaxKind.ModuleDeclaration, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
node.name = parseLiteralNode(/*internName:*/ true);
node.body = parseModuleBlock();
return finishNode(node);
}
function parseModuleDeclaration(fullStart: number, modifiers: ModifiersArray): ModuleDeclaration {
function parseModuleDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ModuleDeclaration {
parseExpected(SyntaxKind.ModuleKeyword);
return token === SyntaxKind.StringLiteral
? parseAmbientExternalModuleDeclaration(fullStart, modifiers)
: parseInternalModuleTail(fullStart, modifiers, modifiers ? modifiers.flags : 0);
? parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers)
: parseInternalModuleTail(fullStart, decorators, modifiers, modifiers ? modifiers.flags : 0);
}
function isExternalModuleReference() {
@@ -4698,7 +4835,7 @@ module ts {
token === SyntaxKind.FromKeyword;
}
function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, modifiers: ModifiersArray): ImportEqualsDeclaration | ImportDeclaration {
function parseImportDeclarationOrImportEqualsDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ImportEqualsDeclaration | ImportDeclaration {
parseExpected(SyntaxKind.ImportKeyword);
let afterImportPos = scanner.getStartPos();
@@ -4710,6 +4847,7 @@ module ts {
// import x = require("mod"); or
// import x = M.x;
let importEqualsDeclaration = <ImportEqualsDeclaration>createNode(SyntaxKind.ImportEqualsDeclaration, fullStart);
importEqualsDeclaration.decorators = decorators;
setModifiers(importEqualsDeclaration, modifiers);
importEqualsDeclaration.name = identifier;
parseExpected(SyntaxKind.EqualsToken);
@@ -4721,6 +4859,7 @@ module ts {
// Import statement
let importDeclaration = <ImportDeclaration>createNode(SyntaxKind.ImportDeclaration, fullStart);
importDeclaration.decorators = decorators;
setModifiers(importDeclaration, modifiers);
// ImportDeclaration:
@@ -4855,8 +4994,9 @@ module ts {
return finishNode(node);
}
function parseExportDeclaration(fullStart: number, modifiers: ModifiersArray): ExportDeclaration {
function parseExportDeclaration(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ExportDeclaration {
let node = <ExportDeclaration>createNode(SyntaxKind.ExportDeclaration, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
if (parseOptional(SyntaxKind.AsteriskToken)) {
parseExpected(SyntaxKind.FromKeyword);
@@ -4872,8 +5012,9 @@ module ts {
return finishNode(node);
}
function parseExportAssignment(fullStart: number, modifiers: ModifiersArray): ExportAssignment {
function parseExportAssignment(fullStart: number, decorators: NodeArray<Decorator>, modifiers: ModifiersArray): ExportAssignment {
let node = <ExportAssignment>createNode(SyntaxKind.ExportAssignment, fullStart);
node.decorators = decorators;
setModifiers(node, modifiers);
if (parseOptional(SyntaxKind.EqualsToken)) {
node.isExportEquals = true;
@@ -4898,7 +5039,7 @@ module ts {
return inStrictModeContext() || lookAhead(nextTokenIsIdentifierOrStartOfDestructuringOnTheSameLine);
}
function isDeclarationStart(): boolean {
function isDeclarationStart(followsModifier?: boolean): boolean {
switch (token) {
case SyntaxKind.VarKeyword:
case SyntaxKind.ConstKeyword:
@@ -4928,6 +5069,10 @@ module ts {
case SyntaxKind.StaticKeyword:
// Check for modifier on source element
return lookAhead(nextTokenIsDeclarationStart);
case SyntaxKind.AtToken:
// a lookahead here is too costly, and decorators are only valid on a declaration.
// We will assume we are parsing a declaration here and report an error later
return !followsModifier;
}
}
@@ -4954,12 +5099,12 @@ module ts {
function nextTokenCanFollowExportKeyword() {
nextToken();
return token === SyntaxKind.EqualsToken || token === SyntaxKind.AsteriskToken ||
token === SyntaxKind.OpenBraceToken || token === SyntaxKind.DefaultKeyword || isDeclarationStart();
token === SyntaxKind.OpenBraceToken || token === SyntaxKind.DefaultKeyword || isDeclarationStart(/*followsModifier*/ true);
}
function nextTokenIsDeclarationStart() {
nextToken();
return isDeclarationStart();
return isDeclarationStart(/*followsModifier*/ true);
}
function nextTokenIsAsKeyword() {
@@ -4968,14 +5113,15 @@ module ts {
function parseDeclaration(): ModuleElement {
let fullStart = getNodePos();
let decorators = parseDecorators();
let modifiers = parseModifiers();
if (token === SyntaxKind.ExportKeyword) {
nextToken();
if (token === SyntaxKind.DefaultKeyword || token === SyntaxKind.EqualsToken) {
return parseExportAssignment(fullStart, modifiers);
return parseExportAssignment(fullStart, decorators, modifiers);
}
if (token === SyntaxKind.AsteriskToken || token === SyntaxKind.OpenBraceToken) {
return parseExportDeclaration(fullStart, modifiers);
return parseExportDeclaration(fullStart, decorators, modifiers);
}
}
@@ -4983,22 +5129,31 @@ module ts {
case SyntaxKind.VarKeyword:
case SyntaxKind.LetKeyword:
case SyntaxKind.ConstKeyword:
return parseVariableStatement(fullStart, modifiers);
return parseVariableStatement(fullStart, decorators, modifiers);
case SyntaxKind.FunctionKeyword:
return parseFunctionDeclaration(fullStart, modifiers);
return parseFunctionDeclaration(fullStart, decorators, modifiers);
case SyntaxKind.ClassKeyword:
return parseClassDeclaration(fullStart, modifiers);
return parseClassDeclaration(fullStart, decorators, modifiers);
case SyntaxKind.InterfaceKeyword:
return parseInterfaceDeclaration(fullStart, modifiers);
return parseInterfaceDeclaration(fullStart, decorators, modifiers);
case SyntaxKind.TypeKeyword:
return parseTypeAliasDeclaration(fullStart, modifiers);
return parseTypeAliasDeclaration(fullStart, decorators, modifiers);
case SyntaxKind.EnumKeyword:
return parseEnumDeclaration(fullStart, modifiers);
return parseEnumDeclaration(fullStart, decorators, modifiers);
case SyntaxKind.ModuleKeyword:
return parseModuleDeclaration(fullStart, modifiers);
return parseModuleDeclaration(fullStart, decorators, modifiers);
case SyntaxKind.ImportKeyword:
return parseImportDeclarationOrImportEqualsDeclaration(fullStart, modifiers);
return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers);
default:
if (decorators) {
// We reached this point because we encountered an AtToken and assumed a declaration would
// follow. For recovery and error reporting purposes, return an incomplete declaration.
let node = <ModuleElement>createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected);
node.pos = fullStart;
node.decorators = decorators;
setModifiers(node, modifiers);
return finishNode(node);
}
Debug.fail("Mismatch between isDeclarationStart and parseDeclaration");
}
}

View File

@@ -148,6 +148,7 @@ module ts {
"&=": SyntaxKind.AmpersandEqualsToken,
"|=": SyntaxKind.BarEqualsToken,
"^=": SyntaxKind.CaretEqualsToken,
"@": SyntaxKind.AtToken,
};
/*
@@ -1284,6 +1285,8 @@ module ts {
return pos++, token = SyntaxKind.CloseBraceToken;
case CharacterCodes.tilde:
return pos++, token = SyntaxKind.TildeToken;
case CharacterCodes.at:
return pos++, token = SyntaxKind.AtToken;
case CharacterCodes.backslash:
let cookedChar = peekUnicodeEscape();
if (cookedChar >= 0 && isIdentifierStart(cookedChar)) {

View File

@@ -67,6 +67,7 @@ module ts {
BarBarToken,
QuestionToken,
ColonToken,
AtToken,
// Assignments
EqualsToken,
PlusEqualsToken,
@@ -154,6 +155,7 @@ module ts {
// Signature elements
TypeParameter,
Parameter,
Decorator,
// TypeMember
PropertySignature,
PropertyDeclaration,
@@ -244,6 +246,7 @@ module ts {
ExportDeclaration,
NamedExports,
ExportSpecifier,
MissingDeclaration,
// Module references
ExternalModuleReference,
@@ -327,22 +330,25 @@ module ts {
// If this node was parsed in the parameters of a generator.
GeneratorParameter = 1 << 3,
// If this node was parsed as part of a decorator
Decorator = 1 << 4,
// If the parser encountered an error when parsing the code that created this node. Note
// the parser only sets this directly on the node it creates right after encountering the
// error.
ThisNodeHasError = 1 << 4,
ThisNodeHasError = 1 << 5,
// Context flags set directly by the parser.
ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | ThisNodeHasError,
ParserGeneratedFlags = StrictMode | DisallowIn | Yield | GeneratorParameter | Decorator | ThisNodeHasError,
// Context flags computed by aggregating child flags upwards.
// Used during incremental parsing to determine if this node or any of its children had an
// error. Computed only once and then cached.
ThisNodeOrAnySubNodesHasError = 1 << 5,
ThisNodeOrAnySubNodesHasError = 1 << 6,
// Used to know if we've computed data from children and cached it in this node.
HasAggregatedChildData = 1 << 6
HasAggregatedChildData = 1 << 7
}
export const enum RelationComparisonResult {
@@ -357,13 +363,14 @@ module ts {
// Specific context the parser was in when this node was created. Normally undefined.
// Only set when the parser was in some interesting context (like async/yield).
parserContextFlags?: ParserContextFlags;
modifiers?: ModifiersArray; // Array of modifiers
id?: number; // Unique id (used to look up NodeLinks)
parent?: Node; // Parent node (initialized by binding)
symbol?: Symbol; // Symbol declared by node (initialized by binding)
locals?: SymbolTable; // Locals associated with node (initialized by binding)
nextContainer?: Node; // Next container in declaration order (initialized by binding)
localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes)
decorators?: NodeArray<Decorator>; // Array of decorators (in document order)
modifiers?: ModifiersArray; // Array of modifiers
id?: number; // Unique id (used to look up NodeLinks)
parent?: Node; // Parent node (initialized by binding)
symbol?: Symbol; // Symbol declared by node (initialized by binding)
locals?: SymbolTable; // Locals associated with node (initialized by binding)
nextContainer?: Node; // Next container in declaration order (initialized by binding)
localSymbol?: Symbol; // Local symbol declared by node (initialized by binding only for exported nodes)
}
export interface NodeArray<T> extends Array<T>, TextRange {
@@ -397,6 +404,10 @@ module ts {
expression: Expression;
}
export interface Decorator extends Node {
expression: LeftHandSideExpression;
}
export interface TypeParameterDeclaration extends Declaration {
name: Identifier;
constraint?: TypeNode;
@@ -531,6 +542,14 @@ module ts {
body: Block;
}
// A merged view of get/set accessors
export interface MergedAccessorDeclarations {
getAccessor: AccessorDeclaration;
setAccessor: AccessorDeclaration;
firstAccessor: AccessorDeclaration;
secondAccessor: AccessorDeclaration;
}
export interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement {
_indexSignatureDeclarationBrand: any;
}
@@ -1337,17 +1356,18 @@ module ts {
}
export const enum NodeCheckFlags {
TypeChecked = 0x00000001, // Node has been type checked
LexicalThis = 0x00000002, // Lexical 'this' reference
CaptureThis = 0x00000004, // Lexical 'this' used in body
EmitExtends = 0x00000008, // Emit __extends
SuperInstance = 0x00000010, // Instance 'super' reference
SuperStatic = 0x00000020, // Static 'super' reference
ContextChecked = 0x00000040, // Contextual types have been assigned
TypeChecked = 0x00000001, // Node has been type checked
LexicalThis = 0x00000002, // Lexical 'this' reference
CaptureThis = 0x00000004, // Lexical 'this' used in body
EmitExtends = 0x00000008, // Emit __extends
SuperInstance = 0x00000010, // Instance 'super' reference
SuperStatic = 0x00000020, // Static 'super' reference
ContextChecked = 0x00000040, // Contextual types have been assigned
// Values for enum members have been computed, and any errors have been reported for them.
EnumValuesComputed = 0x00000080,
BlockScopedBindingInLoop = 0x00000100,
EnumValuesComputed = 0x00000080,
BlockScopedBindingInLoop = 0x00000100,
EmitDecorate = 0x00000200, // Emit __decorate
}
export interface NodeLinks {

View File

@@ -1,4 +1,4 @@
/// <reference path="types.ts" />
/// <reference path="binder.ts" />
module ts {
export interface ReferencePathMatchResult {
@@ -575,6 +575,133 @@ module ts {
return (<CallExpression>node).expression;
}
export function mergeAccessorDeclarations(declarations: NodeArray<Declaration>, accessor: AccessorDeclaration): MergedAccessorDeclarations {
let firstAccessor: AccessorDeclaration;
let secondAccessor: AccessorDeclaration;
let getAccessor: AccessorDeclaration;
let setAccessor: AccessorDeclaration;
if (hasDynamicName(accessor)) {
firstAccessor = accessor;
if (accessor.kind === SyntaxKind.GetAccessor) {
getAccessor = accessor;
}
else if (accessor.kind === SyntaxKind.SetAccessor) {
setAccessor = accessor;
}
else {
Debug.fail("Accessor has wrong kind");
}
}
else {
forEach(declarations, (member: Declaration) => {
if ((member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor)
&& (member.flags & NodeFlags.Static) === (accessor.flags & NodeFlags.Static)) {
let memberName = getPropertyNameForPropertyNameNode(member.name);
let accessorName = getPropertyNameForPropertyNameNode(accessor.name);
if (memberName === accessorName) {
if (!firstAccessor) {
firstAccessor = <AccessorDeclaration>member;
}
else if (!secondAccessor) {
secondAccessor = <AccessorDeclaration>member;
}
if (member.kind === SyntaxKind.GetAccessor && !getAccessor) {
getAccessor = <AccessorDeclaration>member;
}
if (member.kind === SyntaxKind.SetAccessor && !setAccessor) {
setAccessor = <AccessorDeclaration>member;
}
}
}
});
}
return {
firstAccessor,
secondAccessor,
getAccessor,
setAccessor
};
}
export function nodeCanBeDecorated(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
// classes are valid targets
return true;
case SyntaxKind.PropertyDeclaration:
// property declarations are valid if their parent is a class declaration.
return node.parent.kind === SyntaxKind.ClassDeclaration;
case SyntaxKind.Parameter:
// if the parameter's parent has a body and its grandparent is a class declaration, this is a valid target;
return (<FunctionLikeDeclaration>node.parent).body && node.parent.parent.kind === SyntaxKind.ClassDeclaration;
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.MethodDeclaration:
// if this method has a body and its parent is a class declaration, this is a valid target.
return (<FunctionLikeDeclaration>node).body && node.parent.kind === SyntaxKind.ClassDeclaration;
}
return false;
}
export function nodeIsDecorated(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
if (node.decorators) {
return true;
}
return false;
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.Parameter:
if (node.decorators) {
return true;
}
return false;
case SyntaxKind.GetAccessor:
if ((<FunctionLikeDeclaration>node).body && node.decorators) {
return true;
}
return false;
case SyntaxKind.MethodDeclaration:
case SyntaxKind.SetAccessor:
if ((<FunctionLikeDeclaration>node).body && node.decorators) {
return true;
}
return false;
}
return false;
}
export function childIsDecorated(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.ClassDeclaration:
return forEach((<ClassDeclaration>node).members, nodeOrChildIsDecorated);
case SyntaxKind.MethodDeclaration:
case SyntaxKind.SetAccessor:
return forEach((<FunctionLikeDeclaration>node).parameters, nodeIsDecorated);
}
return false;
}
export function nodeOrChildIsDecorated(node: Node): boolean {
return nodeIsDecorated(node) || childIsDecorated(node);
}
export function isExpression(node: Node): boolean {
switch (node.kind) {
case SyntaxKind.ThisKeyword:
@@ -814,6 +941,20 @@ module ts {
}
}
export function isClassElement(n: Node): boolean {
switch (n.kind) {
case SyntaxKind.Constructor:
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.IndexSignature:
return true;
default:
return false;
}
}
// True if the given identifier, string literal, or number literal is the name of a declaration node
export function isDeclarationName(name: Node): boolean {
if (name.kind !== SyntaxKind.Identifier && name.kind !== SyntaxKind.StringLiteral && name.kind !== SyntaxKind.NumericLiteral) {

14
src/lib/core.d.ts vendored
View File

@@ -1155,3 +1155,17 @@ interface ArrayConstructor {
}
declare var Array: ArrayConstructor;
interface TypedPropertyDescriptor<T> {
enumerable?: boolean;
configurable?: boolean;
writable?: boolean;
value?: T;
get?: () => T;
set?: (value: T) => void;
}
declare type ClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
declare type PropertyDecorator = (target: Object, propertyKey: string | symbol) => void;
declare type MethodDecorator = <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
declare type ParameterDecorator = (target: Function, propertyKey: string | symbol, parameterIndex: number) => void;

View File

@@ -419,6 +419,29 @@ module ts.formatting {
}
}
function getFirstNonDecoratorTokenOfNode(node: Node) {
if (node.modifiers && node.modifiers.length) {
return node.modifiers[0].kind;
}
switch (node.kind) {
case SyntaxKind.ClassDeclaration: return SyntaxKind.ClassKeyword;
case SyntaxKind.InterfaceDeclaration: return SyntaxKind.InterfaceKeyword;
case SyntaxKind.FunctionDeclaration: return SyntaxKind.FunctionKeyword;
case SyntaxKind.EnumDeclaration: return SyntaxKind.EnumDeclaration;
case SyntaxKind.GetAccessor: return SyntaxKind.GetKeyword;
case SyntaxKind.SetAccessor: return SyntaxKind.SetKeyword;
case SyntaxKind.MethodDeclaration:
if ((<MethodDeclaration>node).asteriskToken) {
return SyntaxKind.AsteriskToken;
}
// fall-through
case SyntaxKind.PropertyDeclaration:
case SyntaxKind.Parameter:
return (<Declaration>node).name.kind;
}
}
function getDynamicIndentation(node: Node, nodeStartLine: number, indentation: number, delta: number): DynamicIndentation {
return {
getIndentationForComment: kind => {
@@ -434,6 +457,12 @@ module ts.formatting {
return indentation;
},
getIndentationForToken: (line, kind) => {
if (nodeStartLine !== line && node.decorators) {
if (kind === getFirstNonDecoratorTokenOfNode(node)) {
// if this token is the first token following the list of decorators, we do not need to indent
return indentation;
}
}
switch (kind) {
// open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent
case SyntaxKind.OpenBraceToken:
@@ -442,6 +471,7 @@ module ts.formatting {
case SyntaxKind.CloseBracketToken:
case SyntaxKind.ElseKeyword:
case SyntaxKind.WhileKeyword:
case SyntaxKind.AtToken:
return indentation;
default:
// if token line equals to the line of containing node (this is a first token in the node) - use node indentation

View File

@@ -111,192 +111,195 @@ declare module "typescript" {
BarBarToken = 49,
QuestionToken = 50,
ColonToken = 51,
EqualsToken = 52,
PlusEqualsToken = 53,
MinusEqualsToken = 54,
AsteriskEqualsToken = 55,
SlashEqualsToken = 56,
PercentEqualsToken = 57,
LessThanLessThanEqualsToken = 58,
GreaterThanGreaterThanEqualsToken = 59,
GreaterThanGreaterThanGreaterThanEqualsToken = 60,
AmpersandEqualsToken = 61,
BarEqualsToken = 62,
CaretEqualsToken = 63,
Identifier = 64,
BreakKeyword = 65,
CaseKeyword = 66,
CatchKeyword = 67,
ClassKeyword = 68,
ConstKeyword = 69,
ContinueKeyword = 70,
DebuggerKeyword = 71,
DefaultKeyword = 72,
DeleteKeyword = 73,
DoKeyword = 74,
ElseKeyword = 75,
EnumKeyword = 76,
ExportKeyword = 77,
ExtendsKeyword = 78,
FalseKeyword = 79,
FinallyKeyword = 80,
ForKeyword = 81,
FunctionKeyword = 82,
IfKeyword = 83,
ImportKeyword = 84,
InKeyword = 85,
InstanceOfKeyword = 86,
NewKeyword = 87,
NullKeyword = 88,
ReturnKeyword = 89,
SuperKeyword = 90,
SwitchKeyword = 91,
ThisKeyword = 92,
ThrowKeyword = 93,
TrueKeyword = 94,
TryKeyword = 95,
TypeOfKeyword = 96,
VarKeyword = 97,
VoidKeyword = 98,
WhileKeyword = 99,
WithKeyword = 100,
AsKeyword = 101,
ImplementsKeyword = 102,
InterfaceKeyword = 103,
LetKeyword = 104,
PackageKeyword = 105,
PrivateKeyword = 106,
ProtectedKeyword = 107,
PublicKeyword = 108,
StaticKeyword = 109,
YieldKeyword = 110,
AnyKeyword = 111,
BooleanKeyword = 112,
ConstructorKeyword = 113,
DeclareKeyword = 114,
GetKeyword = 115,
ModuleKeyword = 116,
RequireKeyword = 117,
NumberKeyword = 118,
SetKeyword = 119,
StringKeyword = 120,
SymbolKeyword = 121,
TypeKeyword = 122,
FromKeyword = 123,
OfKeyword = 124,
QualifiedName = 125,
ComputedPropertyName = 126,
TypeParameter = 127,
Parameter = 128,
PropertySignature = 129,
PropertyDeclaration = 130,
MethodSignature = 131,
MethodDeclaration = 132,
Constructor = 133,
GetAccessor = 134,
SetAccessor = 135,
CallSignature = 136,
ConstructSignature = 137,
IndexSignature = 138,
TypeReference = 139,
FunctionType = 140,
ConstructorType = 141,
TypeQuery = 142,
TypeLiteral = 143,
ArrayType = 144,
TupleType = 145,
UnionType = 146,
ParenthesizedType = 147,
ObjectBindingPattern = 148,
ArrayBindingPattern = 149,
BindingElement = 150,
ArrayLiteralExpression = 151,
ObjectLiteralExpression = 152,
PropertyAccessExpression = 153,
ElementAccessExpression = 154,
CallExpression = 155,
NewExpression = 156,
TaggedTemplateExpression = 157,
TypeAssertionExpression = 158,
ParenthesizedExpression = 159,
FunctionExpression = 160,
ArrowFunction = 161,
DeleteExpression = 162,
TypeOfExpression = 163,
VoidExpression = 164,
PrefixUnaryExpression = 165,
PostfixUnaryExpression = 166,
BinaryExpression = 167,
ConditionalExpression = 168,
TemplateExpression = 169,
YieldExpression = 170,
SpreadElementExpression = 171,
OmittedExpression = 172,
TemplateSpan = 173,
Block = 174,
VariableStatement = 175,
EmptyStatement = 176,
ExpressionStatement = 177,
IfStatement = 178,
DoStatement = 179,
WhileStatement = 180,
ForStatement = 181,
ForInStatement = 182,
ForOfStatement = 183,
ContinueStatement = 184,
BreakStatement = 185,
ReturnStatement = 186,
WithStatement = 187,
SwitchStatement = 188,
LabeledStatement = 189,
ThrowStatement = 190,
TryStatement = 191,
DebuggerStatement = 192,
VariableDeclaration = 193,
VariableDeclarationList = 194,
FunctionDeclaration = 195,
ClassDeclaration = 196,
InterfaceDeclaration = 197,
TypeAliasDeclaration = 198,
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
CaseBlock = 202,
ImportEqualsDeclaration = 203,
ImportDeclaration = 204,
ImportClause = 205,
NamespaceImport = 206,
NamedImports = 207,
ImportSpecifier = 208,
ExportAssignment = 209,
ExportDeclaration = 210,
NamedExports = 211,
ExportSpecifier = 212,
ExternalModuleReference = 213,
CaseClause = 214,
DefaultClause = 215,
HeritageClause = 216,
CatchClause = 217,
PropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
EnumMember = 220,
SourceFile = 221,
SyntaxList = 222,
Count = 223,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
LastReservedWord = 100,
FirstKeyword = 65,
LastKeyword = 124,
FirstFutureReservedWord = 102,
LastFutureReservedWord = 110,
FirstTypeNode = 139,
LastTypeNode = 147,
AtToken = 52,
EqualsToken = 53,
PlusEqualsToken = 54,
MinusEqualsToken = 55,
AsteriskEqualsToken = 56,
SlashEqualsToken = 57,
PercentEqualsToken = 58,
LessThanLessThanEqualsToken = 59,
GreaterThanGreaterThanEqualsToken = 60,
GreaterThanGreaterThanGreaterThanEqualsToken = 61,
AmpersandEqualsToken = 62,
BarEqualsToken = 63,
CaretEqualsToken = 64,
Identifier = 65,
BreakKeyword = 66,
CaseKeyword = 67,
CatchKeyword = 68,
ClassKeyword = 69,
ConstKeyword = 70,
ContinueKeyword = 71,
DebuggerKeyword = 72,
DefaultKeyword = 73,
DeleteKeyword = 74,
DoKeyword = 75,
ElseKeyword = 76,
EnumKeyword = 77,
ExportKeyword = 78,
ExtendsKeyword = 79,
FalseKeyword = 80,
FinallyKeyword = 81,
ForKeyword = 82,
FunctionKeyword = 83,
IfKeyword = 84,
ImportKeyword = 85,
InKeyword = 86,
InstanceOfKeyword = 87,
NewKeyword = 88,
NullKeyword = 89,
ReturnKeyword = 90,
SuperKeyword = 91,
SwitchKeyword = 92,
ThisKeyword = 93,
ThrowKeyword = 94,
TrueKeyword = 95,
TryKeyword = 96,
TypeOfKeyword = 97,
VarKeyword = 98,
VoidKeyword = 99,
WhileKeyword = 100,
WithKeyword = 101,
AsKeyword = 102,
ImplementsKeyword = 103,
InterfaceKeyword = 104,
LetKeyword = 105,
PackageKeyword = 106,
PrivateKeyword = 107,
ProtectedKeyword = 108,
PublicKeyword = 109,
StaticKeyword = 110,
YieldKeyword = 111,
AnyKeyword = 112,
BooleanKeyword = 113,
ConstructorKeyword = 114,
DeclareKeyword = 115,
GetKeyword = 116,
ModuleKeyword = 117,
RequireKeyword = 118,
NumberKeyword = 119,
SetKeyword = 120,
StringKeyword = 121,
SymbolKeyword = 122,
TypeKeyword = 123,
FromKeyword = 124,
OfKeyword = 125,
QualifiedName = 126,
ComputedPropertyName = 127,
TypeParameter = 128,
Parameter = 129,
Decorator = 130,
PropertySignature = 131,
PropertyDeclaration = 132,
MethodSignature = 133,
MethodDeclaration = 134,
Constructor = 135,
GetAccessor = 136,
SetAccessor = 137,
CallSignature = 138,
ConstructSignature = 139,
IndexSignature = 140,
TypeReference = 141,
FunctionType = 142,
ConstructorType = 143,
TypeQuery = 144,
TypeLiteral = 145,
ArrayType = 146,
TupleType = 147,
UnionType = 148,
ParenthesizedType = 149,
ObjectBindingPattern = 150,
ArrayBindingPattern = 151,
BindingElement = 152,
ArrayLiteralExpression = 153,
ObjectLiteralExpression = 154,
PropertyAccessExpression = 155,
ElementAccessExpression = 156,
CallExpression = 157,
NewExpression = 158,
TaggedTemplateExpression = 159,
TypeAssertionExpression = 160,
ParenthesizedExpression = 161,
FunctionExpression = 162,
ArrowFunction = 163,
DeleteExpression = 164,
TypeOfExpression = 165,
VoidExpression = 166,
PrefixUnaryExpression = 167,
PostfixUnaryExpression = 168,
BinaryExpression = 169,
ConditionalExpression = 170,
TemplateExpression = 171,
YieldExpression = 172,
SpreadElementExpression = 173,
OmittedExpression = 174,
TemplateSpan = 175,
Block = 176,
VariableStatement = 177,
EmptyStatement = 178,
ExpressionStatement = 179,
IfStatement = 180,
DoStatement = 181,
WhileStatement = 182,
ForStatement = 183,
ForInStatement = 184,
ForOfStatement = 185,
ContinueStatement = 186,
BreakStatement = 187,
ReturnStatement = 188,
WithStatement = 189,
SwitchStatement = 190,
LabeledStatement = 191,
ThrowStatement = 192,
TryStatement = 193,
DebuggerStatement = 194,
VariableDeclaration = 195,
VariableDeclarationList = 196,
FunctionDeclaration = 197,
ClassDeclaration = 198,
InterfaceDeclaration = 199,
TypeAliasDeclaration = 200,
EnumDeclaration = 201,
ModuleDeclaration = 202,
ModuleBlock = 203,
CaseBlock = 204,
ImportEqualsDeclaration = 205,
ImportDeclaration = 206,
ImportClause = 207,
NamespaceImport = 208,
NamedImports = 209,
ImportSpecifier = 210,
ExportAssignment = 211,
ExportDeclaration = 212,
NamedExports = 213,
ExportSpecifier = 214,
MissingDeclaration = 215,
ExternalModuleReference = 216,
CaseClause = 217,
DefaultClause = 218,
HeritageClause = 219,
CatchClause = 220,
PropertyAssignment = 221,
ShorthandPropertyAssignment = 222,
EnumMember = 223,
SourceFile = 224,
SyntaxList = 225,
Count = 226,
FirstAssignment = 53,
LastAssignment = 64,
FirstReservedWord = 66,
LastReservedWord = 101,
FirstKeyword = 66,
LastKeyword = 125,
FirstFutureReservedWord = 103,
LastFutureReservedWord = 111,
FirstTypeNode = 141,
LastTypeNode = 149,
FirstPunctuation = 14,
LastPunctuation = 63,
LastPunctuation = 64,
FirstToken = 0,
LastToken = 124,
LastToken = 125,
FirstTriviaToken = 2,
LastTriviaToken = 6,
FirstLiteralToken = 7,
@@ -304,8 +307,8 @@ declare module "typescript" {
FirstTemplateToken = 10,
LastTemplateToken = 13,
FirstBinaryOperator = 24,
LastBinaryOperator = 63,
FirstNode = 125,
LastBinaryOperator = 64,
FirstNode = 126,
}
const enum NodeFlags {
Export = 1,
@@ -330,10 +333,11 @@ declare module "typescript" {
DisallowIn = 2,
Yield = 4,
GeneratorParameter = 8,
ThisNodeHasError = 16,
ParserGeneratedFlags = 31,
ThisNodeOrAnySubNodesHasError = 32,
HasAggregatedChildData = 64,
Decorator = 16,
ThisNodeHasError = 32,
ParserGeneratedFlags = 63,
ThisNodeOrAnySubNodesHasError = 64,
HasAggregatedChildData = 128,
}
const enum RelationComparisonResult {
Succeeded = 1,
@@ -344,6 +348,7 @@ declare module "typescript" {
kind: SyntaxKind;
flags: NodeFlags;
parserContextFlags?: ParserContextFlags;
decorators?: NodeArray<Decorator>;
modifiers?: ModifiersArray;
id?: number;
parent?: Node;
@@ -374,6 +379,9 @@ declare module "typescript" {
interface ComputedPropertyName extends Node {
expression: Expression;
}
interface Decorator extends Node {
expression: LeftHandSideExpression;
}
interface TypeParameterDeclaration extends Declaration {
name: Identifier;
constraint?: TypeNode;
@@ -464,6 +472,12 @@ declare module "typescript" {
_accessorDeclarationBrand: any;
body: Block;
}
interface MergedAccessorDeclarations {
getAccessor: AccessorDeclaration;
setAccessor: AccessorDeclaration;
firstAccessor: AccessorDeclaration;
secondAccessor: AccessorDeclaration;
}
interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement {
_indexSignatureDeclarationBrand: any;
}
@@ -1060,6 +1074,7 @@ declare module "typescript" {
ContextChecked = 64,
EnumValuesComputed = 128,
BlockScopedBindingInLoop = 256,
EmitDecorate = 512,
}
interface NodeLinks {
resolvedType?: Type;

View File

@@ -351,562 +351,571 @@ declare module "typescript" {
>EqualsGreaterThanToken : SyntaxKind
PlusToken = 33,
PlusToken = 33,
>PlusToken : SyntaxKind
MinusToken = 34,
>MinusToken : SyntaxKind
AsteriskToken = 35,
>MinusToken : SyntaxKind
>AsteriskToken : SyntaxKind
SlashToken = 36,
>SlashToken : SyntaxKind
SlashToken = 36,
PercentToken = 37,
>PercentToken : SyntaxKind
PlusPlusToken = 38,
>PercentToken : SyntaxKind
>PlusPlusToken : SyntaxKind
MinusMinusToken = 39,
>MinusMinusToken : SyntaxKind
MinusMinusToken = 39,
LessThanLessThanToken = 40,
>LessThanLessThanToken : SyntaxKind
GreaterThanGreaterThanToken = 41,
>LessThanLessThanToken : SyntaxKind
>GreaterThanGreaterThanToken : SyntaxKind
GreaterThanGreaterThanGreaterThanToken = 42,
>GreaterThanGreaterThanGreaterThanToken : SyntaxKind
GreaterThanGreaterThanGreaterThanToken = 42,
AmpersandToken = 43,
>AmpersandToken : SyntaxKind
BarToken = 44,
>AmpersandToken : SyntaxKind
>BarToken : SyntaxKind
CaretToken = 45,
>CaretToken : SyntaxKind
CaretToken = 45,
ExclamationToken = 46,
>ExclamationToken : SyntaxKind
TildeToken = 47,
>ExclamationToken : SyntaxKind
>TildeToken : SyntaxKind
AmpersandAmpersandToken = 48,
>AmpersandAmpersandToken : SyntaxKind
AmpersandAmpersandToken = 48,
BarBarToken = 49,
>BarBarToken : SyntaxKind
QuestionToken = 50,
>BarBarToken : SyntaxKind
>QuestionToken : SyntaxKind
ColonToken = 51,
>ColonToken : SyntaxKind
ColonToken = 51,
AtToken = 52,
>AtToken : SyntaxKind
EqualsToken = 53,
>EqualsToken : SyntaxKind
>EqualsToken : SyntaxKind
PlusEqualsToken = 54,
>PlusEqualsToken : SyntaxKind
MinusEqualsToken = 54,
MinusEqualsToken = 55,
>MinusEqualsToken : SyntaxKind
AsteriskEqualsToken = 56,
>AsteriskEqualsToken : SyntaxKind
>AsteriskEqualsToken : SyntaxKind
SlashEqualsToken = 57,
>SlashEqualsToken : SyntaxKind
PercentEqualsToken = 57,
PercentEqualsToken = 58,
>PercentEqualsToken : SyntaxKind
LessThanLessThanEqualsToken = 59,
>LessThanLessThanEqualsToken : SyntaxKind
>LessThanLessThanEqualsToken : SyntaxKind
GreaterThanGreaterThanEqualsToken = 60,
>GreaterThanGreaterThanEqualsToken : SyntaxKind
GreaterThanGreaterThanGreaterThanEqualsToken = 60,
GreaterThanGreaterThanGreaterThanEqualsToken = 61,
>GreaterThanGreaterThanGreaterThanEqualsToken : SyntaxKind
AmpersandEqualsToken = 62,
>AmpersandEqualsToken : SyntaxKind
>AmpersandEqualsToken : SyntaxKind
BarEqualsToken = 63,
>BarEqualsToken : SyntaxKind
CaretEqualsToken = 63,
CaretEqualsToken = 64,
>CaretEqualsToken : SyntaxKind
Identifier = 65,
>Identifier : SyntaxKind
>Identifier : SyntaxKind
BreakKeyword = 66,
>BreakKeyword : SyntaxKind
CaseKeyword = 66,
CaseKeyword = 67,
>CaseKeyword : SyntaxKind
CatchKeyword = 68,
>CatchKeyword : SyntaxKind
>CatchKeyword : SyntaxKind
ClassKeyword = 69,
>ClassKeyword : SyntaxKind
ConstKeyword = 69,
ConstKeyword = 70,
>ConstKeyword : SyntaxKind
ContinueKeyword = 71,
>ContinueKeyword : SyntaxKind
>ContinueKeyword : SyntaxKind
DebuggerKeyword = 72,
>DebuggerKeyword : SyntaxKind
DefaultKeyword = 72,
DefaultKeyword = 73,
>DefaultKeyword : SyntaxKind
DeleteKeyword = 74,
>DeleteKeyword : SyntaxKind
>DeleteKeyword : SyntaxKind
DoKeyword = 75,
>DoKeyword : SyntaxKind
ElseKeyword = 75,
ElseKeyword = 76,
>ElseKeyword : SyntaxKind
EnumKeyword = 77,
>EnumKeyword : SyntaxKind
>EnumKeyword : SyntaxKind
ExportKeyword = 78,
>ExportKeyword : SyntaxKind
ExtendsKeyword = 78,
ExtendsKeyword = 79,
>ExtendsKeyword : SyntaxKind
FalseKeyword = 80,
>FalseKeyword : SyntaxKind
>FalseKeyword : SyntaxKind
FinallyKeyword = 81,
>FinallyKeyword : SyntaxKind
ForKeyword = 81,
ForKeyword = 82,
>ForKeyword : SyntaxKind
FunctionKeyword = 83,
>FunctionKeyword : SyntaxKind
>FunctionKeyword : SyntaxKind
IfKeyword = 84,
>IfKeyword : SyntaxKind
ImportKeyword = 84,
ImportKeyword = 85,
>ImportKeyword : SyntaxKind
InKeyword = 86,
>InKeyword : SyntaxKind
>InKeyword : SyntaxKind
InstanceOfKeyword = 87,
>InstanceOfKeyword : SyntaxKind
NewKeyword = 87,
NewKeyword = 88,
>NewKeyword : SyntaxKind
NullKeyword = 89,
>NullKeyword : SyntaxKind
>NullKeyword : SyntaxKind
ReturnKeyword = 90,
>ReturnKeyword : SyntaxKind
SuperKeyword = 90,
SuperKeyword = 91,
>SuperKeyword : SyntaxKind
SwitchKeyword = 92,
>SwitchKeyword : SyntaxKind
>SwitchKeyword : SyntaxKind
ThisKeyword = 93,
>ThisKeyword : SyntaxKind
ThrowKeyword = 94,
ThrowKeyword = 93,
>ThrowKeyword : SyntaxKind
TrueKeyword = 95,
>TrueKeyword : SyntaxKind
>TrueKeyword : SyntaxKind
TryKeyword = 96,
>TryKeyword : SyntaxKind
TypeOfKeyword = 97,
TypeOfKeyword = 96,
>TypeOfKeyword : SyntaxKind
VarKeyword = 98,
>VarKeyword : SyntaxKind
>VarKeyword : SyntaxKind
VoidKeyword = 99,
>VoidKeyword : SyntaxKind
WhileKeyword = 100,
WhileKeyword = 99,
>WhileKeyword : SyntaxKind
WithKeyword = 101,
>WithKeyword : SyntaxKind
>WithKeyword : SyntaxKind
AsKeyword = 102,
>AsKeyword : SyntaxKind
ImplementsKeyword = 103,
ImplementsKeyword = 102,
>ImplementsKeyword : SyntaxKind
InterfaceKeyword = 104,
>InterfaceKeyword : SyntaxKind
>InterfaceKeyword : SyntaxKind
LetKeyword = 105,
>LetKeyword : SyntaxKind
PackageKeyword = 106,
PackageKeyword = 105,
>PackageKeyword : SyntaxKind
PrivateKeyword = 107,
>PrivateKeyword : SyntaxKind
>PrivateKeyword : SyntaxKind
ProtectedKeyword = 108,
>ProtectedKeyword : SyntaxKind
PublicKeyword = 109,
PublicKeyword = 108,
>PublicKeyword : SyntaxKind
StaticKeyword = 110,
>StaticKeyword : SyntaxKind
>StaticKeyword : SyntaxKind
YieldKeyword = 111,
>YieldKeyword : SyntaxKind
AnyKeyword = 112,
AnyKeyword = 111,
>AnyKeyword : SyntaxKind
BooleanKeyword = 113,
>BooleanKeyword : SyntaxKind
>BooleanKeyword : SyntaxKind
ConstructorKeyword = 114,
>ConstructorKeyword : SyntaxKind
DeclareKeyword = 115,
DeclareKeyword = 114,
>DeclareKeyword : SyntaxKind
GetKeyword = 116,
>GetKeyword : SyntaxKind
>GetKeyword : SyntaxKind
ModuleKeyword = 117,
>ModuleKeyword : SyntaxKind
RequireKeyword = 118,
RequireKeyword = 117,
>RequireKeyword : SyntaxKind
NumberKeyword = 119,
>NumberKeyword : SyntaxKind
>NumberKeyword : SyntaxKind
SetKeyword = 120,
>SetKeyword : SyntaxKind
StringKeyword = 121,
StringKeyword = 120,
>StringKeyword : SyntaxKind
SymbolKeyword = 122,
>SymbolKeyword : SyntaxKind
>SymbolKeyword : SyntaxKind
TypeKeyword = 123,
>TypeKeyword : SyntaxKind
FromKeyword = 124,
FromKeyword = 123,
>FromKeyword : SyntaxKind
OfKeyword = 125,
>OfKeyword : SyntaxKind
>OfKeyword : SyntaxKind
QualifiedName = 126,
>QualifiedName : SyntaxKind
ComputedPropertyName = 127,
ComputedPropertyName = 126,
>ComputedPropertyName : SyntaxKind
TypeParameter = 128,
>TypeParameter : SyntaxKind
>TypeParameter : SyntaxKind
Parameter = 129,
>Parameter : SyntaxKind
Decorator = 130,
PropertySignature = 129,
>Decorator : SyntaxKind
PropertySignature = 131,
>PropertySignature : SyntaxKind
>PropertyDeclaration : SyntaxKind
PropertyDeclaration = 132,
>PropertyDeclaration : SyntaxKind
MethodSignature = 133,
MethodDeclaration = 132,
>MethodSignature : SyntaxKind
MethodDeclaration = 134,
>MethodDeclaration : SyntaxKind
>Constructor : SyntaxKind
Constructor = 135,
>Constructor : SyntaxKind
GetAccessor = 136,
SetAccessor = 135,
>GetAccessor : SyntaxKind
SetAccessor = 137,
>SetAccessor : SyntaxKind
>CallSignature : SyntaxKind
CallSignature = 138,
>CallSignature : SyntaxKind
ConstructSignature = 139,
IndexSignature = 138,
>ConstructSignature : SyntaxKind
IndexSignature = 140,
>IndexSignature : SyntaxKind
>TypeReference : SyntaxKind
TypeReference = 141,
>TypeReference : SyntaxKind
FunctionType = 142,
ConstructorType = 141,
>FunctionType : SyntaxKind
ConstructorType = 143,
>ConstructorType : SyntaxKind
>TypeQuery : SyntaxKind
TypeQuery = 144,
>TypeQuery : SyntaxKind
TypeLiteral = 145,
ArrayType = 144,
>TypeLiteral : SyntaxKind
ArrayType = 146,
>ArrayType : SyntaxKind
>TupleType : SyntaxKind
TupleType = 147,
>TupleType : SyntaxKind
UnionType = 148,
ParenthesizedType = 147,
>UnionType : SyntaxKind
ParenthesizedType = 149,
>ParenthesizedType : SyntaxKind
>ObjectBindingPattern : SyntaxKind
ObjectBindingPattern = 150,
>ObjectBindingPattern : SyntaxKind
ArrayBindingPattern = 151,
BindingElement = 150,
>ArrayBindingPattern : SyntaxKind
BindingElement = 152,
>BindingElement : SyntaxKind
>ArrayLiteralExpression : SyntaxKind
ArrayLiteralExpression = 153,
>ArrayLiteralExpression : SyntaxKind
ObjectLiteralExpression = 154,
PropertyAccessExpression = 153,
>ObjectLiteralExpression : SyntaxKind
PropertyAccessExpression = 155,
>PropertyAccessExpression : SyntaxKind
ElementAccessExpression = 156,
>ElementAccessExpression : SyntaxKind
>ElementAccessExpression : SyntaxKind
CallExpression = 157,
>CallExpression : SyntaxKind
NewExpression = 158,
NewExpression = 156,
>NewExpression : SyntaxKind
TaggedTemplateExpression = 159,
>TaggedTemplateExpression : SyntaxKind
>TaggedTemplateExpression : SyntaxKind
TypeAssertionExpression = 160,
>TypeAssertionExpression : SyntaxKind
ParenthesizedExpression = 161,
ParenthesizedExpression = 159,
>ParenthesizedExpression : SyntaxKind
FunctionExpression = 162,
>FunctionExpression : SyntaxKind
>FunctionExpression : SyntaxKind
ArrowFunction = 163,
>ArrowFunction : SyntaxKind
DeleteExpression = 164,
DeleteExpression = 162,
>DeleteExpression : SyntaxKind
TypeOfExpression = 165,
>TypeOfExpression : SyntaxKind
>TypeOfExpression : SyntaxKind
VoidExpression = 166,
>VoidExpression : SyntaxKind
PrefixUnaryExpression = 167,
PrefixUnaryExpression = 165,
>PrefixUnaryExpression : SyntaxKind
PostfixUnaryExpression = 168,
>PostfixUnaryExpression : SyntaxKind
>PostfixUnaryExpression : SyntaxKind
BinaryExpression = 169,
>BinaryExpression : SyntaxKind
ConditionalExpression = 170,
ConditionalExpression = 168,
>ConditionalExpression : SyntaxKind
TemplateExpression = 171,
>TemplateExpression : SyntaxKind
YieldExpression = 172,
>YieldExpression : SyntaxKind
SpreadElementExpression = 173,
>SpreadElementExpression : SyntaxKind
OmittedExpression = 174,
>OmittedExpression : SyntaxKind
@@ -930,10 +939,10 @@ declare module "typescript" {
>ExpressionStatement : SyntaxKind
IfStatement = 180,
>IfStatement : SyntaxKind
>IfStatement : SyntaxKind
DoStatement = 181,
>DoStatement : SyntaxKind
@@ -1002,16 +1011,19 @@ declare module "typescript" {
>FunctionDeclaration : SyntaxKind
ClassDeclaration = 198,
>ClassDeclaration : SyntaxKind
InterfaceDeclaration = 199,
>ClassDeclaration : SyntaxKind
>InterfaceDeclaration : SyntaxKind
TypeAliasDeclaration = 200,
>TypeAliasDeclaration : SyntaxKind
TypeAliasDeclaration = 198,
EnumDeclaration = 201,
>EnumDeclaration : SyntaxKind
@@ -1042,6 +1054,11 @@ declare module "typescript" {
NamespaceImport = 208,
>NamespaceImport : SyntaxKind
NamedImports = 209,
>NamedImports : SyntaxKind
ImportSpecifier = 210,
>ImportSpecifier : SyntaxKind
@@ -1136,6 +1153,14 @@ declare module "typescript" {
FirstFutureReservedWord = 103,
>FirstFutureReservedWord : SyntaxKind
LastFutureReservedWord = 111,
>LastFutureReservedWord : SyntaxKind
FirstTypeNode = 141,
>FirstTypeNode : SyntaxKind
LastTypeNode = 149,
@@ -1415,6 +1440,25 @@ declare module "typescript" {
text: string;
>text : string
}
interface QualifiedName extends Node {
>QualifiedName : QualifiedName
>Node : Node
left: EntityName;
>left : Identifier | QualifiedName
>EntityName : Identifier | QualifiedName
right: Identifier;
>right : Identifier
>Identifier : Identifier
}
type EntityName = Identifier | QualifiedName;
>EntityName : Identifier | QualifiedName
>Identifier : Identifier
@@ -3434,6 +3478,9 @@ declare module "typescript" {
getPropertiesOfType(type: Type): Symbol[];
>getPropertiesOfType : (type: Type) => Symbol[]
>type : Type
>Type : Type
>Symbol : Symbol
getPropertyOfType(type: Type, propertyName: string): Symbol;

View File

@@ -142,192 +142,195 @@ declare module "typescript" {
BarBarToken = 49,
QuestionToken = 50,
ColonToken = 51,
EqualsToken = 52,
PlusEqualsToken = 53,
MinusEqualsToken = 54,
AsteriskEqualsToken = 55,
SlashEqualsToken = 56,
PercentEqualsToken = 57,
LessThanLessThanEqualsToken = 58,
GreaterThanGreaterThanEqualsToken = 59,
GreaterThanGreaterThanGreaterThanEqualsToken = 60,
AmpersandEqualsToken = 61,
BarEqualsToken = 62,
CaretEqualsToken = 63,
Identifier = 64,
BreakKeyword = 65,
CaseKeyword = 66,
CatchKeyword = 67,
ClassKeyword = 68,
ConstKeyword = 69,
ContinueKeyword = 70,
DebuggerKeyword = 71,
DefaultKeyword = 72,
DeleteKeyword = 73,
DoKeyword = 74,
ElseKeyword = 75,
EnumKeyword = 76,
ExportKeyword = 77,
ExtendsKeyword = 78,
FalseKeyword = 79,
FinallyKeyword = 80,
ForKeyword = 81,
FunctionKeyword = 82,
IfKeyword = 83,
ImportKeyword = 84,
InKeyword = 85,
InstanceOfKeyword = 86,
NewKeyword = 87,
NullKeyword = 88,
ReturnKeyword = 89,
SuperKeyword = 90,
SwitchKeyword = 91,
ThisKeyword = 92,
ThrowKeyword = 93,
TrueKeyword = 94,
TryKeyword = 95,
TypeOfKeyword = 96,
VarKeyword = 97,
VoidKeyword = 98,
WhileKeyword = 99,
WithKeyword = 100,
AsKeyword = 101,
ImplementsKeyword = 102,
InterfaceKeyword = 103,
LetKeyword = 104,
PackageKeyword = 105,
PrivateKeyword = 106,
ProtectedKeyword = 107,
PublicKeyword = 108,
StaticKeyword = 109,
YieldKeyword = 110,
AnyKeyword = 111,
BooleanKeyword = 112,
ConstructorKeyword = 113,
DeclareKeyword = 114,
GetKeyword = 115,
ModuleKeyword = 116,
RequireKeyword = 117,
NumberKeyword = 118,
SetKeyword = 119,
StringKeyword = 120,
SymbolKeyword = 121,
TypeKeyword = 122,
FromKeyword = 123,
OfKeyword = 124,
QualifiedName = 125,
ComputedPropertyName = 126,
TypeParameter = 127,
Parameter = 128,
PropertySignature = 129,
PropertyDeclaration = 130,
MethodSignature = 131,
MethodDeclaration = 132,
Constructor = 133,
GetAccessor = 134,
SetAccessor = 135,
CallSignature = 136,
ConstructSignature = 137,
IndexSignature = 138,
TypeReference = 139,
FunctionType = 140,
ConstructorType = 141,
TypeQuery = 142,
TypeLiteral = 143,
ArrayType = 144,
TupleType = 145,
UnionType = 146,
ParenthesizedType = 147,
ObjectBindingPattern = 148,
ArrayBindingPattern = 149,
BindingElement = 150,
ArrayLiteralExpression = 151,
ObjectLiteralExpression = 152,
PropertyAccessExpression = 153,
ElementAccessExpression = 154,
CallExpression = 155,
NewExpression = 156,
TaggedTemplateExpression = 157,
TypeAssertionExpression = 158,
ParenthesizedExpression = 159,
FunctionExpression = 160,
ArrowFunction = 161,
DeleteExpression = 162,
TypeOfExpression = 163,
VoidExpression = 164,
PrefixUnaryExpression = 165,
PostfixUnaryExpression = 166,
BinaryExpression = 167,
ConditionalExpression = 168,
TemplateExpression = 169,
YieldExpression = 170,
SpreadElementExpression = 171,
OmittedExpression = 172,
TemplateSpan = 173,
Block = 174,
VariableStatement = 175,
EmptyStatement = 176,
ExpressionStatement = 177,
IfStatement = 178,
DoStatement = 179,
WhileStatement = 180,
ForStatement = 181,
ForInStatement = 182,
ForOfStatement = 183,
ContinueStatement = 184,
BreakStatement = 185,
ReturnStatement = 186,
WithStatement = 187,
SwitchStatement = 188,
LabeledStatement = 189,
ThrowStatement = 190,
TryStatement = 191,
DebuggerStatement = 192,
VariableDeclaration = 193,
VariableDeclarationList = 194,
FunctionDeclaration = 195,
ClassDeclaration = 196,
InterfaceDeclaration = 197,
TypeAliasDeclaration = 198,
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
CaseBlock = 202,
ImportEqualsDeclaration = 203,
ImportDeclaration = 204,
ImportClause = 205,
NamespaceImport = 206,
NamedImports = 207,
ImportSpecifier = 208,
ExportAssignment = 209,
ExportDeclaration = 210,
NamedExports = 211,
ExportSpecifier = 212,
ExternalModuleReference = 213,
CaseClause = 214,
DefaultClause = 215,
HeritageClause = 216,
CatchClause = 217,
PropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
EnumMember = 220,
SourceFile = 221,
SyntaxList = 222,
Count = 223,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
LastReservedWord = 100,
FirstKeyword = 65,
LastKeyword = 124,
FirstFutureReservedWord = 102,
LastFutureReservedWord = 110,
FirstTypeNode = 139,
LastTypeNode = 147,
AtToken = 52,
EqualsToken = 53,
PlusEqualsToken = 54,
MinusEqualsToken = 55,
AsteriskEqualsToken = 56,
SlashEqualsToken = 57,
PercentEqualsToken = 58,
LessThanLessThanEqualsToken = 59,
GreaterThanGreaterThanEqualsToken = 60,
GreaterThanGreaterThanGreaterThanEqualsToken = 61,
AmpersandEqualsToken = 62,
BarEqualsToken = 63,
CaretEqualsToken = 64,
Identifier = 65,
BreakKeyword = 66,
CaseKeyword = 67,
CatchKeyword = 68,
ClassKeyword = 69,
ConstKeyword = 70,
ContinueKeyword = 71,
DebuggerKeyword = 72,
DefaultKeyword = 73,
DeleteKeyword = 74,
DoKeyword = 75,
ElseKeyword = 76,
EnumKeyword = 77,
ExportKeyword = 78,
ExtendsKeyword = 79,
FalseKeyword = 80,
FinallyKeyword = 81,
ForKeyword = 82,
FunctionKeyword = 83,
IfKeyword = 84,
ImportKeyword = 85,
InKeyword = 86,
InstanceOfKeyword = 87,
NewKeyword = 88,
NullKeyword = 89,
ReturnKeyword = 90,
SuperKeyword = 91,
SwitchKeyword = 92,
ThisKeyword = 93,
ThrowKeyword = 94,
TrueKeyword = 95,
TryKeyword = 96,
TypeOfKeyword = 97,
VarKeyword = 98,
VoidKeyword = 99,
WhileKeyword = 100,
WithKeyword = 101,
AsKeyword = 102,
ImplementsKeyword = 103,
InterfaceKeyword = 104,
LetKeyword = 105,
PackageKeyword = 106,
PrivateKeyword = 107,
ProtectedKeyword = 108,
PublicKeyword = 109,
StaticKeyword = 110,
YieldKeyword = 111,
AnyKeyword = 112,
BooleanKeyword = 113,
ConstructorKeyword = 114,
DeclareKeyword = 115,
GetKeyword = 116,
ModuleKeyword = 117,
RequireKeyword = 118,
NumberKeyword = 119,
SetKeyword = 120,
StringKeyword = 121,
SymbolKeyword = 122,
TypeKeyword = 123,
FromKeyword = 124,
OfKeyword = 125,
QualifiedName = 126,
ComputedPropertyName = 127,
TypeParameter = 128,
Parameter = 129,
Decorator = 130,
PropertySignature = 131,
PropertyDeclaration = 132,
MethodSignature = 133,
MethodDeclaration = 134,
Constructor = 135,
GetAccessor = 136,
SetAccessor = 137,
CallSignature = 138,
ConstructSignature = 139,
IndexSignature = 140,
TypeReference = 141,
FunctionType = 142,
ConstructorType = 143,
TypeQuery = 144,
TypeLiteral = 145,
ArrayType = 146,
TupleType = 147,
UnionType = 148,
ParenthesizedType = 149,
ObjectBindingPattern = 150,
ArrayBindingPattern = 151,
BindingElement = 152,
ArrayLiteralExpression = 153,
ObjectLiteralExpression = 154,
PropertyAccessExpression = 155,
ElementAccessExpression = 156,
CallExpression = 157,
NewExpression = 158,
TaggedTemplateExpression = 159,
TypeAssertionExpression = 160,
ParenthesizedExpression = 161,
FunctionExpression = 162,
ArrowFunction = 163,
DeleteExpression = 164,
TypeOfExpression = 165,
VoidExpression = 166,
PrefixUnaryExpression = 167,
PostfixUnaryExpression = 168,
BinaryExpression = 169,
ConditionalExpression = 170,
TemplateExpression = 171,
YieldExpression = 172,
SpreadElementExpression = 173,
OmittedExpression = 174,
TemplateSpan = 175,
Block = 176,
VariableStatement = 177,
EmptyStatement = 178,
ExpressionStatement = 179,
IfStatement = 180,
DoStatement = 181,
WhileStatement = 182,
ForStatement = 183,
ForInStatement = 184,
ForOfStatement = 185,
ContinueStatement = 186,
BreakStatement = 187,
ReturnStatement = 188,
WithStatement = 189,
SwitchStatement = 190,
LabeledStatement = 191,
ThrowStatement = 192,
TryStatement = 193,
DebuggerStatement = 194,
VariableDeclaration = 195,
VariableDeclarationList = 196,
FunctionDeclaration = 197,
ClassDeclaration = 198,
InterfaceDeclaration = 199,
TypeAliasDeclaration = 200,
EnumDeclaration = 201,
ModuleDeclaration = 202,
ModuleBlock = 203,
CaseBlock = 204,
ImportEqualsDeclaration = 205,
ImportDeclaration = 206,
ImportClause = 207,
NamespaceImport = 208,
NamedImports = 209,
ImportSpecifier = 210,
ExportAssignment = 211,
ExportDeclaration = 212,
NamedExports = 213,
ExportSpecifier = 214,
MissingDeclaration = 215,
ExternalModuleReference = 216,
CaseClause = 217,
DefaultClause = 218,
HeritageClause = 219,
CatchClause = 220,
PropertyAssignment = 221,
ShorthandPropertyAssignment = 222,
EnumMember = 223,
SourceFile = 224,
SyntaxList = 225,
Count = 226,
FirstAssignment = 53,
LastAssignment = 64,
FirstReservedWord = 66,
LastReservedWord = 101,
FirstKeyword = 66,
LastKeyword = 125,
FirstFutureReservedWord = 103,
LastFutureReservedWord = 111,
FirstTypeNode = 141,
LastTypeNode = 149,
FirstPunctuation = 14,
LastPunctuation = 63,
LastPunctuation = 64,
FirstToken = 0,
LastToken = 124,
LastToken = 125,
FirstTriviaToken = 2,
LastTriviaToken = 6,
FirstLiteralToken = 7,
@@ -335,8 +338,8 @@ declare module "typescript" {
FirstTemplateToken = 10,
LastTemplateToken = 13,
FirstBinaryOperator = 24,
LastBinaryOperator = 63,
FirstNode = 125,
LastBinaryOperator = 64,
FirstNode = 126,
}
const enum NodeFlags {
Export = 1,
@@ -361,10 +364,11 @@ declare module "typescript" {
DisallowIn = 2,
Yield = 4,
GeneratorParameter = 8,
ThisNodeHasError = 16,
ParserGeneratedFlags = 31,
ThisNodeOrAnySubNodesHasError = 32,
HasAggregatedChildData = 64,
Decorator = 16,
ThisNodeHasError = 32,
ParserGeneratedFlags = 63,
ThisNodeOrAnySubNodesHasError = 64,
HasAggregatedChildData = 128,
}
const enum RelationComparisonResult {
Succeeded = 1,
@@ -375,6 +379,7 @@ declare module "typescript" {
kind: SyntaxKind;
flags: NodeFlags;
parserContextFlags?: ParserContextFlags;
decorators?: NodeArray<Decorator>;
modifiers?: ModifiersArray;
id?: number;
parent?: Node;
@@ -405,6 +410,9 @@ declare module "typescript" {
interface ComputedPropertyName extends Node {
expression: Expression;
}
interface Decorator extends Node {
expression: LeftHandSideExpression;
}
interface TypeParameterDeclaration extends Declaration {
name: Identifier;
constraint?: TypeNode;
@@ -495,6 +503,12 @@ declare module "typescript" {
_accessorDeclarationBrand: any;
body: Block;
}
interface MergedAccessorDeclarations {
getAccessor: AccessorDeclaration;
setAccessor: AccessorDeclaration;
firstAccessor: AccessorDeclaration;
secondAccessor: AccessorDeclaration;
}
interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement {
_indexSignatureDeclarationBrand: any;
}
@@ -1091,6 +1105,7 @@ declare module "typescript" {
ContextChecked = 64,
EnumValuesComputed = 128,
BlockScopedBindingInLoop = 256,
EmitDecorate = 512,
}
interface NodeLinks {
resolvedType?: Type;
@@ -2032,24 +2047,24 @@ function delint(sourceFile) {
delintNode(sourceFile);
function delintNode(node) {
switch (node.kind) {
case 181 /* ForStatement */:
case 182 /* ForInStatement */:
case 180 /* WhileStatement */:
case 179 /* DoStatement */:
if (node.statement.kind !== 174 /* Block */) {
case 183 /* ForStatement */:
case 184 /* ForInStatement */:
case 182 /* WhileStatement */:
case 181 /* DoStatement */:
if (node.statement.kind !== 176 /* Block */) {
report(node, "A looping statement's contents should be wrapped in a block body.");
}
break;
case 178 /* IfStatement */:
case 180 /* IfStatement */:
var ifStatement = node;
if (ifStatement.thenStatement.kind !== 174 /* Block */) {
if (ifStatement.thenStatement.kind !== 176 /* Block */) {
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
}
if (ifStatement.elseStatement && ifStatement.elseStatement.kind !== 174 /* Block */ && ifStatement.elseStatement.kind !== 178 /* IfStatement */) {
if (ifStatement.elseStatement && ifStatement.elseStatement.kind !== 176 /* Block */ && ifStatement.elseStatement.kind !== 180 /* IfStatement */) {
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
}
break;
case 167 /* BinaryExpression */:
case 169 /* BinaryExpression */:
var op = node.operatorToken.kind;
if (op === 28 /* EqualsEqualsToken */ || op === 29 /* ExclamationEqualsToken */) {
report(node, "Use '===' and '!=='.");

View File

@@ -497,562 +497,571 @@ declare module "typescript" {
>EqualsGreaterThanToken : SyntaxKind
PlusToken = 33,
PlusToken = 33,
>PlusToken : SyntaxKind
MinusToken = 34,
>MinusToken : SyntaxKind
AsteriskToken = 35,
>MinusToken : SyntaxKind
>AsteriskToken : SyntaxKind
SlashToken = 36,
>SlashToken : SyntaxKind
SlashToken = 36,
PercentToken = 37,
>PercentToken : SyntaxKind
PlusPlusToken = 38,
>PercentToken : SyntaxKind
>PlusPlusToken : SyntaxKind
MinusMinusToken = 39,
>MinusMinusToken : SyntaxKind
MinusMinusToken = 39,
LessThanLessThanToken = 40,
>LessThanLessThanToken : SyntaxKind
GreaterThanGreaterThanToken = 41,
>LessThanLessThanToken : SyntaxKind
>GreaterThanGreaterThanToken : SyntaxKind
GreaterThanGreaterThanGreaterThanToken = 42,
>GreaterThanGreaterThanGreaterThanToken : SyntaxKind
GreaterThanGreaterThanGreaterThanToken = 42,
AmpersandToken = 43,
>AmpersandToken : SyntaxKind
BarToken = 44,
>AmpersandToken : SyntaxKind
>BarToken : SyntaxKind
CaretToken = 45,
>CaretToken : SyntaxKind
CaretToken = 45,
ExclamationToken = 46,
>ExclamationToken : SyntaxKind
TildeToken = 47,
>ExclamationToken : SyntaxKind
>TildeToken : SyntaxKind
AmpersandAmpersandToken = 48,
>AmpersandAmpersandToken : SyntaxKind
AmpersandAmpersandToken = 48,
BarBarToken = 49,
>BarBarToken : SyntaxKind
QuestionToken = 50,
>BarBarToken : SyntaxKind
>QuestionToken : SyntaxKind
ColonToken = 51,
>ColonToken : SyntaxKind
ColonToken = 51,
AtToken = 52,
>AtToken : SyntaxKind
EqualsToken = 53,
>EqualsToken : SyntaxKind
>EqualsToken : SyntaxKind
PlusEqualsToken = 54,
>PlusEqualsToken : SyntaxKind
MinusEqualsToken = 54,
MinusEqualsToken = 55,
>MinusEqualsToken : SyntaxKind
AsteriskEqualsToken = 56,
>AsteriskEqualsToken : SyntaxKind
>AsteriskEqualsToken : SyntaxKind
SlashEqualsToken = 57,
>SlashEqualsToken : SyntaxKind
PercentEqualsToken = 57,
PercentEqualsToken = 58,
>PercentEqualsToken : SyntaxKind
LessThanLessThanEqualsToken = 59,
>LessThanLessThanEqualsToken : SyntaxKind
>LessThanLessThanEqualsToken : SyntaxKind
GreaterThanGreaterThanEqualsToken = 60,
>GreaterThanGreaterThanEqualsToken : SyntaxKind
GreaterThanGreaterThanGreaterThanEqualsToken = 60,
GreaterThanGreaterThanGreaterThanEqualsToken = 61,
>GreaterThanGreaterThanGreaterThanEqualsToken : SyntaxKind
AmpersandEqualsToken = 62,
>AmpersandEqualsToken : SyntaxKind
>AmpersandEqualsToken : SyntaxKind
BarEqualsToken = 63,
>BarEqualsToken : SyntaxKind
CaretEqualsToken = 63,
CaretEqualsToken = 64,
>CaretEqualsToken : SyntaxKind
Identifier = 65,
>Identifier : SyntaxKind
>Identifier : SyntaxKind
BreakKeyword = 66,
>BreakKeyword : SyntaxKind
CaseKeyword = 66,
CaseKeyword = 67,
>CaseKeyword : SyntaxKind
CatchKeyword = 68,
>CatchKeyword : SyntaxKind
>CatchKeyword : SyntaxKind
ClassKeyword = 69,
>ClassKeyword : SyntaxKind
ConstKeyword = 69,
ConstKeyword = 70,
>ConstKeyword : SyntaxKind
ContinueKeyword = 71,
>ContinueKeyword : SyntaxKind
>ContinueKeyword : SyntaxKind
DebuggerKeyword = 72,
>DebuggerKeyword : SyntaxKind
DefaultKeyword = 72,
DefaultKeyword = 73,
>DefaultKeyword : SyntaxKind
DeleteKeyword = 74,
>DeleteKeyword : SyntaxKind
>DeleteKeyword : SyntaxKind
DoKeyword = 75,
>DoKeyword : SyntaxKind
ElseKeyword = 75,
ElseKeyword = 76,
>ElseKeyword : SyntaxKind
EnumKeyword = 77,
>EnumKeyword : SyntaxKind
>EnumKeyword : SyntaxKind
ExportKeyword = 78,
>ExportKeyword : SyntaxKind
ExtendsKeyword = 78,
ExtendsKeyword = 79,
>ExtendsKeyword : SyntaxKind
FalseKeyword = 80,
>FalseKeyword : SyntaxKind
>FalseKeyword : SyntaxKind
FinallyKeyword = 81,
>FinallyKeyword : SyntaxKind
ForKeyword = 81,
ForKeyword = 82,
>ForKeyword : SyntaxKind
FunctionKeyword = 83,
>FunctionKeyword : SyntaxKind
>FunctionKeyword : SyntaxKind
IfKeyword = 84,
>IfKeyword : SyntaxKind
ImportKeyword = 84,
ImportKeyword = 85,
>ImportKeyword : SyntaxKind
InKeyword = 86,
>InKeyword : SyntaxKind
>InKeyword : SyntaxKind
InstanceOfKeyword = 87,
>InstanceOfKeyword : SyntaxKind
NewKeyword = 87,
NewKeyword = 88,
>NewKeyword : SyntaxKind
NullKeyword = 89,
>NullKeyword : SyntaxKind
>NullKeyword : SyntaxKind
ReturnKeyword = 90,
>ReturnKeyword : SyntaxKind
SuperKeyword = 90,
SuperKeyword = 91,
>SuperKeyword : SyntaxKind
SwitchKeyword = 92,
>SwitchKeyword : SyntaxKind
>SwitchKeyword : SyntaxKind
ThisKeyword = 93,
>ThisKeyword : SyntaxKind
ThrowKeyword = 94,
ThrowKeyword = 93,
>ThrowKeyword : SyntaxKind
TrueKeyword = 95,
>TrueKeyword : SyntaxKind
>TrueKeyword : SyntaxKind
TryKeyword = 96,
>TryKeyword : SyntaxKind
TypeOfKeyword = 97,
TypeOfKeyword = 96,
>TypeOfKeyword : SyntaxKind
VarKeyword = 98,
>VarKeyword : SyntaxKind
>VarKeyword : SyntaxKind
VoidKeyword = 99,
>VoidKeyword : SyntaxKind
WhileKeyword = 100,
WhileKeyword = 99,
>WhileKeyword : SyntaxKind
WithKeyword = 101,
>WithKeyword : SyntaxKind
>WithKeyword : SyntaxKind
AsKeyword = 102,
>AsKeyword : SyntaxKind
ImplementsKeyword = 103,
ImplementsKeyword = 102,
>ImplementsKeyword : SyntaxKind
InterfaceKeyword = 104,
>InterfaceKeyword : SyntaxKind
>InterfaceKeyword : SyntaxKind
LetKeyword = 105,
>LetKeyword : SyntaxKind
PackageKeyword = 106,
PackageKeyword = 105,
>PackageKeyword : SyntaxKind
PrivateKeyword = 107,
>PrivateKeyword : SyntaxKind
>PrivateKeyword : SyntaxKind
ProtectedKeyword = 108,
>ProtectedKeyword : SyntaxKind
PublicKeyword = 109,
PublicKeyword = 108,
>PublicKeyword : SyntaxKind
StaticKeyword = 110,
>StaticKeyword : SyntaxKind
>StaticKeyword : SyntaxKind
YieldKeyword = 111,
>YieldKeyword : SyntaxKind
AnyKeyword = 112,
AnyKeyword = 111,
>AnyKeyword : SyntaxKind
BooleanKeyword = 113,
>BooleanKeyword : SyntaxKind
>BooleanKeyword : SyntaxKind
ConstructorKeyword = 114,
>ConstructorKeyword : SyntaxKind
DeclareKeyword = 115,
DeclareKeyword = 114,
>DeclareKeyword : SyntaxKind
GetKeyword = 116,
>GetKeyword : SyntaxKind
>GetKeyword : SyntaxKind
ModuleKeyword = 117,
>ModuleKeyword : SyntaxKind
RequireKeyword = 118,
RequireKeyword = 117,
>RequireKeyword : SyntaxKind
NumberKeyword = 119,
>NumberKeyword : SyntaxKind
>NumberKeyword : SyntaxKind
SetKeyword = 120,
>SetKeyword : SyntaxKind
StringKeyword = 121,
StringKeyword = 120,
>StringKeyword : SyntaxKind
SymbolKeyword = 122,
>SymbolKeyword : SyntaxKind
>SymbolKeyword : SyntaxKind
TypeKeyword = 123,
>TypeKeyword : SyntaxKind
FromKeyword = 124,
FromKeyword = 123,
>FromKeyword : SyntaxKind
OfKeyword = 125,
>OfKeyword : SyntaxKind
>OfKeyword : SyntaxKind
QualifiedName = 126,
>QualifiedName : SyntaxKind
ComputedPropertyName = 127,
ComputedPropertyName = 126,
>ComputedPropertyName : SyntaxKind
TypeParameter = 128,
>TypeParameter : SyntaxKind
>TypeParameter : SyntaxKind
Parameter = 129,
>Parameter : SyntaxKind
Decorator = 130,
PropertySignature = 129,
>Decorator : SyntaxKind
PropertySignature = 131,
>PropertySignature : SyntaxKind
>PropertyDeclaration : SyntaxKind
PropertyDeclaration = 132,
>PropertyDeclaration : SyntaxKind
MethodSignature = 133,
MethodDeclaration = 132,
>MethodSignature : SyntaxKind
MethodDeclaration = 134,
>MethodDeclaration : SyntaxKind
>Constructor : SyntaxKind
Constructor = 135,
>Constructor : SyntaxKind
GetAccessor = 136,
SetAccessor = 135,
>GetAccessor : SyntaxKind
SetAccessor = 137,
>SetAccessor : SyntaxKind
>CallSignature : SyntaxKind
CallSignature = 138,
>CallSignature : SyntaxKind
ConstructSignature = 139,
IndexSignature = 138,
>ConstructSignature : SyntaxKind
IndexSignature = 140,
>IndexSignature : SyntaxKind
>TypeReference : SyntaxKind
TypeReference = 141,
>TypeReference : SyntaxKind
FunctionType = 142,
ConstructorType = 141,
>FunctionType : SyntaxKind
ConstructorType = 143,
>ConstructorType : SyntaxKind
>TypeQuery : SyntaxKind
TypeQuery = 144,
>TypeQuery : SyntaxKind
TypeLiteral = 145,
ArrayType = 144,
>TypeLiteral : SyntaxKind
ArrayType = 146,
>ArrayType : SyntaxKind
>TupleType : SyntaxKind
TupleType = 147,
>TupleType : SyntaxKind
UnionType = 148,
ParenthesizedType = 147,
>UnionType : SyntaxKind
ParenthesizedType = 149,
>ParenthesizedType : SyntaxKind
>ObjectBindingPattern : SyntaxKind
ObjectBindingPattern = 150,
>ObjectBindingPattern : SyntaxKind
ArrayBindingPattern = 151,
BindingElement = 150,
>ArrayBindingPattern : SyntaxKind
BindingElement = 152,
>BindingElement : SyntaxKind
>ArrayLiteralExpression : SyntaxKind
ArrayLiteralExpression = 153,
>ArrayLiteralExpression : SyntaxKind
ObjectLiteralExpression = 154,
PropertyAccessExpression = 153,
>ObjectLiteralExpression : SyntaxKind
PropertyAccessExpression = 155,
>PropertyAccessExpression : SyntaxKind
ElementAccessExpression = 156,
>ElementAccessExpression : SyntaxKind
>ElementAccessExpression : SyntaxKind
CallExpression = 157,
>CallExpression : SyntaxKind
NewExpression = 158,
NewExpression = 156,
>NewExpression : SyntaxKind
TaggedTemplateExpression = 159,
>TaggedTemplateExpression : SyntaxKind
>TaggedTemplateExpression : SyntaxKind
TypeAssertionExpression = 160,
>TypeAssertionExpression : SyntaxKind
ParenthesizedExpression = 161,
ParenthesizedExpression = 159,
>ParenthesizedExpression : SyntaxKind
FunctionExpression = 162,
>FunctionExpression : SyntaxKind
>FunctionExpression : SyntaxKind
ArrowFunction = 163,
>ArrowFunction : SyntaxKind
DeleteExpression = 164,
DeleteExpression = 162,
>DeleteExpression : SyntaxKind
TypeOfExpression = 165,
>TypeOfExpression : SyntaxKind
>TypeOfExpression : SyntaxKind
VoidExpression = 166,
>VoidExpression : SyntaxKind
PrefixUnaryExpression = 167,
PrefixUnaryExpression = 165,
>PrefixUnaryExpression : SyntaxKind
PostfixUnaryExpression = 168,
>PostfixUnaryExpression : SyntaxKind
>PostfixUnaryExpression : SyntaxKind
BinaryExpression = 169,
>BinaryExpression : SyntaxKind
ConditionalExpression = 170,
ConditionalExpression = 168,
>ConditionalExpression : SyntaxKind
TemplateExpression = 171,
>TemplateExpression : SyntaxKind
YieldExpression = 172,
>YieldExpression : SyntaxKind
SpreadElementExpression = 173,
>SpreadElementExpression : SyntaxKind
OmittedExpression = 174,
>OmittedExpression : SyntaxKind
@@ -1076,10 +1085,10 @@ declare module "typescript" {
>ExpressionStatement : SyntaxKind
IfStatement = 180,
>IfStatement : SyntaxKind
>IfStatement : SyntaxKind
DoStatement = 181,
>DoStatement : SyntaxKind
@@ -1148,16 +1157,19 @@ declare module "typescript" {
>FunctionDeclaration : SyntaxKind
ClassDeclaration = 198,
>ClassDeclaration : SyntaxKind
InterfaceDeclaration = 199,
>ClassDeclaration : SyntaxKind
>InterfaceDeclaration : SyntaxKind
TypeAliasDeclaration = 200,
>TypeAliasDeclaration : SyntaxKind
TypeAliasDeclaration = 198,
EnumDeclaration = 201,
>EnumDeclaration : SyntaxKind
@@ -1188,6 +1200,11 @@ declare module "typescript" {
NamespaceImport = 208,
>NamespaceImport : SyntaxKind
NamedImports = 209,
>NamedImports : SyntaxKind
ImportSpecifier = 210,
>ImportSpecifier : SyntaxKind
@@ -1282,6 +1299,14 @@ declare module "typescript" {
FirstFutureReservedWord = 103,
>FirstFutureReservedWord : SyntaxKind
LastFutureReservedWord = 111,
>LastFutureReservedWord : SyntaxKind
FirstTypeNode = 141,
>FirstTypeNode : SyntaxKind
LastTypeNode = 149,
@@ -1561,6 +1586,25 @@ declare module "typescript" {
text: string;
>text : string
}
interface QualifiedName extends Node {
>QualifiedName : QualifiedName
>Node : Node
left: EntityName;
>left : Identifier | QualifiedName
>EntityName : Identifier | QualifiedName
right: Identifier;
>right : Identifier
>Identifier : Identifier
}
type EntityName = Identifier | QualifiedName;
>EntityName : Identifier | QualifiedName
>Identifier : Identifier
@@ -3580,6 +3624,9 @@ declare module "typescript" {
getPropertiesOfType(type: Type): Symbol[];
>getPropertiesOfType : (type: Type) => Symbol[]
>type : Type
>Type : Type
>Symbol : Symbol
getPropertyOfType(type: Type, propertyName: string): Symbol;

View File

@@ -143,192 +143,195 @@ declare module "typescript" {
BarBarToken = 49,
QuestionToken = 50,
ColonToken = 51,
EqualsToken = 52,
PlusEqualsToken = 53,
MinusEqualsToken = 54,
AsteriskEqualsToken = 55,
SlashEqualsToken = 56,
PercentEqualsToken = 57,
LessThanLessThanEqualsToken = 58,
GreaterThanGreaterThanEqualsToken = 59,
GreaterThanGreaterThanGreaterThanEqualsToken = 60,
AmpersandEqualsToken = 61,
BarEqualsToken = 62,
CaretEqualsToken = 63,
Identifier = 64,
BreakKeyword = 65,
CaseKeyword = 66,
CatchKeyword = 67,
ClassKeyword = 68,
ConstKeyword = 69,
ContinueKeyword = 70,
DebuggerKeyword = 71,
DefaultKeyword = 72,
DeleteKeyword = 73,
DoKeyword = 74,
ElseKeyword = 75,
EnumKeyword = 76,
ExportKeyword = 77,
ExtendsKeyword = 78,
FalseKeyword = 79,
FinallyKeyword = 80,
ForKeyword = 81,
FunctionKeyword = 82,
IfKeyword = 83,
ImportKeyword = 84,
InKeyword = 85,
InstanceOfKeyword = 86,
NewKeyword = 87,
NullKeyword = 88,
ReturnKeyword = 89,
SuperKeyword = 90,
SwitchKeyword = 91,
ThisKeyword = 92,
ThrowKeyword = 93,
TrueKeyword = 94,
TryKeyword = 95,
TypeOfKeyword = 96,
VarKeyword = 97,
VoidKeyword = 98,
WhileKeyword = 99,
WithKeyword = 100,
AsKeyword = 101,
ImplementsKeyword = 102,
InterfaceKeyword = 103,
LetKeyword = 104,
PackageKeyword = 105,
PrivateKeyword = 106,
ProtectedKeyword = 107,
PublicKeyword = 108,
StaticKeyword = 109,
YieldKeyword = 110,
AnyKeyword = 111,
BooleanKeyword = 112,
ConstructorKeyword = 113,
DeclareKeyword = 114,
GetKeyword = 115,
ModuleKeyword = 116,
RequireKeyword = 117,
NumberKeyword = 118,
SetKeyword = 119,
StringKeyword = 120,
SymbolKeyword = 121,
TypeKeyword = 122,
FromKeyword = 123,
OfKeyword = 124,
QualifiedName = 125,
ComputedPropertyName = 126,
TypeParameter = 127,
Parameter = 128,
PropertySignature = 129,
PropertyDeclaration = 130,
MethodSignature = 131,
MethodDeclaration = 132,
Constructor = 133,
GetAccessor = 134,
SetAccessor = 135,
CallSignature = 136,
ConstructSignature = 137,
IndexSignature = 138,
TypeReference = 139,
FunctionType = 140,
ConstructorType = 141,
TypeQuery = 142,
TypeLiteral = 143,
ArrayType = 144,
TupleType = 145,
UnionType = 146,
ParenthesizedType = 147,
ObjectBindingPattern = 148,
ArrayBindingPattern = 149,
BindingElement = 150,
ArrayLiteralExpression = 151,
ObjectLiteralExpression = 152,
PropertyAccessExpression = 153,
ElementAccessExpression = 154,
CallExpression = 155,
NewExpression = 156,
TaggedTemplateExpression = 157,
TypeAssertionExpression = 158,
ParenthesizedExpression = 159,
FunctionExpression = 160,
ArrowFunction = 161,
DeleteExpression = 162,
TypeOfExpression = 163,
VoidExpression = 164,
PrefixUnaryExpression = 165,
PostfixUnaryExpression = 166,
BinaryExpression = 167,
ConditionalExpression = 168,
TemplateExpression = 169,
YieldExpression = 170,
SpreadElementExpression = 171,
OmittedExpression = 172,
TemplateSpan = 173,
Block = 174,
VariableStatement = 175,
EmptyStatement = 176,
ExpressionStatement = 177,
IfStatement = 178,
DoStatement = 179,
WhileStatement = 180,
ForStatement = 181,
ForInStatement = 182,
ForOfStatement = 183,
ContinueStatement = 184,
BreakStatement = 185,
ReturnStatement = 186,
WithStatement = 187,
SwitchStatement = 188,
LabeledStatement = 189,
ThrowStatement = 190,
TryStatement = 191,
DebuggerStatement = 192,
VariableDeclaration = 193,
VariableDeclarationList = 194,
FunctionDeclaration = 195,
ClassDeclaration = 196,
InterfaceDeclaration = 197,
TypeAliasDeclaration = 198,
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
CaseBlock = 202,
ImportEqualsDeclaration = 203,
ImportDeclaration = 204,
ImportClause = 205,
NamespaceImport = 206,
NamedImports = 207,
ImportSpecifier = 208,
ExportAssignment = 209,
ExportDeclaration = 210,
NamedExports = 211,
ExportSpecifier = 212,
ExternalModuleReference = 213,
CaseClause = 214,
DefaultClause = 215,
HeritageClause = 216,
CatchClause = 217,
PropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
EnumMember = 220,
SourceFile = 221,
SyntaxList = 222,
Count = 223,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
LastReservedWord = 100,
FirstKeyword = 65,
LastKeyword = 124,
FirstFutureReservedWord = 102,
LastFutureReservedWord = 110,
FirstTypeNode = 139,
LastTypeNode = 147,
AtToken = 52,
EqualsToken = 53,
PlusEqualsToken = 54,
MinusEqualsToken = 55,
AsteriskEqualsToken = 56,
SlashEqualsToken = 57,
PercentEqualsToken = 58,
LessThanLessThanEqualsToken = 59,
GreaterThanGreaterThanEqualsToken = 60,
GreaterThanGreaterThanGreaterThanEqualsToken = 61,
AmpersandEqualsToken = 62,
BarEqualsToken = 63,
CaretEqualsToken = 64,
Identifier = 65,
BreakKeyword = 66,
CaseKeyword = 67,
CatchKeyword = 68,
ClassKeyword = 69,
ConstKeyword = 70,
ContinueKeyword = 71,
DebuggerKeyword = 72,
DefaultKeyword = 73,
DeleteKeyword = 74,
DoKeyword = 75,
ElseKeyword = 76,
EnumKeyword = 77,
ExportKeyword = 78,
ExtendsKeyword = 79,
FalseKeyword = 80,
FinallyKeyword = 81,
ForKeyword = 82,
FunctionKeyword = 83,
IfKeyword = 84,
ImportKeyword = 85,
InKeyword = 86,
InstanceOfKeyword = 87,
NewKeyword = 88,
NullKeyword = 89,
ReturnKeyword = 90,
SuperKeyword = 91,
SwitchKeyword = 92,
ThisKeyword = 93,
ThrowKeyword = 94,
TrueKeyword = 95,
TryKeyword = 96,
TypeOfKeyword = 97,
VarKeyword = 98,
VoidKeyword = 99,
WhileKeyword = 100,
WithKeyword = 101,
AsKeyword = 102,
ImplementsKeyword = 103,
InterfaceKeyword = 104,
LetKeyword = 105,
PackageKeyword = 106,
PrivateKeyword = 107,
ProtectedKeyword = 108,
PublicKeyword = 109,
StaticKeyword = 110,
YieldKeyword = 111,
AnyKeyword = 112,
BooleanKeyword = 113,
ConstructorKeyword = 114,
DeclareKeyword = 115,
GetKeyword = 116,
ModuleKeyword = 117,
RequireKeyword = 118,
NumberKeyword = 119,
SetKeyword = 120,
StringKeyword = 121,
SymbolKeyword = 122,
TypeKeyword = 123,
FromKeyword = 124,
OfKeyword = 125,
QualifiedName = 126,
ComputedPropertyName = 127,
TypeParameter = 128,
Parameter = 129,
Decorator = 130,
PropertySignature = 131,
PropertyDeclaration = 132,
MethodSignature = 133,
MethodDeclaration = 134,
Constructor = 135,
GetAccessor = 136,
SetAccessor = 137,
CallSignature = 138,
ConstructSignature = 139,
IndexSignature = 140,
TypeReference = 141,
FunctionType = 142,
ConstructorType = 143,
TypeQuery = 144,
TypeLiteral = 145,
ArrayType = 146,
TupleType = 147,
UnionType = 148,
ParenthesizedType = 149,
ObjectBindingPattern = 150,
ArrayBindingPattern = 151,
BindingElement = 152,
ArrayLiteralExpression = 153,
ObjectLiteralExpression = 154,
PropertyAccessExpression = 155,
ElementAccessExpression = 156,
CallExpression = 157,
NewExpression = 158,
TaggedTemplateExpression = 159,
TypeAssertionExpression = 160,
ParenthesizedExpression = 161,
FunctionExpression = 162,
ArrowFunction = 163,
DeleteExpression = 164,
TypeOfExpression = 165,
VoidExpression = 166,
PrefixUnaryExpression = 167,
PostfixUnaryExpression = 168,
BinaryExpression = 169,
ConditionalExpression = 170,
TemplateExpression = 171,
YieldExpression = 172,
SpreadElementExpression = 173,
OmittedExpression = 174,
TemplateSpan = 175,
Block = 176,
VariableStatement = 177,
EmptyStatement = 178,
ExpressionStatement = 179,
IfStatement = 180,
DoStatement = 181,
WhileStatement = 182,
ForStatement = 183,
ForInStatement = 184,
ForOfStatement = 185,
ContinueStatement = 186,
BreakStatement = 187,
ReturnStatement = 188,
WithStatement = 189,
SwitchStatement = 190,
LabeledStatement = 191,
ThrowStatement = 192,
TryStatement = 193,
DebuggerStatement = 194,
VariableDeclaration = 195,
VariableDeclarationList = 196,
FunctionDeclaration = 197,
ClassDeclaration = 198,
InterfaceDeclaration = 199,
TypeAliasDeclaration = 200,
EnumDeclaration = 201,
ModuleDeclaration = 202,
ModuleBlock = 203,
CaseBlock = 204,
ImportEqualsDeclaration = 205,
ImportDeclaration = 206,
ImportClause = 207,
NamespaceImport = 208,
NamedImports = 209,
ImportSpecifier = 210,
ExportAssignment = 211,
ExportDeclaration = 212,
NamedExports = 213,
ExportSpecifier = 214,
MissingDeclaration = 215,
ExternalModuleReference = 216,
CaseClause = 217,
DefaultClause = 218,
HeritageClause = 219,
CatchClause = 220,
PropertyAssignment = 221,
ShorthandPropertyAssignment = 222,
EnumMember = 223,
SourceFile = 224,
SyntaxList = 225,
Count = 226,
FirstAssignment = 53,
LastAssignment = 64,
FirstReservedWord = 66,
LastReservedWord = 101,
FirstKeyword = 66,
LastKeyword = 125,
FirstFutureReservedWord = 103,
LastFutureReservedWord = 111,
FirstTypeNode = 141,
LastTypeNode = 149,
FirstPunctuation = 14,
LastPunctuation = 63,
LastPunctuation = 64,
FirstToken = 0,
LastToken = 124,
LastToken = 125,
FirstTriviaToken = 2,
LastTriviaToken = 6,
FirstLiteralToken = 7,
@@ -336,8 +339,8 @@ declare module "typescript" {
FirstTemplateToken = 10,
LastTemplateToken = 13,
FirstBinaryOperator = 24,
LastBinaryOperator = 63,
FirstNode = 125,
LastBinaryOperator = 64,
FirstNode = 126,
}
const enum NodeFlags {
Export = 1,
@@ -362,10 +365,11 @@ declare module "typescript" {
DisallowIn = 2,
Yield = 4,
GeneratorParameter = 8,
ThisNodeHasError = 16,
ParserGeneratedFlags = 31,
ThisNodeOrAnySubNodesHasError = 32,
HasAggregatedChildData = 64,
Decorator = 16,
ThisNodeHasError = 32,
ParserGeneratedFlags = 63,
ThisNodeOrAnySubNodesHasError = 64,
HasAggregatedChildData = 128,
}
const enum RelationComparisonResult {
Succeeded = 1,
@@ -376,6 +380,7 @@ declare module "typescript" {
kind: SyntaxKind;
flags: NodeFlags;
parserContextFlags?: ParserContextFlags;
decorators?: NodeArray<Decorator>;
modifiers?: ModifiersArray;
id?: number;
parent?: Node;
@@ -406,6 +411,9 @@ declare module "typescript" {
interface ComputedPropertyName extends Node {
expression: Expression;
}
interface Decorator extends Node {
expression: LeftHandSideExpression;
}
interface TypeParameterDeclaration extends Declaration {
name: Identifier;
constraint?: TypeNode;
@@ -496,6 +504,12 @@ declare module "typescript" {
_accessorDeclarationBrand: any;
body: Block;
}
interface MergedAccessorDeclarations {
getAccessor: AccessorDeclaration;
setAccessor: AccessorDeclaration;
firstAccessor: AccessorDeclaration;
secondAccessor: AccessorDeclaration;
}
interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement {
_indexSignatureDeclarationBrand: any;
}
@@ -1092,6 +1106,7 @@ declare module "typescript" {
ContextChecked = 64,
EnumValuesComputed = 128,
BlockScopedBindingInLoop = 256,
EmitDecorate = 512,
}
interface NodeLinks {
resolvedType?: Type;

View File

@@ -447,562 +447,571 @@ declare module "typescript" {
>EqualsGreaterThanToken : SyntaxKind
PlusToken = 33,
PlusToken = 33,
>PlusToken : SyntaxKind
MinusToken = 34,
>MinusToken : SyntaxKind
AsteriskToken = 35,
>MinusToken : SyntaxKind
>AsteriskToken : SyntaxKind
SlashToken = 36,
>SlashToken : SyntaxKind
SlashToken = 36,
PercentToken = 37,
>PercentToken : SyntaxKind
PlusPlusToken = 38,
>PercentToken : SyntaxKind
>PlusPlusToken : SyntaxKind
MinusMinusToken = 39,
>MinusMinusToken : SyntaxKind
MinusMinusToken = 39,
LessThanLessThanToken = 40,
>LessThanLessThanToken : SyntaxKind
GreaterThanGreaterThanToken = 41,
>LessThanLessThanToken : SyntaxKind
>GreaterThanGreaterThanToken : SyntaxKind
GreaterThanGreaterThanGreaterThanToken = 42,
>GreaterThanGreaterThanGreaterThanToken : SyntaxKind
GreaterThanGreaterThanGreaterThanToken = 42,
AmpersandToken = 43,
>AmpersandToken : SyntaxKind
BarToken = 44,
>AmpersandToken : SyntaxKind
>BarToken : SyntaxKind
CaretToken = 45,
>CaretToken : SyntaxKind
CaretToken = 45,
ExclamationToken = 46,
>ExclamationToken : SyntaxKind
TildeToken = 47,
>ExclamationToken : SyntaxKind
>TildeToken : SyntaxKind
AmpersandAmpersandToken = 48,
>AmpersandAmpersandToken : SyntaxKind
AmpersandAmpersandToken = 48,
BarBarToken = 49,
>BarBarToken : SyntaxKind
QuestionToken = 50,
>BarBarToken : SyntaxKind
>QuestionToken : SyntaxKind
ColonToken = 51,
>ColonToken : SyntaxKind
ColonToken = 51,
AtToken = 52,
>AtToken : SyntaxKind
EqualsToken = 53,
>EqualsToken : SyntaxKind
>EqualsToken : SyntaxKind
PlusEqualsToken = 54,
>PlusEqualsToken : SyntaxKind
MinusEqualsToken = 54,
MinusEqualsToken = 55,
>MinusEqualsToken : SyntaxKind
AsteriskEqualsToken = 56,
>AsteriskEqualsToken : SyntaxKind
>AsteriskEqualsToken : SyntaxKind
SlashEqualsToken = 57,
>SlashEqualsToken : SyntaxKind
PercentEqualsToken = 57,
PercentEqualsToken = 58,
>PercentEqualsToken : SyntaxKind
LessThanLessThanEqualsToken = 59,
>LessThanLessThanEqualsToken : SyntaxKind
>LessThanLessThanEqualsToken : SyntaxKind
GreaterThanGreaterThanEqualsToken = 60,
>GreaterThanGreaterThanEqualsToken : SyntaxKind
GreaterThanGreaterThanGreaterThanEqualsToken = 60,
GreaterThanGreaterThanGreaterThanEqualsToken = 61,
>GreaterThanGreaterThanGreaterThanEqualsToken : SyntaxKind
AmpersandEqualsToken = 62,
>AmpersandEqualsToken : SyntaxKind
>AmpersandEqualsToken : SyntaxKind
BarEqualsToken = 63,
>BarEqualsToken : SyntaxKind
CaretEqualsToken = 63,
CaretEqualsToken = 64,
>CaretEqualsToken : SyntaxKind
Identifier = 65,
>Identifier : SyntaxKind
>Identifier : SyntaxKind
BreakKeyword = 66,
>BreakKeyword : SyntaxKind
CaseKeyword = 66,
CaseKeyword = 67,
>CaseKeyword : SyntaxKind
CatchKeyword = 68,
>CatchKeyword : SyntaxKind
>CatchKeyword : SyntaxKind
ClassKeyword = 69,
>ClassKeyword : SyntaxKind
ConstKeyword = 69,
ConstKeyword = 70,
>ConstKeyword : SyntaxKind
ContinueKeyword = 71,
>ContinueKeyword : SyntaxKind
>ContinueKeyword : SyntaxKind
DebuggerKeyword = 72,
>DebuggerKeyword : SyntaxKind
DefaultKeyword = 72,
DefaultKeyword = 73,
>DefaultKeyword : SyntaxKind
DeleteKeyword = 74,
>DeleteKeyword : SyntaxKind
>DeleteKeyword : SyntaxKind
DoKeyword = 75,
>DoKeyword : SyntaxKind
ElseKeyword = 75,
ElseKeyword = 76,
>ElseKeyword : SyntaxKind
EnumKeyword = 77,
>EnumKeyword : SyntaxKind
>EnumKeyword : SyntaxKind
ExportKeyword = 78,
>ExportKeyword : SyntaxKind
ExtendsKeyword = 78,
ExtendsKeyword = 79,
>ExtendsKeyword : SyntaxKind
FalseKeyword = 80,
>FalseKeyword : SyntaxKind
>FalseKeyword : SyntaxKind
FinallyKeyword = 81,
>FinallyKeyword : SyntaxKind
ForKeyword = 81,
ForKeyword = 82,
>ForKeyword : SyntaxKind
FunctionKeyword = 83,
>FunctionKeyword : SyntaxKind
>FunctionKeyword : SyntaxKind
IfKeyword = 84,
>IfKeyword : SyntaxKind
ImportKeyword = 84,
ImportKeyword = 85,
>ImportKeyword : SyntaxKind
InKeyword = 86,
>InKeyword : SyntaxKind
>InKeyword : SyntaxKind
InstanceOfKeyword = 87,
>InstanceOfKeyword : SyntaxKind
NewKeyword = 87,
NewKeyword = 88,
>NewKeyword : SyntaxKind
NullKeyword = 89,
>NullKeyword : SyntaxKind
>NullKeyword : SyntaxKind
ReturnKeyword = 90,
>ReturnKeyword : SyntaxKind
SuperKeyword = 90,
SuperKeyword = 91,
>SuperKeyword : SyntaxKind
SwitchKeyword = 92,
>SwitchKeyword : SyntaxKind
>SwitchKeyword : SyntaxKind
ThisKeyword = 93,
>ThisKeyword : SyntaxKind
ThrowKeyword = 94,
ThrowKeyword = 93,
>ThrowKeyword : SyntaxKind
TrueKeyword = 95,
>TrueKeyword : SyntaxKind
>TrueKeyword : SyntaxKind
TryKeyword = 96,
>TryKeyword : SyntaxKind
TypeOfKeyword = 97,
TypeOfKeyword = 96,
>TypeOfKeyword : SyntaxKind
VarKeyword = 98,
>VarKeyword : SyntaxKind
>VarKeyword : SyntaxKind
VoidKeyword = 99,
>VoidKeyword : SyntaxKind
WhileKeyword = 100,
WhileKeyword = 99,
>WhileKeyword : SyntaxKind
WithKeyword = 101,
>WithKeyword : SyntaxKind
>WithKeyword : SyntaxKind
AsKeyword = 102,
>AsKeyword : SyntaxKind
ImplementsKeyword = 103,
ImplementsKeyword = 102,
>ImplementsKeyword : SyntaxKind
InterfaceKeyword = 104,
>InterfaceKeyword : SyntaxKind
>InterfaceKeyword : SyntaxKind
LetKeyword = 105,
>LetKeyword : SyntaxKind
PackageKeyword = 106,
PackageKeyword = 105,
>PackageKeyword : SyntaxKind
PrivateKeyword = 107,
>PrivateKeyword : SyntaxKind
>PrivateKeyword : SyntaxKind
ProtectedKeyword = 108,
>ProtectedKeyword : SyntaxKind
PublicKeyword = 109,
PublicKeyword = 108,
>PublicKeyword : SyntaxKind
StaticKeyword = 110,
>StaticKeyword : SyntaxKind
>StaticKeyword : SyntaxKind
YieldKeyword = 111,
>YieldKeyword : SyntaxKind
AnyKeyword = 112,
AnyKeyword = 111,
>AnyKeyword : SyntaxKind
BooleanKeyword = 113,
>BooleanKeyword : SyntaxKind
>BooleanKeyword : SyntaxKind
ConstructorKeyword = 114,
>ConstructorKeyword : SyntaxKind
DeclareKeyword = 115,
DeclareKeyword = 114,
>DeclareKeyword : SyntaxKind
GetKeyword = 116,
>GetKeyword : SyntaxKind
>GetKeyword : SyntaxKind
ModuleKeyword = 117,
>ModuleKeyword : SyntaxKind
RequireKeyword = 118,
RequireKeyword = 117,
>RequireKeyword : SyntaxKind
NumberKeyword = 119,
>NumberKeyword : SyntaxKind
>NumberKeyword : SyntaxKind
SetKeyword = 120,
>SetKeyword : SyntaxKind
StringKeyword = 121,
StringKeyword = 120,
>StringKeyword : SyntaxKind
SymbolKeyword = 122,
>SymbolKeyword : SyntaxKind
>SymbolKeyword : SyntaxKind
TypeKeyword = 123,
>TypeKeyword : SyntaxKind
FromKeyword = 124,
FromKeyword = 123,
>FromKeyword : SyntaxKind
OfKeyword = 125,
>OfKeyword : SyntaxKind
>OfKeyword : SyntaxKind
QualifiedName = 126,
>QualifiedName : SyntaxKind
ComputedPropertyName = 127,
ComputedPropertyName = 126,
>ComputedPropertyName : SyntaxKind
TypeParameter = 128,
>TypeParameter : SyntaxKind
>TypeParameter : SyntaxKind
Parameter = 129,
>Parameter : SyntaxKind
Decorator = 130,
PropertySignature = 129,
>Decorator : SyntaxKind
PropertySignature = 131,
>PropertySignature : SyntaxKind
>PropertyDeclaration : SyntaxKind
PropertyDeclaration = 132,
>PropertyDeclaration : SyntaxKind
MethodSignature = 133,
MethodDeclaration = 132,
>MethodSignature : SyntaxKind
MethodDeclaration = 134,
>MethodDeclaration : SyntaxKind
>Constructor : SyntaxKind
Constructor = 135,
>Constructor : SyntaxKind
GetAccessor = 136,
SetAccessor = 135,
>GetAccessor : SyntaxKind
SetAccessor = 137,
>SetAccessor : SyntaxKind
>CallSignature : SyntaxKind
CallSignature = 138,
>CallSignature : SyntaxKind
ConstructSignature = 139,
IndexSignature = 138,
>ConstructSignature : SyntaxKind
IndexSignature = 140,
>IndexSignature : SyntaxKind
>TypeReference : SyntaxKind
TypeReference = 141,
>TypeReference : SyntaxKind
FunctionType = 142,
ConstructorType = 141,
>FunctionType : SyntaxKind
ConstructorType = 143,
>ConstructorType : SyntaxKind
>TypeQuery : SyntaxKind
TypeQuery = 144,
>TypeQuery : SyntaxKind
TypeLiteral = 145,
ArrayType = 144,
>TypeLiteral : SyntaxKind
ArrayType = 146,
>ArrayType : SyntaxKind
>TupleType : SyntaxKind
TupleType = 147,
>TupleType : SyntaxKind
UnionType = 148,
ParenthesizedType = 147,
>UnionType : SyntaxKind
ParenthesizedType = 149,
>ParenthesizedType : SyntaxKind
>ObjectBindingPattern : SyntaxKind
ObjectBindingPattern = 150,
>ObjectBindingPattern : SyntaxKind
ArrayBindingPattern = 151,
BindingElement = 150,
>ArrayBindingPattern : SyntaxKind
BindingElement = 152,
>BindingElement : SyntaxKind
>ArrayLiteralExpression : SyntaxKind
ArrayLiteralExpression = 153,
>ArrayLiteralExpression : SyntaxKind
ObjectLiteralExpression = 154,
PropertyAccessExpression = 153,
>ObjectLiteralExpression : SyntaxKind
PropertyAccessExpression = 155,
>PropertyAccessExpression : SyntaxKind
ElementAccessExpression = 156,
>ElementAccessExpression : SyntaxKind
>ElementAccessExpression : SyntaxKind
CallExpression = 157,
>CallExpression : SyntaxKind
NewExpression = 158,
NewExpression = 156,
>NewExpression : SyntaxKind
TaggedTemplateExpression = 159,
>TaggedTemplateExpression : SyntaxKind
>TaggedTemplateExpression : SyntaxKind
TypeAssertionExpression = 160,
>TypeAssertionExpression : SyntaxKind
ParenthesizedExpression = 161,
ParenthesizedExpression = 159,
>ParenthesizedExpression : SyntaxKind
FunctionExpression = 162,
>FunctionExpression : SyntaxKind
>FunctionExpression : SyntaxKind
ArrowFunction = 163,
>ArrowFunction : SyntaxKind
DeleteExpression = 164,
DeleteExpression = 162,
>DeleteExpression : SyntaxKind
TypeOfExpression = 165,
>TypeOfExpression : SyntaxKind
>TypeOfExpression : SyntaxKind
VoidExpression = 166,
>VoidExpression : SyntaxKind
PrefixUnaryExpression = 167,
PrefixUnaryExpression = 165,
>PrefixUnaryExpression : SyntaxKind
PostfixUnaryExpression = 168,
>PostfixUnaryExpression : SyntaxKind
>PostfixUnaryExpression : SyntaxKind
BinaryExpression = 169,
>BinaryExpression : SyntaxKind
ConditionalExpression = 170,
ConditionalExpression = 168,
>ConditionalExpression : SyntaxKind
TemplateExpression = 171,
>TemplateExpression : SyntaxKind
YieldExpression = 172,
>YieldExpression : SyntaxKind
SpreadElementExpression = 173,
>SpreadElementExpression : SyntaxKind
OmittedExpression = 174,
>OmittedExpression : SyntaxKind
@@ -1026,10 +1035,10 @@ declare module "typescript" {
>ExpressionStatement : SyntaxKind
IfStatement = 180,
>IfStatement : SyntaxKind
>IfStatement : SyntaxKind
DoStatement = 181,
>DoStatement : SyntaxKind
@@ -1098,16 +1107,19 @@ declare module "typescript" {
>FunctionDeclaration : SyntaxKind
ClassDeclaration = 198,
>ClassDeclaration : SyntaxKind
InterfaceDeclaration = 199,
>ClassDeclaration : SyntaxKind
>InterfaceDeclaration : SyntaxKind
TypeAliasDeclaration = 200,
>TypeAliasDeclaration : SyntaxKind
TypeAliasDeclaration = 198,
EnumDeclaration = 201,
>EnumDeclaration : SyntaxKind
@@ -1138,6 +1150,11 @@ declare module "typescript" {
NamespaceImport = 208,
>NamespaceImport : SyntaxKind
NamedImports = 209,
>NamedImports : SyntaxKind
ImportSpecifier = 210,
>ImportSpecifier : SyntaxKind
@@ -1232,6 +1249,14 @@ declare module "typescript" {
FirstFutureReservedWord = 103,
>FirstFutureReservedWord : SyntaxKind
LastFutureReservedWord = 111,
>LastFutureReservedWord : SyntaxKind
FirstTypeNode = 141,
>FirstTypeNode : SyntaxKind
LastTypeNode = 149,
@@ -1511,6 +1536,25 @@ declare module "typescript" {
text: string;
>text : string
}
interface QualifiedName extends Node {
>QualifiedName : QualifiedName
>Node : Node
left: EntityName;
>left : Identifier | QualifiedName
>EntityName : Identifier | QualifiedName
right: Identifier;
>right : Identifier
>Identifier : Identifier
}
type EntityName = Identifier | QualifiedName;
>EntityName : Identifier | QualifiedName
>Identifier : Identifier
@@ -3530,6 +3574,9 @@ declare module "typescript" {
getPropertiesOfType(type: Type): Symbol[];
>getPropertiesOfType : (type: Type) => Symbol[]
>type : Type
>Type : Type
>Symbol : Symbol
getPropertyOfType(type: Type, propertyName: string): Symbol;

View File

@@ -180,192 +180,195 @@ declare module "typescript" {
BarBarToken = 49,
QuestionToken = 50,
ColonToken = 51,
EqualsToken = 52,
PlusEqualsToken = 53,
MinusEqualsToken = 54,
AsteriskEqualsToken = 55,
SlashEqualsToken = 56,
PercentEqualsToken = 57,
LessThanLessThanEqualsToken = 58,
GreaterThanGreaterThanEqualsToken = 59,
GreaterThanGreaterThanGreaterThanEqualsToken = 60,
AmpersandEqualsToken = 61,
BarEqualsToken = 62,
CaretEqualsToken = 63,
Identifier = 64,
BreakKeyword = 65,
CaseKeyword = 66,
CatchKeyword = 67,
ClassKeyword = 68,
ConstKeyword = 69,
ContinueKeyword = 70,
DebuggerKeyword = 71,
DefaultKeyword = 72,
DeleteKeyword = 73,
DoKeyword = 74,
ElseKeyword = 75,
EnumKeyword = 76,
ExportKeyword = 77,
ExtendsKeyword = 78,
FalseKeyword = 79,
FinallyKeyword = 80,
ForKeyword = 81,
FunctionKeyword = 82,
IfKeyword = 83,
ImportKeyword = 84,
InKeyword = 85,
InstanceOfKeyword = 86,
NewKeyword = 87,
NullKeyword = 88,
ReturnKeyword = 89,
SuperKeyword = 90,
SwitchKeyword = 91,
ThisKeyword = 92,
ThrowKeyword = 93,
TrueKeyword = 94,
TryKeyword = 95,
TypeOfKeyword = 96,
VarKeyword = 97,
VoidKeyword = 98,
WhileKeyword = 99,
WithKeyword = 100,
AsKeyword = 101,
ImplementsKeyword = 102,
InterfaceKeyword = 103,
LetKeyword = 104,
PackageKeyword = 105,
PrivateKeyword = 106,
ProtectedKeyword = 107,
PublicKeyword = 108,
StaticKeyword = 109,
YieldKeyword = 110,
AnyKeyword = 111,
BooleanKeyword = 112,
ConstructorKeyword = 113,
DeclareKeyword = 114,
GetKeyword = 115,
ModuleKeyword = 116,
RequireKeyword = 117,
NumberKeyword = 118,
SetKeyword = 119,
StringKeyword = 120,
SymbolKeyword = 121,
TypeKeyword = 122,
FromKeyword = 123,
OfKeyword = 124,
QualifiedName = 125,
ComputedPropertyName = 126,
TypeParameter = 127,
Parameter = 128,
PropertySignature = 129,
PropertyDeclaration = 130,
MethodSignature = 131,
MethodDeclaration = 132,
Constructor = 133,
GetAccessor = 134,
SetAccessor = 135,
CallSignature = 136,
ConstructSignature = 137,
IndexSignature = 138,
TypeReference = 139,
FunctionType = 140,
ConstructorType = 141,
TypeQuery = 142,
TypeLiteral = 143,
ArrayType = 144,
TupleType = 145,
UnionType = 146,
ParenthesizedType = 147,
ObjectBindingPattern = 148,
ArrayBindingPattern = 149,
BindingElement = 150,
ArrayLiteralExpression = 151,
ObjectLiteralExpression = 152,
PropertyAccessExpression = 153,
ElementAccessExpression = 154,
CallExpression = 155,
NewExpression = 156,
TaggedTemplateExpression = 157,
TypeAssertionExpression = 158,
ParenthesizedExpression = 159,
FunctionExpression = 160,
ArrowFunction = 161,
DeleteExpression = 162,
TypeOfExpression = 163,
VoidExpression = 164,
PrefixUnaryExpression = 165,
PostfixUnaryExpression = 166,
BinaryExpression = 167,
ConditionalExpression = 168,
TemplateExpression = 169,
YieldExpression = 170,
SpreadElementExpression = 171,
OmittedExpression = 172,
TemplateSpan = 173,
Block = 174,
VariableStatement = 175,
EmptyStatement = 176,
ExpressionStatement = 177,
IfStatement = 178,
DoStatement = 179,
WhileStatement = 180,
ForStatement = 181,
ForInStatement = 182,
ForOfStatement = 183,
ContinueStatement = 184,
BreakStatement = 185,
ReturnStatement = 186,
WithStatement = 187,
SwitchStatement = 188,
LabeledStatement = 189,
ThrowStatement = 190,
TryStatement = 191,
DebuggerStatement = 192,
VariableDeclaration = 193,
VariableDeclarationList = 194,
FunctionDeclaration = 195,
ClassDeclaration = 196,
InterfaceDeclaration = 197,
TypeAliasDeclaration = 198,
EnumDeclaration = 199,
ModuleDeclaration = 200,
ModuleBlock = 201,
CaseBlock = 202,
ImportEqualsDeclaration = 203,
ImportDeclaration = 204,
ImportClause = 205,
NamespaceImport = 206,
NamedImports = 207,
ImportSpecifier = 208,
ExportAssignment = 209,
ExportDeclaration = 210,
NamedExports = 211,
ExportSpecifier = 212,
ExternalModuleReference = 213,
CaseClause = 214,
DefaultClause = 215,
HeritageClause = 216,
CatchClause = 217,
PropertyAssignment = 218,
ShorthandPropertyAssignment = 219,
EnumMember = 220,
SourceFile = 221,
SyntaxList = 222,
Count = 223,
FirstAssignment = 52,
LastAssignment = 63,
FirstReservedWord = 65,
LastReservedWord = 100,
FirstKeyword = 65,
LastKeyword = 124,
FirstFutureReservedWord = 102,
LastFutureReservedWord = 110,
FirstTypeNode = 139,
LastTypeNode = 147,
AtToken = 52,
EqualsToken = 53,
PlusEqualsToken = 54,
MinusEqualsToken = 55,
AsteriskEqualsToken = 56,
SlashEqualsToken = 57,
PercentEqualsToken = 58,
LessThanLessThanEqualsToken = 59,
GreaterThanGreaterThanEqualsToken = 60,
GreaterThanGreaterThanGreaterThanEqualsToken = 61,
AmpersandEqualsToken = 62,
BarEqualsToken = 63,
CaretEqualsToken = 64,
Identifier = 65,
BreakKeyword = 66,
CaseKeyword = 67,
CatchKeyword = 68,
ClassKeyword = 69,
ConstKeyword = 70,
ContinueKeyword = 71,
DebuggerKeyword = 72,
DefaultKeyword = 73,
DeleteKeyword = 74,
DoKeyword = 75,
ElseKeyword = 76,
EnumKeyword = 77,
ExportKeyword = 78,
ExtendsKeyword = 79,
FalseKeyword = 80,
FinallyKeyword = 81,
ForKeyword = 82,
FunctionKeyword = 83,
IfKeyword = 84,
ImportKeyword = 85,
InKeyword = 86,
InstanceOfKeyword = 87,
NewKeyword = 88,
NullKeyword = 89,
ReturnKeyword = 90,
SuperKeyword = 91,
SwitchKeyword = 92,
ThisKeyword = 93,
ThrowKeyword = 94,
TrueKeyword = 95,
TryKeyword = 96,
TypeOfKeyword = 97,
VarKeyword = 98,
VoidKeyword = 99,
WhileKeyword = 100,
WithKeyword = 101,
AsKeyword = 102,
ImplementsKeyword = 103,
InterfaceKeyword = 104,
LetKeyword = 105,
PackageKeyword = 106,
PrivateKeyword = 107,
ProtectedKeyword = 108,
PublicKeyword = 109,
StaticKeyword = 110,
YieldKeyword = 111,
AnyKeyword = 112,
BooleanKeyword = 113,
ConstructorKeyword = 114,
DeclareKeyword = 115,
GetKeyword = 116,
ModuleKeyword = 117,
RequireKeyword = 118,
NumberKeyword = 119,
SetKeyword = 120,
StringKeyword = 121,
SymbolKeyword = 122,
TypeKeyword = 123,
FromKeyword = 124,
OfKeyword = 125,
QualifiedName = 126,
ComputedPropertyName = 127,
TypeParameter = 128,
Parameter = 129,
Decorator = 130,
PropertySignature = 131,
PropertyDeclaration = 132,
MethodSignature = 133,
MethodDeclaration = 134,
Constructor = 135,
GetAccessor = 136,
SetAccessor = 137,
CallSignature = 138,
ConstructSignature = 139,
IndexSignature = 140,
TypeReference = 141,
FunctionType = 142,
ConstructorType = 143,
TypeQuery = 144,
TypeLiteral = 145,
ArrayType = 146,
TupleType = 147,
UnionType = 148,
ParenthesizedType = 149,
ObjectBindingPattern = 150,
ArrayBindingPattern = 151,
BindingElement = 152,
ArrayLiteralExpression = 153,
ObjectLiteralExpression = 154,
PropertyAccessExpression = 155,
ElementAccessExpression = 156,
CallExpression = 157,
NewExpression = 158,
TaggedTemplateExpression = 159,
TypeAssertionExpression = 160,
ParenthesizedExpression = 161,
FunctionExpression = 162,
ArrowFunction = 163,
DeleteExpression = 164,
TypeOfExpression = 165,
VoidExpression = 166,
PrefixUnaryExpression = 167,
PostfixUnaryExpression = 168,
BinaryExpression = 169,
ConditionalExpression = 170,
TemplateExpression = 171,
YieldExpression = 172,
SpreadElementExpression = 173,
OmittedExpression = 174,
TemplateSpan = 175,
Block = 176,
VariableStatement = 177,
EmptyStatement = 178,
ExpressionStatement = 179,
IfStatement = 180,
DoStatement = 181,
WhileStatement = 182,
ForStatement = 183,
ForInStatement = 184,
ForOfStatement = 185,
ContinueStatement = 186,
BreakStatement = 187,
ReturnStatement = 188,
WithStatement = 189,
SwitchStatement = 190,
LabeledStatement = 191,
ThrowStatement = 192,
TryStatement = 193,
DebuggerStatement = 194,
VariableDeclaration = 195,
VariableDeclarationList = 196,
FunctionDeclaration = 197,
ClassDeclaration = 198,
InterfaceDeclaration = 199,
TypeAliasDeclaration = 200,
EnumDeclaration = 201,
ModuleDeclaration = 202,
ModuleBlock = 203,
CaseBlock = 204,
ImportEqualsDeclaration = 205,
ImportDeclaration = 206,
ImportClause = 207,
NamespaceImport = 208,
NamedImports = 209,
ImportSpecifier = 210,
ExportAssignment = 211,
ExportDeclaration = 212,
NamedExports = 213,
ExportSpecifier = 214,
MissingDeclaration = 215,
ExternalModuleReference = 216,
CaseClause = 217,
DefaultClause = 218,
HeritageClause = 219,
CatchClause = 220,
PropertyAssignment = 221,
ShorthandPropertyAssignment = 222,
EnumMember = 223,
SourceFile = 224,
SyntaxList = 225,
Count = 226,
FirstAssignment = 53,
LastAssignment = 64,
FirstReservedWord = 66,
LastReservedWord = 101,
FirstKeyword = 66,
LastKeyword = 125,
FirstFutureReservedWord = 103,
LastFutureReservedWord = 111,
FirstTypeNode = 141,
LastTypeNode = 149,
FirstPunctuation = 14,
LastPunctuation = 63,
LastPunctuation = 64,
FirstToken = 0,
LastToken = 124,
LastToken = 125,
FirstTriviaToken = 2,
LastTriviaToken = 6,
FirstLiteralToken = 7,
@@ -373,8 +376,8 @@ declare module "typescript" {
FirstTemplateToken = 10,
LastTemplateToken = 13,
FirstBinaryOperator = 24,
LastBinaryOperator = 63,
FirstNode = 125,
LastBinaryOperator = 64,
FirstNode = 126,
}
const enum NodeFlags {
Export = 1,
@@ -399,10 +402,11 @@ declare module "typescript" {
DisallowIn = 2,
Yield = 4,
GeneratorParameter = 8,
ThisNodeHasError = 16,
ParserGeneratedFlags = 31,
ThisNodeOrAnySubNodesHasError = 32,
HasAggregatedChildData = 64,
Decorator = 16,
ThisNodeHasError = 32,
ParserGeneratedFlags = 63,
ThisNodeOrAnySubNodesHasError = 64,
HasAggregatedChildData = 128,
}
const enum RelationComparisonResult {
Succeeded = 1,
@@ -413,6 +417,7 @@ declare module "typescript" {
kind: SyntaxKind;
flags: NodeFlags;
parserContextFlags?: ParserContextFlags;
decorators?: NodeArray<Decorator>;
modifiers?: ModifiersArray;
id?: number;
parent?: Node;
@@ -443,6 +448,9 @@ declare module "typescript" {
interface ComputedPropertyName extends Node {
expression: Expression;
}
interface Decorator extends Node {
expression: LeftHandSideExpression;
}
interface TypeParameterDeclaration extends Declaration {
name: Identifier;
constraint?: TypeNode;
@@ -533,6 +541,12 @@ declare module "typescript" {
_accessorDeclarationBrand: any;
body: Block;
}
interface MergedAccessorDeclarations {
getAccessor: AccessorDeclaration;
setAccessor: AccessorDeclaration;
firstAccessor: AccessorDeclaration;
secondAccessor: AccessorDeclaration;
}
interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement {
_indexSignatureDeclarationBrand: any;
}
@@ -1129,6 +1143,7 @@ declare module "typescript" {
ContextChecked = 64,
EnumValuesComputed = 128,
BlockScopedBindingInLoop = 256,
EmitDecorate = 512,
}
interface NodeLinks {
resolvedType?: Type;

View File

@@ -620,562 +620,571 @@ declare module "typescript" {
>EqualsGreaterThanToken : SyntaxKind
PlusToken = 33,
PlusToken = 33,
>PlusToken : SyntaxKind
MinusToken = 34,
>MinusToken : SyntaxKind
AsteriskToken = 35,
>MinusToken : SyntaxKind
>AsteriskToken : SyntaxKind
SlashToken = 36,
>SlashToken : SyntaxKind
SlashToken = 36,
PercentToken = 37,
>PercentToken : SyntaxKind
PlusPlusToken = 38,
>PercentToken : SyntaxKind
>PlusPlusToken : SyntaxKind
MinusMinusToken = 39,
>MinusMinusToken : SyntaxKind
MinusMinusToken = 39,
LessThanLessThanToken = 40,
>LessThanLessThanToken : SyntaxKind
GreaterThanGreaterThanToken = 41,
>LessThanLessThanToken : SyntaxKind
>GreaterThanGreaterThanToken : SyntaxKind
GreaterThanGreaterThanGreaterThanToken = 42,
>GreaterThanGreaterThanGreaterThanToken : SyntaxKind
GreaterThanGreaterThanGreaterThanToken = 42,
AmpersandToken = 43,
>AmpersandToken : SyntaxKind
BarToken = 44,
>AmpersandToken : SyntaxKind
>BarToken : SyntaxKind
CaretToken = 45,
>CaretToken : SyntaxKind
CaretToken = 45,
ExclamationToken = 46,
>ExclamationToken : SyntaxKind
TildeToken = 47,
>ExclamationToken : SyntaxKind
>TildeToken : SyntaxKind
AmpersandAmpersandToken = 48,
>AmpersandAmpersandToken : SyntaxKind
AmpersandAmpersandToken = 48,
BarBarToken = 49,
>BarBarToken : SyntaxKind
QuestionToken = 50,
>BarBarToken : SyntaxKind
>QuestionToken : SyntaxKind
ColonToken = 51,
>ColonToken : SyntaxKind
ColonToken = 51,
AtToken = 52,
>AtToken : SyntaxKind
EqualsToken = 53,
>EqualsToken : SyntaxKind
>EqualsToken : SyntaxKind
PlusEqualsToken = 54,
>PlusEqualsToken : SyntaxKind
MinusEqualsToken = 54,
MinusEqualsToken = 55,
>MinusEqualsToken : SyntaxKind
AsteriskEqualsToken = 56,
>AsteriskEqualsToken : SyntaxKind
>AsteriskEqualsToken : SyntaxKind
SlashEqualsToken = 57,
>SlashEqualsToken : SyntaxKind
PercentEqualsToken = 57,
PercentEqualsToken = 58,
>PercentEqualsToken : SyntaxKind
LessThanLessThanEqualsToken = 59,
>LessThanLessThanEqualsToken : SyntaxKind
>LessThanLessThanEqualsToken : SyntaxKind
GreaterThanGreaterThanEqualsToken = 60,
>GreaterThanGreaterThanEqualsToken : SyntaxKind
GreaterThanGreaterThanGreaterThanEqualsToken = 60,
GreaterThanGreaterThanGreaterThanEqualsToken = 61,
>GreaterThanGreaterThanGreaterThanEqualsToken : SyntaxKind
AmpersandEqualsToken = 62,
>AmpersandEqualsToken : SyntaxKind
>AmpersandEqualsToken : SyntaxKind
BarEqualsToken = 63,
>BarEqualsToken : SyntaxKind
CaretEqualsToken = 63,
CaretEqualsToken = 64,
>CaretEqualsToken : SyntaxKind
Identifier = 65,
>Identifier : SyntaxKind
>Identifier : SyntaxKind
BreakKeyword = 66,
>BreakKeyword : SyntaxKind
CaseKeyword = 66,
CaseKeyword = 67,
>CaseKeyword : SyntaxKind
CatchKeyword = 68,
>CatchKeyword : SyntaxKind
>CatchKeyword : SyntaxKind
ClassKeyword = 69,
>ClassKeyword : SyntaxKind
ConstKeyword = 69,
ConstKeyword = 70,
>ConstKeyword : SyntaxKind
ContinueKeyword = 71,
>ContinueKeyword : SyntaxKind
>ContinueKeyword : SyntaxKind
DebuggerKeyword = 72,
>DebuggerKeyword : SyntaxKind
DefaultKeyword = 72,
DefaultKeyword = 73,
>DefaultKeyword : SyntaxKind
DeleteKeyword = 74,
>DeleteKeyword : SyntaxKind
>DeleteKeyword : SyntaxKind
DoKeyword = 75,
>DoKeyword : SyntaxKind
ElseKeyword = 75,
ElseKeyword = 76,
>ElseKeyword : SyntaxKind
EnumKeyword = 77,
>EnumKeyword : SyntaxKind
>EnumKeyword : SyntaxKind
ExportKeyword = 78,
>ExportKeyword : SyntaxKind
ExtendsKeyword = 78,
ExtendsKeyword = 79,
>ExtendsKeyword : SyntaxKind
FalseKeyword = 80,
>FalseKeyword : SyntaxKind
>FalseKeyword : SyntaxKind
FinallyKeyword = 81,
>FinallyKeyword : SyntaxKind
ForKeyword = 81,
ForKeyword = 82,
>ForKeyword : SyntaxKind
FunctionKeyword = 83,
>FunctionKeyword : SyntaxKind
>FunctionKeyword : SyntaxKind
IfKeyword = 84,
>IfKeyword : SyntaxKind
ImportKeyword = 84,
ImportKeyword = 85,
>ImportKeyword : SyntaxKind
InKeyword = 86,
>InKeyword : SyntaxKind
>InKeyword : SyntaxKind
InstanceOfKeyword = 87,
>InstanceOfKeyword : SyntaxKind
NewKeyword = 87,
NewKeyword = 88,
>NewKeyword : SyntaxKind
NullKeyword = 89,
>NullKeyword : SyntaxKind
>NullKeyword : SyntaxKind
ReturnKeyword = 90,
>ReturnKeyword : SyntaxKind
SuperKeyword = 90,
SuperKeyword = 91,
>SuperKeyword : SyntaxKind
SwitchKeyword = 92,
>SwitchKeyword : SyntaxKind
>SwitchKeyword : SyntaxKind
ThisKeyword = 93,
>ThisKeyword : SyntaxKind
ThrowKeyword = 94,
ThrowKeyword = 93,
>ThrowKeyword : SyntaxKind
TrueKeyword = 95,
>TrueKeyword : SyntaxKind
>TrueKeyword : SyntaxKind
TryKeyword = 96,
>TryKeyword : SyntaxKind
TypeOfKeyword = 97,
TypeOfKeyword = 96,
>TypeOfKeyword : SyntaxKind
VarKeyword = 98,
>VarKeyword : SyntaxKind
>VarKeyword : SyntaxKind
VoidKeyword = 99,
>VoidKeyword : SyntaxKind
WhileKeyword = 100,
WhileKeyword = 99,
>WhileKeyword : SyntaxKind
WithKeyword = 101,
>WithKeyword : SyntaxKind
>WithKeyword : SyntaxKind
AsKeyword = 102,
>AsKeyword : SyntaxKind
ImplementsKeyword = 103,
ImplementsKeyword = 102,
>ImplementsKeyword : SyntaxKind
InterfaceKeyword = 104,
>InterfaceKeyword : SyntaxKind
>InterfaceKeyword : SyntaxKind
LetKeyword = 105,
>LetKeyword : SyntaxKind
PackageKeyword = 106,
PackageKeyword = 105,
>PackageKeyword : SyntaxKind
PrivateKeyword = 107,
>PrivateKeyword : SyntaxKind
>PrivateKeyword : SyntaxKind
ProtectedKeyword = 108,
>ProtectedKeyword : SyntaxKind
PublicKeyword = 109,
PublicKeyword = 108,
>PublicKeyword : SyntaxKind
StaticKeyword = 110,
>StaticKeyword : SyntaxKind
>StaticKeyword : SyntaxKind
YieldKeyword = 111,
>YieldKeyword : SyntaxKind
AnyKeyword = 112,
AnyKeyword = 111,
>AnyKeyword : SyntaxKind
BooleanKeyword = 113,
>BooleanKeyword : SyntaxKind
>BooleanKeyword : SyntaxKind
ConstructorKeyword = 114,
>ConstructorKeyword : SyntaxKind
DeclareKeyword = 115,
DeclareKeyword = 114,
>DeclareKeyword : SyntaxKind
GetKeyword = 116,
>GetKeyword : SyntaxKind
>GetKeyword : SyntaxKind
ModuleKeyword = 117,
>ModuleKeyword : SyntaxKind
RequireKeyword = 118,
RequireKeyword = 117,
>RequireKeyword : SyntaxKind
NumberKeyword = 119,
>NumberKeyword : SyntaxKind
>NumberKeyword : SyntaxKind
SetKeyword = 120,
>SetKeyword : SyntaxKind
StringKeyword = 121,
StringKeyword = 120,
>StringKeyword : SyntaxKind
SymbolKeyword = 122,
>SymbolKeyword : SyntaxKind
>SymbolKeyword : SyntaxKind
TypeKeyword = 123,
>TypeKeyword : SyntaxKind
FromKeyword = 124,
FromKeyword = 123,
>FromKeyword : SyntaxKind
OfKeyword = 125,
>OfKeyword : SyntaxKind
>OfKeyword : SyntaxKind
QualifiedName = 126,
>QualifiedName : SyntaxKind
ComputedPropertyName = 127,
ComputedPropertyName = 126,
>ComputedPropertyName : SyntaxKind
TypeParameter = 128,
>TypeParameter : SyntaxKind
>TypeParameter : SyntaxKind
Parameter = 129,
>Parameter : SyntaxKind
Decorator = 130,
PropertySignature = 129,
>Decorator : SyntaxKind
PropertySignature = 131,
>PropertySignature : SyntaxKind
>PropertyDeclaration : SyntaxKind
PropertyDeclaration = 132,
>PropertyDeclaration : SyntaxKind
MethodSignature = 133,
MethodDeclaration = 132,
>MethodSignature : SyntaxKind
MethodDeclaration = 134,
>MethodDeclaration : SyntaxKind
>Constructor : SyntaxKind
Constructor = 135,
>Constructor : SyntaxKind
GetAccessor = 136,
SetAccessor = 135,
>GetAccessor : SyntaxKind
SetAccessor = 137,
>SetAccessor : SyntaxKind
>CallSignature : SyntaxKind
CallSignature = 138,
>CallSignature : SyntaxKind
ConstructSignature = 139,
IndexSignature = 138,
>ConstructSignature : SyntaxKind
IndexSignature = 140,
>IndexSignature : SyntaxKind
>TypeReference : SyntaxKind
TypeReference = 141,
>TypeReference : SyntaxKind
FunctionType = 142,
ConstructorType = 141,
>FunctionType : SyntaxKind
ConstructorType = 143,
>ConstructorType : SyntaxKind
>TypeQuery : SyntaxKind
TypeQuery = 144,
>TypeQuery : SyntaxKind
TypeLiteral = 145,
ArrayType = 144,
>TypeLiteral : SyntaxKind
ArrayType = 146,
>ArrayType : SyntaxKind
>TupleType : SyntaxKind
TupleType = 147,
>TupleType : SyntaxKind
UnionType = 148,
ParenthesizedType = 147,
>UnionType : SyntaxKind
ParenthesizedType = 149,
>ParenthesizedType : SyntaxKind
>ObjectBindingPattern : SyntaxKind
ObjectBindingPattern = 150,
>ObjectBindingPattern : SyntaxKind
ArrayBindingPattern = 151,
BindingElement = 150,
>ArrayBindingPattern : SyntaxKind
BindingElement = 152,
>BindingElement : SyntaxKind
>ArrayLiteralExpression : SyntaxKind
ArrayLiteralExpression = 153,
>ArrayLiteralExpression : SyntaxKind
ObjectLiteralExpression = 154,
PropertyAccessExpression = 153,
>ObjectLiteralExpression : SyntaxKind
PropertyAccessExpression = 155,
>PropertyAccessExpression : SyntaxKind
ElementAccessExpression = 156,
>ElementAccessExpression : SyntaxKind
>ElementAccessExpression : SyntaxKind
CallExpression = 157,
>CallExpression : SyntaxKind
NewExpression = 158,
NewExpression = 156,
>NewExpression : SyntaxKind
TaggedTemplateExpression = 159,
>TaggedTemplateExpression : SyntaxKind
>TaggedTemplateExpression : SyntaxKind
TypeAssertionExpression = 160,
>TypeAssertionExpression : SyntaxKind
ParenthesizedExpression = 161,
ParenthesizedExpression = 159,
>ParenthesizedExpression : SyntaxKind
FunctionExpression = 162,
>FunctionExpression : SyntaxKind
>FunctionExpression : SyntaxKind
ArrowFunction = 163,
>ArrowFunction : SyntaxKind
DeleteExpression = 164,
DeleteExpression = 162,
>DeleteExpression : SyntaxKind
TypeOfExpression = 165,
>TypeOfExpression : SyntaxKind
>TypeOfExpression : SyntaxKind
VoidExpression = 166,
>VoidExpression : SyntaxKind
PrefixUnaryExpression = 167,
PrefixUnaryExpression = 165,
>PrefixUnaryExpression : SyntaxKind
PostfixUnaryExpression = 168,
>PostfixUnaryExpression : SyntaxKind
>PostfixUnaryExpression : SyntaxKind
BinaryExpression = 169,
>BinaryExpression : SyntaxKind
ConditionalExpression = 170,
ConditionalExpression = 168,
>ConditionalExpression : SyntaxKind
TemplateExpression = 171,
>TemplateExpression : SyntaxKind
YieldExpression = 172,
>YieldExpression : SyntaxKind
SpreadElementExpression = 173,
>SpreadElementExpression : SyntaxKind
OmittedExpression = 174,
>OmittedExpression : SyntaxKind
@@ -1199,10 +1208,10 @@ declare module "typescript" {
>ExpressionStatement : SyntaxKind
IfStatement = 180,
>IfStatement : SyntaxKind
>IfStatement : SyntaxKind
DoStatement = 181,
>DoStatement : SyntaxKind
@@ -1271,16 +1280,19 @@ declare module "typescript" {
>FunctionDeclaration : SyntaxKind
ClassDeclaration = 198,
>ClassDeclaration : SyntaxKind
InterfaceDeclaration = 199,
>ClassDeclaration : SyntaxKind
>InterfaceDeclaration : SyntaxKind
TypeAliasDeclaration = 200,
>TypeAliasDeclaration : SyntaxKind
TypeAliasDeclaration = 198,
EnumDeclaration = 201,
>EnumDeclaration : SyntaxKind
@@ -1311,6 +1323,11 @@ declare module "typescript" {
NamespaceImport = 208,
>NamespaceImport : SyntaxKind
NamedImports = 209,
>NamedImports : SyntaxKind
ImportSpecifier = 210,
>ImportSpecifier : SyntaxKind
@@ -1405,6 +1422,14 @@ declare module "typescript" {
FirstFutureReservedWord = 103,
>FirstFutureReservedWord : SyntaxKind
LastFutureReservedWord = 111,
>LastFutureReservedWord : SyntaxKind
FirstTypeNode = 141,
>FirstTypeNode : SyntaxKind
LastTypeNode = 149,
@@ -1684,6 +1709,25 @@ declare module "typescript" {
text: string;
>text : string
}
interface QualifiedName extends Node {
>QualifiedName : QualifiedName
>Node : Node
left: EntityName;
>left : Identifier | QualifiedName
>EntityName : Identifier | QualifiedName
right: Identifier;
>right : Identifier
>Identifier : Identifier
}
type EntityName = Identifier | QualifiedName;
>EntityName : Identifier | QualifiedName
>Identifier : Identifier
@@ -3703,6 +3747,9 @@ declare module "typescript" {
getPropertiesOfType(type: Type): Symbol[];
>getPropertiesOfType : (type: Type) => Symbol[]
>type : Type
>Type : Type
>Symbol : Symbol
getPropertyOfType(type: Type, propertyName: string): Symbol;

View File

@@ -20,5 +20,5 @@ var C = (function () {
_a)[0]] = function () {
};
return C;
var _a;
})();
var _a;

View File

@@ -35,5 +35,5 @@ var C = (function (_super) {
_a)[0]] = function () {
};
return C;
var _a;
})(Base);
var _a;

View File

@@ -0,0 +1,16 @@
tests/cases/conformance/decorators/invalid/decoratorOnArrowFunction.ts(3,9): error TS1109: Expression expected.
tests/cases/conformance/decorators/invalid/decoratorOnArrowFunction.ts(3,16): error TS1146: Declaration expected.
tests/cases/conformance/decorators/invalid/decoratorOnArrowFunction.ts(3,17): error TS1128: Declaration or statement expected.
==== tests/cases/conformance/decorators/invalid/decoratorOnArrowFunction.ts (3 errors) ====
declare function dec<T>(target: T): T;
var F = @dec () => {
~
!!! error TS1109: Expression expected.
!!! error TS1146: Declaration expected.
~~
!!! error TS1128: Declaration or statement expected.
}

View File

@@ -0,0 +1,10 @@
//// [decoratorOnArrowFunction.ts]
declare function dec<T>(target: T): T;
var F = @dec () => {
}
//// [decoratorOnArrowFunction.js]
var F = ;
{
}

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClass1.ts]
declare function dec<T>(target: T): T;
@dec
class C {
}
//// [decoratorOnClass1.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
C = __decorate([dec], C);
return C;
})();

View File

@@ -0,0 +1,14 @@
=== tests/cases/conformance/decorators/class/decoratorOnClass1.ts ===
declare function dec<T>(target: T): T;
>dec : <T>(target: T) => T
>T : T
>target : T
>T : T
>T : T
@dec
>dec : unknown
class C {
>C : C
}

View File

@@ -0,0 +1,28 @@
//// [decoratorOnClass2.ts]
declare function dec<T>(target: T): T;
@dec
export class C {
}
//// [decoratorOnClass2.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
C = __decorate([dec], C);
return C;
})();
exports.C = C;

View File

@@ -0,0 +1,14 @@
=== tests/cases/conformance/decorators/class/decoratorOnClass2.ts ===
declare function dec<T>(target: T): T;
>dec : <T>(target: T) => T
>T : T
>target : T
>T : T
>T : T
@dec
>dec : unknown
export class C {
>C : C
}

View File

@@ -0,0 +1,12 @@
tests/cases/conformance/decorators/class/decoratorOnClass3.ts(3,1): error TS1128: Declaration or statement expected.
==== tests/cases/conformance/decorators/class/decoratorOnClass3.ts (1 errors) ====
declare function dec<T>(target: T): T;
export
~~~~~~
!!! error TS1128: Declaration or statement expected.
@dec
class C {
}

View File

@@ -0,0 +1,28 @@
//// [decoratorOnClass3.ts]
declare function dec<T>(target: T): T;
export
@dec
class C {
}
//// [decoratorOnClass3.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
C = __decorate([dec], C);
return C;
})();

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClass4.ts]
declare function dec(): <T>(target: T) => T;
@dec()
class C {
}
//// [decoratorOnClass4.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
C = __decorate([dec()], C);
return C;
})();

View File

@@ -0,0 +1,15 @@
=== tests/cases/conformance/decorators/class/decoratorOnClass4.ts ===
declare function dec(): <T>(target: T) => T;
>dec : () => <T>(target: T) => T
>T : T
>target : T
>T : T
>T : T
@dec()
>dec() : <T>(target: T) => T
>dec : () => <T>(target: T) => T
class C {
>C : C
}

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClass5.ts]
declare function dec(): <T>(target: T) => T;
@dec()
class C {
}
//// [decoratorOnClass5.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
C = __decorate([dec()], C);
return C;
})();

View File

@@ -0,0 +1,15 @@
=== tests/cases/conformance/decorators/class/decoratorOnClass5.ts ===
declare function dec(): <T>(target: T) => T;
>dec : () => <T>(target: T) => T
>T : T
>target : T
>T : T
>T : T
@dec()
>dec() : <T>(target: T) => T
>dec : () => <T>(target: T) => T
class C {
>C : C
}

View File

@@ -0,0 +1,11 @@
tests/cases/conformance/decorators/class/decoratorOnClass8.ts(3,1): error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: typeof C) => void | typeof C'.
==== tests/cases/conformance/decorators/class/decoratorOnClass8.ts (1 errors) ====
declare function dec(): (target: Function, paramIndex: number) => void;
@dec()
~~~~~~
!!! error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: typeof C) => void | typeof C'.
class C {
}

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClass8.ts]
declare function dec(): (target: Function, paramIndex: number) => void;
@dec()
class C {
}
//// [decoratorOnClass8.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
C = __decorate([dec()], C);
return C;
})();

View File

@@ -0,0 +1,34 @@
//// [decoratorOnClassAccessor1.ts]
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
@dec get accessor() { return 1; }
}
//// [decoratorOnClassAccessor1.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "accessor", {
get: function () {
return 1;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, "accessor", __decorate([dec], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor")));
return C;
})();

View File

@@ -0,0 +1,19 @@
=== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor1.ts ===
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>T : T
>target : any
>propertyKey : string
>descriptor : TypedPropertyDescriptor<T>
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
class C {
>C : C
@dec get accessor() { return 1; }
>dec : unknown
>accessor : number
}

View File

@@ -0,0 +1,34 @@
//// [decoratorOnClassAccessor2.ts]
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
@dec public get accessor() { return 1; }
}
//// [decoratorOnClassAccessor2.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "accessor", {
get: function () {
return 1;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, "accessor", __decorate([dec], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor")));
return C;
})();

View File

@@ -0,0 +1,19 @@
=== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor2.ts ===
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>T : T
>target : any
>propertyKey : string
>descriptor : TypedPropertyDescriptor<T>
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
class C {
>C : C
@dec public get accessor() { return 1; }
>dec : unknown
>accessor : number
}

View File

@@ -0,0 +1,35 @@
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,5): error TS2304: Cannot find name 'public'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,12): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,16): error TS1146: Declaration expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,17): error TS2304: Cannot find name 'get'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,21): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,21): error TS2304: Cannot find name 'accessor'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(4,32): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts(5,1): error TS1128: Declaration or statement expected.
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor3.ts (9 errors) ====
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
public @dec get accessor() { return 1; }
~~~~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
~
!!! error TS1005: ';' expected.
!!! error TS1146: Declaration expected.
~~~
!!! error TS2304: Cannot find name 'get'.
~~~~~~~~
!!! error TS1005: ';' expected.
~~~~~~~~
!!! error TS2304: Cannot find name 'accessor'.
~
!!! error TS1005: ';' expected.
}
~
!!! error TS1128: Declaration or statement expected.

View File

@@ -0,0 +1,19 @@
//// [decoratorOnClassAccessor3.ts]
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
public @dec get accessor() { return 1; }
}
//// [decoratorOnClassAccessor3.js]
var C = (function () {
function C() {
}
return C;
})();
public;
get;
accessor();
{
return 1;
}

View File

@@ -0,0 +1,33 @@
//// [decoratorOnClassAccessor4.ts]
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
@dec set accessor(value: number) { }
}
//// [decoratorOnClassAccessor4.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "accessor", {
set: function (value) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, "accessor", __decorate([dec], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor")));
return C;
})();

View File

@@ -0,0 +1,20 @@
=== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor4.ts ===
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>T : T
>target : any
>propertyKey : string
>descriptor : TypedPropertyDescriptor<T>
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
class C {
>C : C
@dec set accessor(value: number) { }
>dec : unknown
>accessor : number
>value : number
}

View File

@@ -0,0 +1,33 @@
//// [decoratorOnClassAccessor5.ts]
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
@dec public set accessor(value: number) { }
}
//// [decoratorOnClassAccessor5.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "accessor", {
set: function (value) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, "accessor", __decorate([dec], C.prototype, "accessor", Object.getOwnPropertyDescriptor(C.prototype, "accessor")));
return C;
})();

View File

@@ -0,0 +1,20 @@
=== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor5.ts ===
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>T : T
>target : any
>propertyKey : string
>descriptor : TypedPropertyDescriptor<T>
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
class C {
>C : C
@dec public set accessor(value: number) { }
>dec : unknown
>accessor : number
>value : number
}

View File

@@ -0,0 +1,44 @@
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,5): error TS2304: Cannot find name 'public'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,12): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,16): error TS1146: Declaration expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,17): error TS2304: Cannot find name 'set'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,21): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,21): error TS2304: Cannot find name 'accessor'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,30): error TS2304: Cannot find name 'value'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,35): error TS1005: ',' expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,37): error TS2304: Cannot find name 'number'.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(4,45): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts(5,1): error TS1128: Declaration or statement expected.
==== tests/cases/conformance/decorators/class/accessor/decoratorOnClassAccessor6.ts (12 errors) ====
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
public @dec set accessor(value: number) { }
~~~~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
~
!!! error TS1005: ';' expected.
!!! error TS1146: Declaration expected.
~~~
!!! error TS2304: Cannot find name 'set'.
~~~~~~~~
!!! error TS1005: ';' expected.
~~~~~~~~
!!! error TS2304: Cannot find name 'accessor'.
~~~~~
!!! error TS2304: Cannot find name 'value'.
~
!!! error TS1005: ',' expected.
~~~~~~
!!! error TS2304: Cannot find name 'number'.
~
!!! error TS1005: ';' expected.
}
~
!!! error TS1128: Declaration or statement expected.

View File

@@ -0,0 +1,18 @@
//// [decoratorOnClassAccessor6.ts]
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
public @dec set accessor(value: number) { }
}
//// [decoratorOnClassAccessor6.js]
var C = (function () {
function C() {
}
return C;
})();
public;
set;
accessor(value, number);
{
}

View File

@@ -0,0 +1,11 @@
tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor1.ts(4,5): error TS1206: Decorators are not valid here.
==== tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor1.ts (1 errors) ====
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
@dec constructor() {}
~~~~~~~~~~~~~~~~~~~~~
!!! error TS1206: Decorators are not valid here.
}

View File

@@ -0,0 +1,13 @@
//// [decoratorOnClassConstructor1.ts]
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
@dec constructor() {}
}
//// [decoratorOnClassConstructor1.js]
var C = (function () {
function C() {
}
return C;
})();

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClassConstructorParameter1.ts]
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
class C {
constructor(@dec p: number) {}
}
//// [decoratorOnClassConstructorParameter1.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C(p) {
}
__decorate([dec], C, void 0, 0);
return C;
})();

View File

@@ -0,0 +1,15 @@
=== tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter1.ts ===
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
>dec : (target: Function, propertyKey: string | symbol, parameterIndex: number) => void
>target : Function
>Function : Function
>propertyKey : string | symbol
>parameterIndex : number
class C {
>C : C
constructor(@dec p: number) {}
>dec : unknown
>p : number
}

View File

@@ -0,0 +1,11 @@
tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts(4,24): error TS1005: ',' expected.
==== tests/cases/conformance/decorators/class/constructor/parameter/decoratorOnClassConstructorParameter4.ts (1 errors) ====
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
class C {
constructor(public @dec p: number) {}
~
!!! error TS1005: ',' expected.
}

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClassConstructorParameter4.ts]
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
class C {
constructor(public @dec p: number) {}
}
//// [decoratorOnClassConstructorParameter4.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C(public, p) {
}
__decorate([dec], C, void 0, 1);
return C;
})();

View File

@@ -0,0 +1,29 @@
//// [decoratorOnClassMethod1.ts]
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
@dec method() {}
}
//// [decoratorOnClassMethod1.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
C.prototype.method = function () {
};
Object.defineProperty(C.prototype, "method", __decorate([dec], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method")));
return C;
})();

View File

@@ -0,0 +1,19 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod1.ts ===
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>T : T
>target : any
>propertyKey : string
>descriptor : TypedPropertyDescriptor<T>
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
class C {
>C : C
@dec method() {}
>dec : unknown
>method : () => void
}

View File

@@ -0,0 +1,17 @@
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts(4,5): error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<() => void>) => void | TypedPropertyDescriptor<() => void>'.
Types of parameters 'paramIndex' and 'propertyKey' are incompatible.
Type 'number' is not assignable to type 'string | symbol'.
Type 'number' is not assignable to type 'symbol'.
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod10.ts (1 errors) ====
declare function dec(target: Function, paramIndex: number): void;
class C {
@dec method() {}
~~~~
!!! error TS2322: Type '(target: Function, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<() => void>) => void | TypedPropertyDescriptor<() => void>'.
!!! error TS2322: Types of parameters 'paramIndex' and 'propertyKey' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string | symbol'.
!!! error TS2322: Type 'number' is not assignable to type 'symbol'.
}

View File

@@ -0,0 +1,29 @@
//// [decoratorOnClassMethod10.ts]
declare function dec(target: Function, paramIndex: number): void;
class C {
@dec method() {}
}
//// [decoratorOnClassMethod10.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
C.prototype.method = function () {
};
Object.defineProperty(C.prototype, "method", __decorate([dec], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method")));
return C;
})();

View File

@@ -0,0 +1,29 @@
//// [decoratorOnClassMethod2.ts]
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
@dec public method() {}
}
//// [decoratorOnClassMethod2.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
C.prototype.method = function () {
};
Object.defineProperty(C.prototype, "method", __decorate([dec], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method")));
return C;
})();

View File

@@ -0,0 +1,19 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod2.ts ===
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>T : T
>target : any
>propertyKey : string
>descriptor : TypedPropertyDescriptor<T>
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
class C {
>C : C
@dec public method() {}
>dec : unknown
>method : () => void
}

View File

@@ -0,0 +1,29 @@
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,5): error TS2304: Cannot find name 'public'.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,12): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,16): error TS1146: Declaration expected.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,17): error TS2304: Cannot find name 'method'.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(4,26): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts(5,1): error TS1128: Declaration or statement expected.
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod3.ts (7 errors) ====
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
public @dec method() {}
~~~~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
~
!!! error TS1005: ';' expected.
!!! error TS1146: Declaration expected.
~~~~~~
!!! error TS2304: Cannot find name 'method'.
~
!!! error TS1005: ';' expected.
}
~
!!! error TS1128: Declaration or statement expected.

View File

@@ -0,0 +1,17 @@
//// [decoratorOnClassMethod3.ts]
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
public @dec method() {}
}
//// [decoratorOnClassMethod3.js]
var C = (function () {
function C() {
}
return C;
})();
public;
method();
{
}

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClassMethod4.ts]
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
@dec ["method"]() {}
}
//// [decoratorOnClassMethod4.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
class C {
[_a = "method"]() {
}
}
Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)));
var _a;

View File

@@ -0,0 +1,18 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod4.ts ===
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>T : T
>target : any
>propertyKey : string
>descriptor : TypedPropertyDescriptor<T>
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
class C {
>C : C
@dec ["method"]() {}
>dec : unknown
}

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClassMethod5.ts]
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
class C {
@dec() ["method"]() {}
}
//// [decoratorOnClassMethod5.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
class C {
[_a = "method"]() {
}
}
Object.defineProperty(C.prototype, _a, __decorate([dec()], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)));
var _a;

View File

@@ -0,0 +1,19 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod5.ts ===
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>T : T
>target : any
>propertyKey : string
>descriptor : TypedPropertyDescriptor<T>
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
class C {
>C : C
@dec() ["method"]() {}
>dec() : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
}

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClassMethod6.ts]
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
class C {
@dec ["method"]() {}
}
//// [decoratorOnClassMethod6.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
class C {
[_a = "method"]() {
}
}
Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)));
var _a;

View File

@@ -0,0 +1,18 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod6.ts ===
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>T : T
>target : any
>propertyKey : string
>descriptor : TypedPropertyDescriptor<T>
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
class C {
>C : C
@dec ["method"]() {}
>dec : unknown
}

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClassMethod7.ts]
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
class C {
@dec public ["method"]() {}
}
//// [decoratorOnClassMethod7.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
class C {
[_a = "method"]() {
}
}
Object.defineProperty(C.prototype, _a, __decorate([dec], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)));
var _a;

View File

@@ -0,0 +1,18 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod7.ts ===
declare function dec<T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>): TypedPropertyDescriptor<T>;
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>T : T
>target : any
>propertyKey : string
>descriptor : TypedPropertyDescriptor<T>
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
>T : T
class C {
>C : C
@dec public ["method"]() {}
>dec : unknown
}

View File

@@ -0,0 +1,29 @@
//// [decoratorOnClassMethod8.ts]
declare function dec<T>(target: T): T;
class C {
@dec method() {}
}
//// [decoratorOnClassMethod8.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
C.prototype.method = function () {
};
Object.defineProperty(C.prototype, "method", __decorate([dec], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method")));
return C;
})();

View File

@@ -0,0 +1,15 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod8.ts ===
declare function dec<T>(target: T): T;
>dec : <T>(target: T) => T
>T : T
>target : T
>T : T
>T : T
class C {
>C : C
@dec method() {}
>dec : unknown
>method : () => void
}

View File

@@ -0,0 +1,29 @@
//// [decoratorOnClassMethodParameter1.ts]
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
class C {
method(@dec p: number) {}
}
//// [decoratorOnClassMethodParameter1.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
C.prototype.method = function (p) {
};
__decorate([dec], C.prototype, "method", 0);
return C;
})();

View File

@@ -0,0 +1,16 @@
=== tests/cases/conformance/decorators/class/method/parameter/decoratorOnClassMethodParameter1.ts ===
declare function dec(target: Function, propertyKey: string | symbol, parameterIndex: number): void;
>dec : (target: Function, propertyKey: string | symbol, parameterIndex: number) => void
>target : Function
>Function : Function
>propertyKey : string | symbol
>parameterIndex : number
class C {
>C : C
method(@dec p: number) {}
>method : (p: number) => void
>dec : unknown
>p : number
}

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClassProperty1.ts]
declare function dec(target: any, propertyKey: string): void;
class C {
@dec prop;
}
//// [decoratorOnClassProperty1.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
__decorate([dec], C.prototype, "prop");
return C;
})();

View File

@@ -0,0 +1,13 @@
=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty1.ts ===
declare function dec(target: any, propertyKey: string): void;
>dec : (target: any, propertyKey: string) => void
>target : any
>propertyKey : string
class C {
>C : C
@dec prop;
>dec : unknown
>prop : any
}

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClassProperty10.ts]
declare function dec(): <T>(target: any, propertyKey: string) => void;
class C {
@dec() prop;
}
//// [decoratorOnClassProperty10.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
__decorate([dec()], C.prototype, "prop");
return C;
})();

View File

@@ -0,0 +1,15 @@
=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty10.ts ===
declare function dec(): <T>(target: any, propertyKey: string) => void;
>dec : () => <T>(target: any, propertyKey: string) => void
>T : T
>target : any
>propertyKey : string
class C {
>C : C
@dec() prop;
>dec() : <T>(target: any, propertyKey: string) => void
>dec : () => <T>(target: any, propertyKey: string) => void
>prop : any
}

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClassProperty11.ts]
declare function dec(): <T>(target: any, propertyKey: string) => void;
class C {
@dec prop;
}
//// [decoratorOnClassProperty11.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
__decorate([dec], C.prototype, "prop");
return C;
})();

View File

@@ -0,0 +1,14 @@
=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty11.ts ===
declare function dec(): <T>(target: any, propertyKey: string) => void;
>dec : () => <T>(target: any, propertyKey: string) => void
>T : T
>target : any
>propertyKey : string
class C {
>C : C
@dec prop;
>dec : unknown
>prop : any
}

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClassProperty2.ts]
declare function dec(target: any, propertyKey: string): void;
class C {
@dec public prop;
}
//// [decoratorOnClassProperty2.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
__decorate([dec], C.prototype, "prop");
return C;
})();

View File

@@ -0,0 +1,13 @@
=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty2.ts ===
declare function dec(target: any, propertyKey: string): void;
>dec : (target: any, propertyKey: string) => void
>target : any
>propertyKey : string
class C {
>C : C
@dec public prop;
>dec : unknown
>prop : any
}

View File

@@ -0,0 +1,26 @@
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,5): error TS2304: Cannot find name 'public'.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,12): error TS1005: ';' expected.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,16): error TS1146: Declaration expected.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(4,17): error TS2304: Cannot find name 'prop'.
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts(5,1): error TS1128: Declaration or statement expected.
==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty3.ts (6 errors) ====
declare function dec(target: any, propertyKey: string): void;
class C {
public @dec prop;
~~~~~~
!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
~
!!! error TS1005: ';' expected.
!!! error TS1146: Declaration expected.
~~~~
!!! error TS2304: Cannot find name 'prop'.
}
~
!!! error TS1128: Declaration or statement expected.

View File

@@ -0,0 +1,15 @@
//// [decoratorOnClassProperty3.ts]
declare function dec(target: any, propertyKey: string): void;
class C {
public @dec prop;
}
//// [decoratorOnClassProperty3.js]
var C = (function () {
function C() {
}
return C;
})();
public;
prop;

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClassProperty6.ts]
declare function dec(target: Function): void;
class C {
@dec prop;
}
//// [decoratorOnClassProperty6.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
__decorate([dec], C.prototype, "prop");
return C;
})();

View File

@@ -0,0 +1,13 @@
=== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty6.ts ===
declare function dec(target: Function): void;
>dec : (target: Function) => void
>target : Function
>Function : Function
class C {
>C : C
@dec prop;
>dec : unknown
>prop : any
}

View File

@@ -0,0 +1,11 @@
tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts(4,5): error TS2322: Type '(target: Function, propertyKey: string | symbol, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol) => void'.
==== tests/cases/conformance/decorators/class/property/decoratorOnClassProperty7.ts (1 errors) ====
declare function dec(target: Function, propertyKey: string | symbol, paramIndex: number): void;
class C {
@dec prop;
~~~~
!!! error TS2322: Type '(target: Function, propertyKey: string | symbol, paramIndex: number) => void' is not assignable to type '(target: Object, propertyKey: string | symbol) => void'.
}

View File

@@ -0,0 +1,27 @@
//// [decoratorOnClassProperty7.ts]
declare function dec(target: Function, propertyKey: string | symbol, paramIndex: number): void;
class C {
@dec prop;
}
//// [decoratorOnClassProperty7.js]
var __decorate = this.__decorate || function (decorators, target, key, value) {
var kind = typeof (arguments.length == 2 ? value = target : value);
for (var i = decorators.length - 1; i >= 0; --i) {
var decorator = decorators[i];
switch (kind) {
case "function": value = decorator(value) || value; break;
case "number": decorator(target, key, value); break;
case "undefined": decorator(target, key); break;
case "object": value = decorator(target, key, value) || value; break;
}
}
return value;
};
var C = (function () {
function C() {
}
__decorate([dec], C.prototype, "prop");
return C;
})();

View File

@@ -0,0 +1,11 @@
tests/cases/conformance/decorators/invalid/decoratorOnEnum.ts(4,6): error TS1206: Decorators are not valid here.
==== tests/cases/conformance/decorators/invalid/decoratorOnEnum.ts (1 errors) ====
declare function dec<T>(target: T): T;
@dec
enum E {
~
!!! error TS1206: Decorators are not valid here.
}

View File

@@ -0,0 +1,11 @@
//// [decoratorOnEnum.ts]
declare function dec<T>(target: T): T;
@dec
enum E {
}
//// [decoratorOnEnum.js]
var E;
(function (E) {
})(E || (E = {}));

View File

@@ -0,0 +1,20 @@
tests/cases/conformance/decorators/invalid/decoratorOnEnum2.ts(4,5): error TS1132: Enum member expected.
tests/cases/conformance/decorators/invalid/decoratorOnEnum2.ts(4,9): error TS1146: Declaration expected.
tests/cases/conformance/decorators/invalid/decoratorOnEnum2.ts(4,10): error TS2304: Cannot find name 'A'.
tests/cases/conformance/decorators/invalid/decoratorOnEnum2.ts(5,1): error TS1128: Declaration or statement expected.
==== tests/cases/conformance/decorators/invalid/decoratorOnEnum2.ts (4 errors) ====
declare function dec<T>(target: T): T;
enum E {
@dec A
~
!!! error TS1132: Enum member expected.
!!! error TS1146: Declaration expected.
~
!!! error TS2304: Cannot find name 'A'.
}
~
!!! error TS1128: Declaration or statement expected.

View File

@@ -0,0 +1,12 @@
//// [decoratorOnEnum2.ts]
declare function dec<T>(target: T): T;
enum E {
@dec A
}
//// [decoratorOnEnum2.js]
var E;
(function (E) {
})(E || (E = {}));
A;

View File

@@ -0,0 +1,11 @@
tests/cases/conformance/decorators/invalid/decoratorOnFunctionDeclaration.ts(4,10): error TS1206: Decorators are not valid here.
==== tests/cases/conformance/decorators/invalid/decoratorOnFunctionDeclaration.ts (1 errors) ====
declare function dec<T>(target: T): T;
@dec
function F() {
~
!!! error TS1206: Decorators are not valid here.
}

View File

@@ -0,0 +1,10 @@
//// [decoratorOnFunctionDeclaration.ts]
declare function dec<T>(target: T): T;
@dec
function F() {
}
//// [decoratorOnFunctionDeclaration.js]
function F() {
}

View File

@@ -0,0 +1,13 @@
tests/cases/conformance/decorators/invalid/decoratorOnFunctionExpression.ts(3,9): error TS1109: Expression expected.
tests/cases/conformance/decorators/invalid/decoratorOnFunctionExpression.ts(3,23): error TS1003: Identifier expected.
==== tests/cases/conformance/decorators/invalid/decoratorOnFunctionExpression.ts (2 errors) ====
declare function dec<T>(target: T): T;
var F = @dec function () {
~
!!! error TS1109: Expression expected.
~
!!! error TS1003: Identifier expected.
}

View File

@@ -0,0 +1,10 @@
//// [decoratorOnFunctionExpression.ts]
declare function dec<T>(target: T): T;
var F = @dec function () {
}
//// [decoratorOnFunctionExpression.js]
var F = ;
function () {
}

View File

@@ -0,0 +1,17 @@
tests/cases/conformance/decorators/invalid/decoratorOnImportEquals1.ts(8,5): error TS1206: Decorators are not valid here.
==== tests/cases/conformance/decorators/invalid/decoratorOnImportEquals1.ts (1 errors) ====
declare function dec<T>(target: T): T;
module M1 {
export var X: number;
}
module M2 {
@dec
~~~~
import X = M1.X;
~~~~~~~~~~~~~~~~~~~~
!!! error TS1206: Decorators are not valid here.
}

View File

@@ -0,0 +1,17 @@
//// [decoratorOnImportEquals1.ts]
declare function dec<T>(target: T): T;
module M1 {
export var X: number;
}
module M2 {
@dec
import X = M1.X;
}
//// [decoratorOnImportEquals1.js]
var M1;
(function (M1) {
M1.X;
})(M1 || (M1 = {}));

View File

@@ -0,0 +1,14 @@
tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2_1.ts(1,1): error TS1206: Decorators are not valid here.
==== tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2_1.ts (1 errors) ====
@dec
~~~~
import lib = require('./decoratorOnImportEquals2_0');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1206: Decorators are not valid here.
declare function dec<T>(target: T): T;
==== tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2_0.ts (0 errors) ====
export var X;

View File

@@ -0,0 +1,14 @@
//// [tests/cases/conformance/decorators/invalid/decoratorOnImportEquals2.ts] ////
//// [decoratorOnImportEquals2_0.ts]
export var X;
//// [decoratorOnImportEquals2_1.ts]
@dec
import lib = require('./decoratorOnImportEquals2_0');
declare function dec<T>(target: T): T;
//// [decoratorOnImportEquals2_0.js]
exports.X;
//// [decoratorOnImportEquals2_1.js]

View File

@@ -0,0 +1,11 @@
tests/cases/conformance/decorators/invalid/decoratorOnInterface.ts(4,11): error TS1206: Decorators are not valid here.
==== tests/cases/conformance/decorators/invalid/decoratorOnInterface.ts (1 errors) ====
declare function dec<T>(target: T): T;
@dec
interface I {
~
!!! error TS1206: Decorators are not valid here.
}

Some files were not shown because too many files have changed in this diff Show More