Merge branch 'master' into APIReviewCleanup

Conflicts:
	src/services/outliningElementsCollector.ts
This commit is contained in:
Mohamed Hegazy
2015-04-10 16:11:03 -07:00
355 changed files with 6796 additions and 1521 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ Your pull request should:
* Tests should include reasonable permutations of the target fix/change
* Include baseline changes with your change
* All changed code must have 100% code coverage
* Follow the code conventions descriped in [Coding guidlines](https://github.com/Microsoft/TypeScript/wiki/Coding-guidlines)
* Follow the code conventions descriped in [Coding guidelines](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines)
* To avoid line ending issues, set `autocrlf = input` and `whitespace = cr-at-eol` in your git configuration
## Running the Tests
+1 -1
View File
@@ -540,7 +540,7 @@ module ts {
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
break;
case SyntaxKind.ExportAssignment:
if ((<ExportAssignment>node).expression && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
if ((<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
// An export default clause with an identifier exports all meanings of that identifier
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes);
}
+117 -89
View File
@@ -681,7 +681,7 @@ module ts {
}
function getTargetOfExportAssignment(node: ExportAssignment): Symbol {
return node.expression && resolveEntityName(<Identifier>node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace);
return resolveEntityName(<Identifier>node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace);
}
function getTargetOfAliasDeclaration(node: Declaration): Symbol {
@@ -747,7 +747,7 @@ module ts {
if (!links.referenced) {
links.referenced = true;
let node = getDeclarationOfAliasSymbol(symbol);
if (node.kind === SyntaxKind.ExportAssignment && (<ExportAssignment>node).expression) {
if (node.kind === SyntaxKind.ExportAssignment) {
// export default <symbol>
checkExpressionCached((<ExportAssignment>node).expression);
}
@@ -2077,15 +2077,20 @@ module ts {
}
}
else {
// For an array binding element the specified or inferred type of the parent must be an array-like type
if (!isArrayLikeType(parentType)) {
error(pattern, Diagnostics.Type_0_is_not_an_array_type, typeToString(parentType));
return unknownType;
}
// This elementType will be used if the specific property corresponding to this index is not
// present (aka the tuple element property). This call also checks that the parentType is in
// fact an iterable or array (depending on target language).
let elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false);
if (!declaration.dotDotDotToken) {
if (elementType.flags & TypeFlags.Any) {
return elementType;
}
// Use specific property type when parent is a tuple or numeric index type when parent is an array
let propName = "" + indexOf(pattern.elements, declaration);
type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) : getIndexTypeOfType(parentType, IndexKind.Number);
type = isTupleLikeType(parentType)
? getTypeOfPropertyOfType(parentType, propName)
: elementType;
if (!type) {
if (isTupleType(parentType)) {
error(declaration, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), (<TupleType>parentType).elementTypes.length, pattern.elements.length);
@@ -2098,7 +2103,7 @@ module ts {
}
else {
// Rest element has an array type with the same element type as the parent type
type = createArrayType(getIndexTypeOfType(parentType, IndexKind.Number));
type = createArrayType(elementType);
}
}
return type;
@@ -2187,7 +2192,34 @@ module ts {
hasSpreadElement = true;
}
});
return !elementTypes.length ? anyArrayType : hasSpreadElement ? createArrayType(getUnionType(elementTypes)) : createTupleType(elementTypes);
if (!elementTypes.length) {
return languageVersion >= ScriptTarget.ES6 ? createIterableType(anyType) : anyArrayType;
}
else if (hasSpreadElement) {
let unionOfElements = getUnionType(elementTypes);
if (languageVersion >= ScriptTarget.ES6) {
// If the user has something like:
//
// function fun(...[a, ...b]) { }
//
// Normally, in ES6, the implied type of an array binding pattern with a rest element is
// an iterable. However, there is a requirement in our type system that all rest
// parameters be array types. To satisfy this, we have an exception to the rule that
// says the type of an array binding pattern with a rest element is an array type
// if it is *itself* in a rest parameter. It will still be compatible with a spreaded
// iterable argument, but within the function it will be an array.
let parent = pattern.parent;
let isRestParameter = parent.kind === SyntaxKind.Parameter &&
pattern === (<ParameterDeclaration>parent).name &&
(<ParameterDeclaration>parent).dotDotDotToken !== undefined;
return isRestParameter ? createArrayType(unionOfElements) : createIterableType(unionOfElements);
}
return createArrayType(unionOfElements);
}
// If the pattern has at least one element, and no rest element, then it should imply a tuple type.
return createTupleType(elementTypes);
}
// Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself
@@ -2254,16 +2286,7 @@ module ts {
}
// Handle export default expressions
if (declaration.kind === SyntaxKind.ExportAssignment) {
var exportAssignment = <ExportAssignment>declaration;
if (exportAssignment.expression) {
return links.type = checkExpression(exportAssignment.expression);
}
else if (exportAssignment.type) {
return links.type = getTypeFromTypeNodeOrHeritageClauseElement(exportAssignment.type);
}
else {
return links.type = anyType;
}
return links.type = checkExpression((<ExportAssignment>declaration).expression);
}
// Handle variable, parameter or property
links.type = resolvingType;
@@ -3460,6 +3483,10 @@ module ts {
return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"));
}
function createIterableType(elementType: Type): Type {
return globalIterableType !== emptyObjectType ? createTypeReference(<GenericType>globalIterableType, [elementType]) : emptyObjectType;
}
function createArrayType(elementType: Type): Type {
// globalArrayType will be undefined if we get here during creation of the Array type. This for example happens if
// user code augments the Array type with call or construct signatures that have an array type as the return type.
@@ -5545,7 +5572,7 @@ module ts {
needToCaptureLexicalThis = false;
while (container && container.kind === SyntaxKind.ArrowFunction) {
container = getSuperContainer(container, /*includeFunctions*/ true);
needToCaptureLexicalThis = true;
needToCaptureLexicalThis = languageVersion < ScriptTarget.ES6;
}
// topmost container must be something that is directly nested in the class declaration
@@ -5967,12 +5994,14 @@ module ts {
}
function checkSpreadElementExpression(node: SpreadElementExpression, contextualMapper?: TypeMapper): Type {
let type = checkExpressionCached(node.expression, contextualMapper);
if (!isArrayLikeType(type)) {
error(node.expression, Diagnostics.Type_0_is_not_an_array_type, typeToString(type));
return unknownType;
}
return type;
// It is usually not safe to call checkExpressionCached if we can be contextually typing.
// You can tell that we are contextually typing because of the contextualMapper parameter.
// While it is true that a spread element can have a contextual type, it does not do anything
// with this type. It is neither affected by it, nor does it propagate it to its operand.
// So the fact that contextualMapper is passed is not important, because the operand of a spread
// element is not contextually typed.
let arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false);
}
function checkArrayLiteral(node: ArrayLiteralExpression, contextualMapper?: TypeMapper): Type {
@@ -5980,18 +6009,13 @@ module ts {
if (!elements.length) {
return createArrayType(undefinedType);
}
let hasSpreadElement: boolean = false;
let hasSpreadElement = false;
let elementTypes: Type[] = [];
forEach(elements, e => {
for (let e of elements) {
let type = checkExpression(e, contextualMapper);
if (e.kind === SyntaxKind.SpreadElementExpression) {
elementTypes.push(getIndexTypeOfType(type, IndexKind.Number) || anyType);
hasSpreadElement = true;
}
else {
elementTypes.push(type);
}
});
elementTypes.push(type);
hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElementExpression;
}
if (!hasSpreadElement) {
let contextualType = getContextualType(node);
if (contextualType && contextualTypeIsTupleLikeType(contextualType) || isAssignmentTarget(node)) {
@@ -6614,7 +6638,7 @@ module ts {
for (let i = 0; i < args.length; i++) {
let arg = args[i];
if (arg.kind !== SyntaxKind.OmittedExpression) {
let paramType = getTypeAtPosition(signature, arg.kind === SyntaxKind.SpreadElementExpression ? -1 : i);
let paramType = getTypeAtPosition(signature, i);
let argType: Type;
if (i === 0 && args[i].parent.kind === SyntaxKind.TaggedTemplateExpression) {
argType = globalTemplateStringsArrayType;
@@ -6637,7 +6661,7 @@ module ts {
// No need to check for omitted args and template expressions, their exlusion value is always undefined
if (excludeArgument[i] === false) {
let arg = args[i];
let paramType = getTypeAtPosition(signature, arg.kind === SyntaxKind.SpreadElementExpression ? -1 : i);
let paramType = getTypeAtPosition(signature, i);
inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType);
}
}
@@ -6670,7 +6694,7 @@ module ts {
let arg = args[i];
if (arg.kind !== SyntaxKind.OmittedExpression) {
// Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter)
let paramType = getTypeAtPosition(signature, arg.kind === SyntaxKind.SpreadElementExpression ? -1 : i);
let paramType = getTypeAtPosition(signature, i);
// A tagged template expression provides a special first argument, and string literals get string literal types
// unless we're reporting errors
let argType = i === 0 && node.kind === SyntaxKind.TaggedTemplateExpression ? globalTemplateStringsArrayType :
@@ -7144,14 +7168,9 @@ module ts {
}
function getTypeAtPosition(signature: Signature, pos: number): Type {
if (pos >= 0) {
return signature.hasRestParameter ?
pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) :
pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType;
}
return signature.hasRestParameter ?
getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]) :
anyArrayType;
pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) :
pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType;
}
function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) {
@@ -7587,11 +7606,10 @@ module ts {
}
function checkArrayLiteralAssignment(node: ArrayLiteralExpression, sourceType: Type, contextualMapper?: TypeMapper): Type {
// TODOO(andersh): Allow iterable source type in ES6
if (!isArrayLikeType(sourceType)) {
error(node, Diagnostics.Type_0_is_not_an_array_type, typeToString(sourceType));
return sourceType;
}
// This elementType will be used if the specific property corresponding to this index is not
// present (aka the tuple element property). This call also checks that the parentType is in
// fact an iterable or array (depending on target language).
let elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false);
let elements = node.elements;
for (let i = 0; i < elements.length; i++) {
let e = elements[i];
@@ -7599,8 +7617,9 @@ module ts {
if (e.kind !== SyntaxKind.SpreadElementExpression) {
let propName = "" + i;
let type = sourceType.flags & TypeFlags.Any ? sourceType :
isTupleLikeType(sourceType) ? getTypeOfPropertyOfType(sourceType, propName) :
getIndexTypeOfType(sourceType, IndexKind.Number);
isTupleLikeType(sourceType)
? getTypeOfPropertyOfType(sourceType, propName)
: elementType;
if (type) {
checkDestructuringAssignment(e, type, contextualMapper);
}
@@ -7615,7 +7634,7 @@ module ts {
}
else {
if (i === elements.length - 1) {
checkReferenceAssignment((<SpreadElementExpression>e).expression, sourceType, contextualMapper);
checkReferenceAssignment((<SpreadElementExpression>e).expression, createArrayType(elementType), contextualMapper);
}
else {
error(e, Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
@@ -9372,29 +9391,41 @@ module ts {
function checkRightHandSideOfForOf(rhsExpression: Expression): Type {
let expressionType = getTypeOfExpression(rhsExpression);
return languageVersion >= ScriptTarget.ES6
? checkIteratedType(expressionType, rhsExpression)
: checkElementTypeOfArrayOrString(expressionType, rhsExpression);
return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true);
}
function checkIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean): Type {
if (languageVersion >= ScriptTarget.ES6) {
return checkIteratedType(inputType, errorNode) || anyType;
}
if (allowStringInput) {
return checkElementTypeOfArrayOrString(inputType, errorNode);
}
if (isArrayLikeType(inputType)) {
return getIndexTypeOfType(inputType, IndexKind.Number);
}
error(errorNode, Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType));
return unknownType;
}
/**
* When expressionForError is undefined, it means we should not report any errors.
* When errorNode is undefined, it means we should not report any errors.
*/
function checkIteratedType(iterable: Type, expressionForError: Expression): Type {
function checkIteratedType(iterable: Type, errorNode: Node): Type {
Debug.assert(languageVersion >= ScriptTarget.ES6);
let iteratedType = getIteratedType(iterable, expressionForError);
let iteratedType = getIteratedType(iterable, errorNode);
// Now even though we have extracted the iteratedType, we will have to validate that the type
// passed in is actually an Iterable.
if (expressionForError && iteratedType) {
let completeIterableType = globalIterableType !== emptyObjectType
? createTypeReference(<GenericType>globalIterableType, [iteratedType])
: emptyObjectType;
checkTypeAssignableTo(iterable, completeIterableType, expressionForError);
if (errorNode && iteratedType) {
checkTypeAssignableTo(iterable, createIterableType(iteratedType), errorNode);
}
return iteratedType;
function getIteratedType(iterable: Type, expressionForError: Expression) {
function getIteratedType(iterable: Type, errorNode: Node) {
// We want to treat type as an iterable, and get the type it is an iterable of. The iterable
// must have the following structure (annotated with the names of the variables below):
//
@@ -9425,6 +9456,12 @@ module ts {
return undefined;
}
// As an optimization, if the type is instantiated directly using the globalIterableType (Iterable<number>),
// then just grab its type argument.
if ((iterable.flags & TypeFlags.Reference) && (<GenericType>iterable).target === globalIterableType) {
return (<GenericType>iterable).typeArguments[0];
}
let iteratorFunction = getTypeOfPropertyOfType(iterable, getPropertyNameForKnownSymbolName("iterator"));
if (iteratorFunction && allConstituentTypesHaveKind(iteratorFunction, TypeFlags.Any)) {
return undefined;
@@ -9432,8 +9469,8 @@ module ts {
let iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray;
if (iteratorFunctionSignatures.length === 0) {
if (expressionForError) {
error(expressionForError, Diagnostics.The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator);
if (errorNode) {
error(errorNode, Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator);
}
return undefined;
}
@@ -9450,8 +9487,8 @@ module ts {
let iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray;
if (iteratorNextFunctionSignatures.length === 0) {
if (expressionForError) {
error(expressionForError, Diagnostics.The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method);
if (errorNode) {
error(errorNode, Diagnostics.An_iterator_must_have_a_next_method);
}
return undefined;
}
@@ -9463,8 +9500,8 @@ module ts {
let iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value");
if (!iteratorNextValue) {
if (expressionForError) {
error(expressionForError, Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property);
if (errorNode) {
error(errorNode, Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property);
}
return undefined;
}
@@ -9490,7 +9527,7 @@ module ts {
* 1. Some constituent is neither a string nor an array.
* 2. Some constituent is a string and target is less than ES5 (because in ES3 string is not indexable).
*/
function checkElementTypeOfArrayOrString(arrayOrStringType: Type, expressionForError: Expression): Type {
function checkElementTypeOfArrayOrString(arrayOrStringType: Type, errorNode: Node): Type {
Debug.assert(languageVersion < ScriptTarget.ES6);
// After we remove all types that are StringLike, we will know if there was a string constituent
@@ -9501,7 +9538,7 @@ module ts {
let reportedError = false;
if (hasStringConstituent) {
if (languageVersion < ScriptTarget.ES5) {
error(expressionForError, Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
error(errorNode, Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
reportedError = true;
}
@@ -9521,7 +9558,7 @@ module ts {
let diagnostic = hasStringConstituent
? Diagnostics.Type_0_is_not_an_array_type
: Diagnostics.Type_0_is_not_an_array_type_or_a_string_type;
error(expressionForError, diagnostic, typeToString(arrayType));
error(errorNode, diagnostic, typeToString(arrayType));
}
return hasStringConstituent ? stringType : unknownType;
}
@@ -10552,21 +10589,12 @@ module ts {
if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers);
}
if (node.expression) {
if (node.expression.kind === SyntaxKind.Identifier) {
markExportAsReferenced(node);
}
else {
checkExpressionCached(node.expression);
}
if (node.expression.kind === SyntaxKind.Identifier) {
markExportAsReferenced(node);
}
if (node.type) {
checkSourceElement(node.type);
if (!isInAmbientContext(node)) {
grammarErrorOnFirstToken(node.type, Diagnostics.A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration);
}
else {
checkExpressionCached(node.expression);
}
checkExternalModuleExports(container);
if (node.isExportEquals && languageVersion >= ScriptTarget.ES6) {
+3 -1
View File
@@ -434,7 +434,7 @@ module ts {
return path.replace(/\\/g, "/");
}
// Returns length of path root (i.e. length of "/", "x:/", "//server/share/")
// Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files")
export function getRootLength(path: string): number {
if (path.charCodeAt(0) === CharacterCodes.slash) {
if (path.charCodeAt(1) !== CharacterCodes.slash) return 1;
@@ -448,6 +448,8 @@ module ts {
if (path.charCodeAt(2) === CharacterCodes.slash) return 3;
return 2;
}
let idx = path.indexOf('://');
if (idx !== -1) return idx + 3
return 0;
}
+29 -8
View File
@@ -442,20 +442,41 @@ module ts {
emitLines(node.statements);
}
// Return a temp variable name to be used in `export default` statements.
// The temp name will be of the form _default_counter.
// Note that export default is only allowed at most once in a module, so we
// do not need to keep track of created temp names.
function getExportDefaultTempVariableName(): string {
let baseName = "_default";
if (!hasProperty(currentSourceFile.identifiers, baseName)) {
return baseName;
}
let count = 0;
while (true) {
let name = baseName + "_" + (++count);
if (!hasProperty(currentSourceFile.identifiers, name)) {
return name;
}
}
}
function emitExportAssignment(node: ExportAssignment) {
write(node.isExportEquals ? "export = " : "export default ");
if (node.expression.kind === SyntaxKind.Identifier) {
write(node.isExportEquals ? "export = " : "export default ");
writeTextOfNode(currentSourceFile, node.expression);
}
else {
// Expression
let tempVarName = getExportDefaultTempVariableName();
write("declare var ");
write(tempVarName);
write(": ");
if (node.type) {
emitType(node.type);
}
else {
writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic;
resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
}
writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic;
resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction, writer);
write(";");
writeLine();
write(node.isExportEquals ? "export = " : "export default ");
write(tempVarName);
}
write(";");
writeLine();
@@ -159,7 +159,6 @@ module ts {
An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." },
Unterminated_Unicode_escape_sequence: { code: 1199, category: DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." },
Line_terminator_not_permitted_before_arrow: { code: 1200, category: DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." },
A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration: { code: 1201, category: DiagnosticCategory.Error, key: "A type annotation on an export statement is only allowed in an ambient external module declaration." },
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." },
@@ -345,8 +344,8 @@ module ts {
The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." },
The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." },
Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." },
The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." },
The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." },
Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "Type must have a '[Symbol.iterator]()' method that returns an iterator." },
An_iterator_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "An iterator must have a 'next()' method." },
The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." },
The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." },
Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" },
+2 -6
View File
@@ -623,10 +623,6 @@
"category": "Error",
"code": 1200
},
"A type annotation on an export statement is only allowed in an ambient external module declaration.": {
"category": "Error",
"code": 1201
},
"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.": {
"category": "Error",
"code": 1202
@@ -1367,11 +1363,11 @@
"category": "Error",
"code": 2487
},
"The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator.": {
"Type must have a '[Symbol.iterator]()' method that returns an iterator.": {
"category": "Error",
"code": 2488
},
"The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method.": {
"An iterator must have a 'next()' method.": {
"category": "Error",
"code": 2489
},
+164 -192
View File
@@ -1136,8 +1136,8 @@ var __param = this.__param || function(index, decorator) { return function (targ
if (!computedPropertyNamesToGeneratedNames) {
computedPropertyNamesToGeneratedNames = [];
}
let generatedName = computedPropertyNamesToGeneratedNames[node.id];
let generatedName = computedPropertyNamesToGeneratedNames[getNodeId(node)];
if (generatedName) {
// we have already generated a variable for this node, write that value instead.
write(generatedName);
@@ -1145,7 +1145,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
}
generatedName = createAndRecordTempVariable(TempFlags.Auto).text;
computedPropertyNamesToGeneratedNames[node.id] = generatedName;
computedPropertyNamesToGeneratedNames[getNodeId(node)] = generatedName;
write(generatedName);
write(" = ");
}
@@ -1381,211 +1381,163 @@ var __param = this.__param || function(index, decorator) { return function (targ
}
}
function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number): void {
let parenthesizedObjectLiteral = createDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex);
return emit(parenthesizedObjectLiteral);
function emitObjectLiteralBody(node: ObjectLiteralExpression, numElements: number): void {
if (numElements === 0) {
write("{}");
return;
}
write("{");
if (numElements > 0) {
var properties = node.properties;
// If we are not doing a downlevel transformation for object literals,
// then try to preserve the original shape of the object literal.
// Otherwise just try to preserve the formatting.
if (numElements === properties.length) {
emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= ScriptTarget.ES5, /* spacesBetweenBraces */ true);
}
else {
let multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
if (!multiLine) {
write(" ");
}
else {
increaseIndent();
}
emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false);
if (!multiLine) {
write(" ");
}
else {
decreaseIndent();
}
}
}
write("}");
}
function createDownlevelObjectLiteralWithComputedProperties(originalObjectLiteral: ObjectLiteralExpression, firstComputedPropertyIndex: number): ParenthesizedExpression {
function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number) {
let multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
let properties = node.properties;
write("(");
if (multiLine) {
increaseIndent();
}
// For computed properties, we need to create a unique handle to the object
// literal so we can modify it without risking internal assignments tainting the object.
let tempVar = createAndRecordTempVariable(TempFlags.Auto);
// Hold onto the initial non-computed properties in a new object literal,
// then create the rest through property accesses on the temp variable.
let initialObjectLiteral = <ObjectLiteralExpression>createSynthesizedNode(SyntaxKind.ObjectLiteralExpression);
initialObjectLiteral.properties = <NodeArray<ObjectLiteralElement>>originalObjectLiteral.properties.slice(0, firstComputedPropertyIndex);
initialObjectLiteral.flags |= NodeFlags.MultiLine;
// Write out the first non-computed properties
// (or all properties if none of them are computed),
// then emit the rest through indexing on the temp variable.
emit(tempVar)
write(" = ");
emitObjectLiteralBody(node, firstComputedPropertyIndex);
// The comma expressions that will patch the object literal.
// This will end up being something like '_a = { ... }, _a.x = 10, _a.y = 20, _a'.
let propertyPatches = createBinaryExpression(tempVar, SyntaxKind.EqualsToken, initialObjectLiteral);
for (let i = firstComputedPropertyIndex, n = properties.length; i < n; i++) {
writeComma();
ts.forEach(originalObjectLiteral.properties, property => {
let patchedProperty = tryCreatePatchingPropertyAssignment(originalObjectLiteral, tempVar, property);
if (patchedProperty) {
// TODO(drosen): Preserve comments
//let leadingComments = getLeadingCommentRanges(currentSourceFile.text, property.pos);
//let trailingComments = getTrailingCommentRanges(currentSourceFile.text, property.end);
//addCommentsToSynthesizedNode(patchedProperty, leadingComments, trailingComments);
let property = properties[i];
propertyPatches = createBinaryExpression(propertyPatches, SyntaxKind.CommaToken, patchedProperty);
emitStart(property)
if (property.kind === SyntaxKind.GetAccessor || property.kind === SyntaxKind.SetAccessor) {
// TODO (drosen): Reconcile with 'emitMemberFunctions'.
let accessors = getAllAccessorDeclarations(node.properties, <AccessorDeclaration>property);
if (property !== accessors.firstAccessor) {
continue;
}
write("Object.defineProperty(");
emit(tempVar);
write(", ");
emitStart(node.name);
emitExpressionForPropertyName(property.name);
emitEnd(property.name);
write(", {");
increaseIndent();
if (accessors.getAccessor) {
writeLine()
emitLeadingComments(accessors.getAccessor);
write("get: ");
emitStart(accessors.getAccessor);
write("function ");
emitSignatureAndBody(accessors.getAccessor);
emitEnd(accessors.getAccessor);
emitTrailingComments(accessors.getAccessor);
write(",");
}
if (accessors.setAccessor) {
writeLine();
emitLeadingComments(accessors.setAccessor);
write("set: ");
emitStart(accessors.setAccessor);
write("function ");
emitSignatureAndBody(accessors.setAccessor);
emitEnd(accessors.setAccessor);
emitTrailingComments(accessors.setAccessor);
write(",");
}
writeLine();
write("enumerable: true,");
writeLine();
write("configurable: true");
decreaseIndent();
writeLine();
write("})");
emitEnd(property);
}
});
else {
emitLeadingComments(property);
emitStart(property.name);
emit(tempVar);
emitMemberAccessForPropertyName(property.name);
emitEnd(property.name);
// Finally, return the temp variable.
propertyPatches = createBinaryExpression(propertyPatches, SyntaxKind.CommaToken, createIdentifier(tempVar.text, /*startsOnNewLine:*/ true));
write(" = ");
let result = createParenthesizedExpression(propertyPatches);
// TODO(drosen): Preserve comments
// let leadingComments = getLeadingCommentRanges(currentSourceFile.text, originalObjectLiteral.pos);
// let trailingComments = getTrailingCommentRanges(currentSourceFile.text, originalObjectLiteral.end);
//addCommentsToSynthesizedNode(result, leadingComments, trailingComments);
return result;
}
function addCommentsToSynthesizedNode(node: SynthesizedNode, leadingCommentRanges: CommentRange[], trailingCommentRanges: CommentRange[]): void {
node.leadingCommentRanges = leadingCommentRanges;
node.trailingCommentRanges = trailingCommentRanges;
}
// Returns 'undefined' if a property has already been accounted for
// (e.g. a 'get' accessor which has already been emitted along with its 'set' accessor).
function tryCreatePatchingPropertyAssignment(objectLiteral: ObjectLiteralExpression, tempVar: Identifier, property: ObjectLiteralElement): Expression {
let leftHandSide = createMemberAccessForPropertyName(tempVar, property.name);
let maybeRightHandSide = tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral, property);
return maybeRightHandSide && createBinaryExpression(leftHandSide, SyntaxKind.EqualsToken, maybeRightHandSide, /*startsOnNewLine:*/ true);
}
function tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral: ObjectLiteralExpression, property: ObjectLiteralElement) {
switch (property.kind) {
case SyntaxKind.PropertyAssignment:
return (<PropertyAssignment>property).initializer;
case SyntaxKind.ShorthandPropertyAssignment:
// TODO: (andersh) Technically it isn't correct to make an identifier here since getExpressionNamePrefix returns
// a string containing a dotted name. In general I'm not a fan of mini tree rewriters as this one, elsewhere we
// manage by just emitting strings (which is a lot more performant).
//let prefix = createIdentifier(resolver.getExpressionNamePrefix((<ShorthandPropertyAssignment>property).name));
//return createPropertyAccessExpression(prefix, (<ShorthandPropertyAssignment>property).name);
return createIdentifier(resolver.getExpressionNameSubstitution((<ShorthandPropertyAssignment>property).name, getGeneratedNameForNode));
case SyntaxKind.MethodDeclaration:
return createFunctionExpression((<MethodDeclaration>property).parameters, (<MethodDeclaration>property).body);
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
let { firstAccessor, getAccessor, setAccessor } = getAllAccessorDeclarations(objectLiteral.properties, <AccessorDeclaration>property);
// Only emit the first accessor.
if (firstAccessor !== property) {
return undefined;
if (property.kind === SyntaxKind.PropertyAssignment) {
emit((<PropertyAssignment>property).initializer);
}
let propertyDescriptor = <ObjectLiteralExpression>createSynthesizedNode(SyntaxKind.ObjectLiteralExpression);
let descriptorProperties = <NodeArray<ObjectLiteralElement>>[];
if (getAccessor) {
let getProperty = createPropertyAssignment(createIdentifier("get"), createFunctionExpression(getAccessor.parameters, getAccessor.body));
descriptorProperties.push(getProperty);
else if (property.kind === SyntaxKind.ShorthandPropertyAssignment) {
emitExpressionIdentifier((<ShorthandPropertyAssignment>property).name);
}
if (setAccessor) {
let setProperty = createPropertyAssignment(createIdentifier("set"), createFunctionExpression(setAccessor.parameters, setAccessor.body));
descriptorProperties.push(setProperty);
else if (property.kind === SyntaxKind.MethodDeclaration) {
emitFunctionDeclaration(<MethodDeclaration>property);
}
else {
Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind);
}
}
let trueExpr = <PrimaryExpression>createSynthesizedNode(SyntaxKind.TrueKeyword);
let enumerableTrue = createPropertyAssignment(createIdentifier("enumerable"), trueExpr);
descriptorProperties.push(enumerableTrue);
let configurableTrue = createPropertyAssignment(createIdentifier("configurable"), trueExpr);
descriptorProperties.push(configurableTrue);
propertyDescriptor.properties = descriptorProperties;
let objectDotDefineProperty = createPropertyAccessExpression(createIdentifier("Object"), createIdentifier("defineProperty"));
return createCallExpression(objectDotDefineProperty, createNodeArray(propertyDescriptor));
default:
Debug.fail(`ObjectLiteralElement kind ${property.kind} not accounted for.`);
emitEnd(property);
}
}
function createParenthesizedExpression(expression: Expression) {
let result = <ParenthesizedExpression>createSynthesizedNode(SyntaxKind.ParenthesizedExpression);
result.expression = expression;
writeComma();
emit(tempVar);
return result;
}
function createNodeArray<T extends Node>(...elements: T[]): NodeArray<T> {
let result = <NodeArray<T>>elements;
result.pos = -1;
result.end = -1;
return result;
}
function createBinaryExpression(left: Expression, operator: SyntaxKind, right: Expression, startsOnNewLine?: boolean): BinaryExpression {
let result = <BinaryExpression>createSynthesizedNode(SyntaxKind.BinaryExpression, startsOnNewLine);
result.operatorToken = createSynthesizedNode(operator);
result.left = left;
result.right = right;
return result;
}
function createExpressionStatement(expression: Expression): ExpressionStatement {
let result = <ExpressionStatement>createSynthesizedNode(SyntaxKind.ExpressionStatement);
result.expression = expression;
return result;
}
function createMemberAccessForPropertyName(expression: LeftHandSideExpression, memberName: DeclarationName): PropertyAccessExpression | ElementAccessExpression {
if (memberName.kind === SyntaxKind.Identifier) {
return createPropertyAccessExpression(expression, <Identifier>memberName);
if (multiLine) {
decreaseIndent();
writeLine();
}
else if (memberName.kind === SyntaxKind.StringLiteral || memberName.kind === SyntaxKind.NumericLiteral) {
return createElementAccessExpression(expression, <LiteralExpression>memberName);
write(")");
function writeComma() {
if (multiLine) {
write(",");
writeLine();
}
else {
write(", ");
}
}
else if (memberName.kind === SyntaxKind.ComputedPropertyName) {
return createElementAccessExpression(expression, (<ComputedPropertyName>memberName).expression);
}
else {
Debug.fail(`Kind '${memberName.kind}' not accounted for.`);
}
}
function createPropertyAssignment(name: LiteralExpression | Identifier, initializer: Expression) {
let result = <PropertyAssignment>createSynthesizedNode(SyntaxKind.PropertyAssignment);
result.name = name;
result.initializer = initializer;
return result;
}
function createFunctionExpression(parameters: NodeArray<ParameterDeclaration>, body: Block): FunctionExpression {
let result = <FunctionExpression>createSynthesizedNode(SyntaxKind.FunctionExpression);
result.parameters = parameters;
result.body = body;
return result;
}
function createPropertyAccessExpression(expression: LeftHandSideExpression, name: Identifier): PropertyAccessExpression {
let result = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression);
result.expression = expression;
result.dotToken = createSynthesizedNode(SyntaxKind.DotToken);
result.name = name;
return result;
}
function createElementAccessExpression(expression: LeftHandSideExpression, argumentExpression: Expression): ElementAccessExpression {
let result = <ElementAccessExpression>createSynthesizedNode(SyntaxKind.ElementAccessExpression);
result.expression = expression;
result.argumentExpression = argumentExpression;
return result;
}
function createIdentifier(name: string, startsOnNewLine?: boolean) {
let result = <Identifier>createSynthesizedNode(SyntaxKind.Identifier, startsOnNewLine);
result.text = name;
return result;
}
function createCallExpression(invokedExpression: MemberExpression, arguments: NodeArray<Expression>) {
let result = <CallExpression>createSynthesizedNode(SyntaxKind.CallExpression);
result.expression = invokedExpression;
result.arguments = arguments;
return result;
}
function emitObjectLiteral(node: ObjectLiteralExpression): void {
@@ -1613,13 +1565,33 @@ var __param = this.__param || function(index, decorator) { return function (targ
// Ordinary case: either the object has no computed properties
// or we're compiling with an ES6+ target.
write("{");
emitObjectLiteralBody(node, properties.length);
}
if (properties.length) {
emitLinePreservingList(node, properties, /*allowTrailingComma:*/ languageVersion >= ScriptTarget.ES5, /*spacesBetweenBraces:*/ true)
}
function createBinaryExpression(left: Expression, operator: SyntaxKind, right: Expression, startsOnNewLine?: boolean): BinaryExpression {
let result = <BinaryExpression>createSynthesizedNode(SyntaxKind.BinaryExpression, startsOnNewLine);
result.operatorToken = createSynthesizedNode(operator);
result.left = left;
result.right = right;
write("}");
return result;
}
function createPropertyAccessExpression(expression: LeftHandSideExpression, name: Identifier): PropertyAccessExpression {
let result = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression);
result.expression = expression;
result.dotToken = createSynthesizedNode(SyntaxKind.DotToken);
result.name = name;
return result;
}
function createElementAccessExpression(expression: LeftHandSideExpression, argumentExpression: Expression): ElementAccessExpression {
let result = <ElementAccessExpression>createSynthesizedNode(SyntaxKind.ElementAccessExpression);
result.expression = expression;
result.argumentExpression = argumentExpression;
return result;
}
function emitComputedPropertyName(node: ComputedPropertyName) {
+13 -10
View File
@@ -299,8 +299,7 @@ module ts {
case SyntaxKind.ExportAssignment:
return visitNodes(cbNodes, node.decorators) ||
visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<ExportAssignment>node).expression) ||
visitNode(cbNode, (<ExportAssignment>node).type);
visitNode(cbNode, (<ExportAssignment>node).expression);
case SyntaxKind.TemplateExpression:
return visitNode(cbNode, (<TemplateExpression>node).head) || visitNodes(cbNodes, (<TemplateExpression>node).templateSpans);
case SyntaxKind.TemplateSpan:
@@ -3221,6 +3220,16 @@ module ts {
}
}
// If encounter "([" or "({", this could be the start of a binding pattern.
// Examples:
// ([ x ]) => { }
// ({ x }) => { }
// ([ x ])
// ({ x })
if (second === SyntaxKind.OpenBracketToken || second === SyntaxKind.OpenBraceToken) {
return Tristate.Unknown;
}
// Simple case: "(..."
// This is an arrow function with a rest parameter.
if (second === SyntaxKind.DotDotDotToken) {
@@ -5123,17 +5132,11 @@ module ts {
setModifiers(node, modifiers);
if (parseOptional(SyntaxKind.EqualsToken)) {
node.isExportEquals = true;
node.expression = parseAssignmentExpressionOrHigher();
}
else {
parseExpected(SyntaxKind.DefaultKeyword);
if (parseOptional(SyntaxKind.ColonToken)) {
node.type = parseType();
}
else {
node.expression = parseAssignmentExpressionOrHigher();
}
}
node.expression = parseAssignmentExpressionOrHigher();
parseSemicolon();
return finishNode(node);
}
@@ -5299,7 +5302,7 @@ module ts {
break;
}
let range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos() };
let range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() };
let comment = sourceText.substring(range.pos, range.end);
let referencePathMatchResult = getFileReferenceFromReferencePath(comment, range);
+2 -1
View File
@@ -530,6 +530,7 @@ module ts {
let nextChar = text.charCodeAt(pos + 1);
let hasTrailingNewLine = false;
if (nextChar === CharacterCodes.slash || nextChar === CharacterCodes.asterisk) {
let kind = nextChar === CharacterCodes.slash ? SyntaxKind.SingleLineCommentTrivia : SyntaxKind.MultiLineCommentTrivia;
let startPos = pos;
pos += 2;
if (nextChar === CharacterCodes.slash) {
@@ -555,7 +556,7 @@ module ts {
result = [];
}
result.push({ pos: startPos, end: pos, hasTrailingNewLine: hasTrailingNewLine });
result.push({ pos: startPos, end: pos, hasTrailingNewLine, kind });
}
continue;
}
+2 -2
View File
@@ -977,8 +977,7 @@ module ts {
export interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression?: Expression;
type?: TypeNode;
expression: Expression;
}
export interface FileReference extends TextRange {
@@ -987,6 +986,7 @@ module ts {
export interface CommentRange extends TextRange {
hasTrailingNewLine?: boolean;
kind: SyntaxKind;
}
// Source files are declarations when they are external modules.
+10
View File
@@ -161,6 +161,14 @@ module ts {
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
}
export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number {
if (nodeIsMissing(node) || !node.decorators) {
return getTokenPosOfNode(node, sourceFile);
}
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end);
}
export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node): string {
if (nodeIsMissing(node)) {
return "";
@@ -781,6 +789,8 @@ module ts {
return node === (<TemplateSpan>parent).expression;
case SyntaxKind.ComputedPropertyName:
return node === (<ComputedPropertyName>parent).expression;
case SyntaxKind.Decorator:
return true;
default:
if (isExpression(parent)) {
return true;
+3
View File
@@ -336,6 +336,9 @@ module Harness.LanguageService {
getOccurrencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[] {
return unwrapJSONCallResult(this.shim.getOccurrencesAtPosition(fileName, position));
}
getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): ts.DocumentHighlights[] {
return unwrapJSONCallResult(this.shim.getDocumentHighlights(fileName, position, JSON.stringify(filesToSearch)));
}
getNavigateToItems(searchValue: string): ts.NavigateToItem[] {
return unwrapJSONCallResult(this.shim.getNavigateToItems(searchValue));
}
+1
View File
@@ -52,6 +52,7 @@ class TypeWriterWalker {
case ts.SyntaxKind.PostfixUnaryExpression:
case ts.SyntaxKind.BinaryExpression:
case ts.SyntaxKind.ConditionalExpression:
case ts.SyntaxKind.SpreadElementExpression:
this.log(node, this.getTypeOfNode(node));
break;
+1 -1
View File
@@ -823,7 +823,7 @@ interface RegExp {
*/
test(string: string): boolean;
/** Returns a copy of the text of the regular expression pattern. Read-only. The rgExp argument is a Regular expression object. It can be a variable name or a literal. */
/** Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal. */
source: string;
/** Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only. */
+19 -12
View File
@@ -50,26 +50,21 @@ interface SymbolConstructor {
*/
isConcatSpreadable: symbol;
/**
* A Boolean value that if true indicates that an object may be used as a regular expression.
*/
isRegExp: symbol;
/**
* A method that returns the default iterator for an object.Called by the semantics of the
* for-of statement.
* for-of statement.
*/
iterator: symbol;
/**
* A method that converts an object to a corresponding primitive value.Called by the ToPrimitive
* abstract operation.
* abstract operation.
*/
toPrimitive: symbol;
/**
* A String value that is used in the creation of the default string description of an object.
* Called by the built- in method Object.prototype.toString.
* A String value that is used in the creation of the default string description of an object.
* Called by the built-in method Object.prototype.toString.
*/
toStringTag: symbol;
@@ -111,7 +106,7 @@ interface ObjectConstructor {
getOwnPropertySymbols(o: any): symbol[];
/**
* Returns true if the values are the same value, false otherwise.
* Returns true if the values are the same value, false otherwise.
* @param value1 The first value.
* @param value2 The second value.
*/
@@ -598,8 +593,6 @@ interface Math {
}
interface RegExp {
[Symbol.isRegExp]: boolean;
/**
* Matches a string with a regular expression, and returns an array containing the results of
* that search.
@@ -631,6 +624,20 @@ interface RegExp {
*/
split(string: string, limit?: number): string[];
/**
* Returns a string indicating the flags of the regular expression in question. This field is read-only.
* The characters in this string are sequenced and concatenated in the following order:
*
* - "g" for global
* - "i" for ignoreCase
* - "m" for multiline
* - "u" for unicode
* - "y" for sticky
*
* If no flags are set, the value is the empty string.
*/
flags: string;
/**
* Returns a Boolean value indicating the state of the sticky flag (y) used with a regular
* expression. Default is false. Read-only.
+25 -1
View File
@@ -104,7 +104,7 @@ module ts.server {
var response: T = JSON.parse(responseBody);
}
catch (e) {
throw new Error("Malformed response: Failed to parse server response: " + lastMessage + ". \r\n Error detailes: " + e.message);
throw new Error("Malformed response: Failed to parse server response: " + lastMessage + ". \r\n Error details: " + e.message);
}
// verify the sequence numbers
@@ -446,6 +446,7 @@ module ts.server {
if (!response.body) {
return undefined;
}
var helpItems: protocol.SignatureHelpItems = response.body;
var span = helpItems.applicableSpan;
var start = this.lineOffsetToPosition(fileName, span.start);
@@ -465,6 +466,29 @@ module ts.server {
}
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
var args: protocol.FileLocationRequestArgs = {
file: fileName,
line: lineOffset.line,
offset: lineOffset.offset,
};
var request = this.processRequest<protocol.OccurrencesRequest>(CommandNames.Occurrences, args);
var response = this.processResponse<protocol.OccurrencesResponse>(request);
return response.body.map(entry => {
var fileName = entry.file;
var start = this.lineOffsetToPosition(fileName, entry.start);
var end = this.lineOffsetToPosition(fileName, entry.end);
return {
fileName,
textSpan: ts.createTextSpanFromBounds(start, end),
isWriteAccess: entry.isWriteAccess,
};
});
}
getDocumentHighlights(fileName: string, position: number): DocumentHighlights[] {
throw new Error("Not Implemented Yet.");
}
+19
View File
@@ -165,6 +165,25 @@ declare module ts.server.protocol {
body?: FileSpan[];
}
/**
* Get occurrences request; value of command field is
* "occurrences". Return response giving spans that are relevant
* in the file at a given line and column.
*/
export interface OccurrencesRequest extends FileLocationRequest {
}
export interface OccurrencesResponseItem extends FileSpan {
/**
* True if the occurrence is a write location, false otherwise.
*/
isWriteAccess: boolean;
}
export interface OccurrencesResponse extends Response {
body?: OccurrencesResponseItem[];
}
/**
* Find references request; value of command field is
* "references". Return response giving the file locations that
+79 -67
View File
@@ -89,6 +89,7 @@ module ts.server {
export var Geterr = "geterr";
export var NavBar = "navbar";
export var Navto = "navto";
export var Occurrences = "occurrences";
export var Open = "open";
export var Quickinfo = "quickinfo";
export var References = "references";
@@ -117,7 +118,7 @@ module ts.server {
constructor(private host: ServerHost, private logger: Logger) {
this.projectService =
new ProjectService(host, logger, (eventName,project,fileName) => {
new ProjectService(host, logger, (eventName, project, fileName) => {
this.handleEvent(eventName, project, fileName);
});
}
@@ -262,7 +263,7 @@ module ts.server {
}
}
getDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] {
getDefinition({ line, offset, file: fileName }: protocol.FileLocationRequestArgs): protocol.FileSpan[] {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -284,7 +285,37 @@ module ts.server {
}));
}
getRenameLocations(line: number, offset: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody {
getOccurrences({ line, offset, file: fileName }: protocol.FileLocationRequestArgs): protocol.OccurrencesResponseItem[] {
fileName = ts.normalizePath(fileName);
let project = this.projectService.getProjectForFile(fileName);
if (!project) {
throw Errors.NoProject;
}
let { compilerService } = project;
let position = compilerService.host.lineOffsetToPosition(fileName, line, offset);
let occurrences = compilerService.languageService.getOccurrencesAtPosition(fileName, position);
if (!occurrences) {
return undefined;
}
return occurrences.map(occurrence => {
let { fileName, isWriteAccess, textSpan } = occurrence;
let start = compilerService.host.positionToLineOffset(fileName, textSpan.start);
let end = compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(textSpan));
return {
start,
end,
file: fileName,
isWriteAccess
}
});
}
getRenameLocations({line, offset, file: fileName, findInComments, findInStrings }: protocol.RenameRequestArgs): protocol.RenameResponseBody {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -352,7 +383,7 @@ module ts.server {
return { info: renameInfo, locs: bakedRenameLocs };
}
getReferences(line: number, offset: number, fileName: string): protocol.ReferencesResponseBody {
getReferences({ line, offset, file: fileName }: protocol.FileLocationRequestArgs): protocol.ReferencesResponseBody {
// TODO: get all projects for this file; report refs for all projects deleting duplicates
// can avoid duplicates by eliminating same ref file from subsequent projects
var file = ts.normalizePath(fileName);
@@ -378,7 +409,7 @@ module ts.server {
var nameSpan = nameInfo.textSpan;
var nameColStart = compilerService.host.positionToLineOffset(file, nameSpan.start).offset;
var nameText = compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan));
var bakedRefs: protocol.ReferencesResponseItem[] = references.map((ref) => {
var bakedRefs: protocol.ReferencesResponseItem[] = references.map(ref => {
var start = compilerService.host.positionToLineOffset(ref.fileName, ref.textSpan.start);
var refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1);
var snap = compilerService.host.getScriptSnapshot(ref.fileName);
@@ -399,12 +430,12 @@ module ts.server {
};
}
openClientFile(fileName: string) {
openClientFile({ file: fileName }: protocol.OpenRequestArgs) {
var file = ts.normalizePath(fileName);
this.projectService.openClientFile(file);
}
getQuickInfo(line: number, offset: number, fileName: string): protocol.QuickInfoResponseBody {
getQuickInfo({ line, offset, file: fileName }: protocol.FileLocationRequestArgs): protocol.QuickInfoResponseBody {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -430,7 +461,7 @@ module ts.server {
};
}
getFormattingEditsForRange(line: number, offset: number, endLine: number, endOffset: number, fileName: string): protocol.CodeEdit[] {
getFormattingEditsForRange({line, offset, endLine, endOffset, file: fileName}: protocol.FormatRequestArgs): protocol.CodeEdit[] {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -457,7 +488,7 @@ module ts.server {
});
}
getFormattingEditsAfterKeystroke(line: number, offset: number, key: string, fileName: string): protocol.CodeEdit[] {
getFormattingEditsAfterKeystroke({line, offset, key, file: fileName}: protocol.FormatOnKeyRequestArgs): protocol.CodeEdit[] {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
@@ -530,7 +561,7 @@ module ts.server {
});
}
getCompletions(line: number, offset: number, prefix: string, fileName: string): protocol.CompletionEntry[] {
getCompletions({ line, offset, prefix, file: fileName}: protocol.CompletionsRequestArgs): protocol.CompletionEntry[] {
if (!prefix) {
prefix = "";
}
@@ -556,8 +587,7 @@ module ts.server {
}, []).sort((a, b) => a.name.localeCompare(b.name));
}
getCompletionEntryDetails(line: number, offset: number,
entryNames: string[], fileName: string): protocol.CompletionEntryDetails[] {
getCompletionEntryDetails({ line, offset, entryNames, file: fileName}: protocol.CompletionDetailsRequestArgs): protocol.CompletionEntryDetails[] {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -576,20 +606,20 @@ module ts.server {
}, []);
}
getSignatureHelpItems(line: number, offset: number, fileName: string): protocol.SignatureHelpItems {
getSignatureHelpItems({ line, offset, file: fileName }: protocol.SignatureHelpRequestArgs): protocol.SignatureHelpItems {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
throw Errors.NoProject;
}
var compilerService = project.compilerService;
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
var helpItems = compilerService.languageService.getSignatureHelpItems(file, position);
if (!helpItems) {
return undefined;
}
var span = helpItems.applicableSpan;
var result: protocol.SignatureHelpItems = {
items: helpItems.items,
@@ -601,11 +631,11 @@ module ts.server {
argumentIndex: helpItems.argumentIndex,
argumentCount: helpItems.argumentCount,
}
return result;
}
getDiagnostics(delay: number, fileNames: string[]) {
getDiagnostics({ delay, files: fileNames }: protocol.GeterrRequestArgs): void {
var checkList = fileNames.reduce((accum: PendingErrorCheck[], fileName: string) => {
fileName = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(fileName);
@@ -616,11 +646,11 @@ module ts.server {
}, []);
if (checkList.length > 0) {
this.updateErrorCheck(checkList, this.changeSeq,(n) => n == this.changeSeq, delay)
this.updateErrorCheck(checkList, this.changeSeq, (n) => n == this.changeSeq, delay)
}
}
change(line: number, offset: number, endLine: number, endOffset: number, insertString: string, fileName: string) {
change({ line, offset, endLine, endOffset, insertString, file: fileName }: protocol.ChangeRequestArgs): void {
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (project) {
@@ -635,7 +665,7 @@ module ts.server {
}
}
reload(fileName: string, tempFileName: string, reqSeq = 0) {
reload({ file: fileName, tmpfile: tempFileName }: protocol.ReloadRequestArgs, reqSeq = 0): void {
var file = ts.normalizePath(fileName);
var tmpfile = ts.normalizePath(tempFileName);
var project = this.projectService.getProjectForFile(file);
@@ -648,7 +678,7 @@ module ts.server {
}
}
saveToTmp(fileName: string, tempFileName: string) {
saveToTmp({ file: fileName, tmpfile: tempFileName }: protocol.SavetoRequestArgs): void {
var file = ts.normalizePath(fileName);
var tmpfile = ts.normalizePath(tempFileName);
@@ -658,7 +688,7 @@ module ts.server {
}
}
closeClientFile(fileName: string) {
closeClientFile({ file: fileName }: protocol.FileRequestArgs) {
var file = ts.normalizePath(fileName);
this.projectService.closeClientFile(file);
}
@@ -682,7 +712,7 @@ module ts.server {
}));
}
getNavigationBarItems(fileName: string): protocol.NavigationBarItem[] {
getNavigationBarItems({ file: fileName }: protocol.FileRequestArgs): protocol.NavigationBarItem[]{
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -698,7 +728,7 @@ module ts.server {
return this.decorateNavigationBarItem(project, fileName, items);
}
getNavigateToItems(searchValue: string, fileName: string, maxResultCount?: number): protocol.NavtoItem[] {
getNavigateToItems({ searchValue, file: fileName, maxResultCount }: protocol.NavtoRequestArgs): protocol.NavtoItem[]{
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
if (!project) {
@@ -737,7 +767,7 @@ module ts.server {
});
}
getBraceMatching(line: number, offset: number, fileName: string): protocol.TextSpan[] {
getBraceMatching({ line, offset, file: fileName }: protocol.FileLocationRequestArgs): protocol.TextSpan[]{
var file = ts.normalizePath(fileName);
var project = this.projectService.getProjectForFile(file);
@@ -779,109 +809,91 @@ module ts.server {
break;
}
case CommandNames.Definition: {
var defArgs = <protocol.FileLocationRequestArgs>request.arguments;
response = this.getDefinition(defArgs.line, defArgs.offset, defArgs.file);
response = this.getDefinition(<protocol.FileLocationRequestArgs>request.arguments);
break;
}
case CommandNames.References: {
var refArgs = <protocol.FileLocationRequestArgs>request.arguments;
response = this.getReferences(refArgs.line, refArgs.offset, refArgs.file);
response = this.getReferences(<protocol.FileLocationRequestArgs>request.arguments);
break;
}
case CommandNames.Rename: {
var renameArgs = <protocol.RenameRequestArgs>request.arguments;
response = this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings);
response = this.getRenameLocations(<protocol.RenameRequestArgs>request.arguments);
break;
}
case CommandNames.Open: {
var openArgs = <protocol.OpenRequestArgs>request.arguments;
this.openClientFile(openArgs.file);
this.openClientFile(<protocol.OpenRequestArgs>request.arguments);
responseRequired = false;
break;
}
case CommandNames.Quickinfo: {
var quickinfoArgs = <protocol.FileLocationRequestArgs>request.arguments;
response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file);
response = this.getQuickInfo(<protocol.FileLocationRequestArgs>request.arguments);
break;
}
case CommandNames.Format: {
var formatArgs = <protocol.FormatRequestArgs>request.arguments;
response = this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file);
response = this.getFormattingEditsForRange(<protocol.FormatRequestArgs>request.arguments);
break;
}
case CommandNames.Formatonkey: {
var formatOnKeyArgs = <protocol.FormatOnKeyRequestArgs>request.arguments;
response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file);
response = this.getFormattingEditsAfterKeystroke(<protocol.FormatOnKeyRequestArgs>request.arguments);
break;
}
case CommandNames.Completions: {
var completionsArgs = <protocol.CompletionsRequestArgs>request.arguments;
response = this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file);
response = this.getCompletions(<protocol.CompletionsRequestArgs>request.arguments);
break;
}
case CommandNames.CompletionDetails: {
var completionDetailsArgs = <protocol.CompletionDetailsRequestArgs>request.arguments;
response =
this.getCompletionEntryDetails(completionDetailsArgs.line,completionDetailsArgs.offset,
completionDetailsArgs.entryNames,completionDetailsArgs.file);
response = this.getCompletionEntryDetails(<protocol.CompletionDetailsRequestArgs>request.arguments);
break;
}
case CommandNames.SignatureHelp: {
var signatureHelpArgs = <protocol.SignatureHelpRequestArgs>request.arguments;
response = this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file);
response = this.getSignatureHelpItems(<protocol.SignatureHelpRequestArgs>request.arguments);
break;
}
case CommandNames.Geterr: {
var geterrArgs = <protocol.GeterrRequestArgs>request.arguments;
response = this.getDiagnostics(geterrArgs.delay, geterrArgs.files);
this.getDiagnostics(<protocol.GeterrRequestArgs>request.arguments);
responseRequired = false;
break;
}
case CommandNames.Change: {
var changeArgs = <protocol.ChangeRequestArgs>request.arguments;
this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset,
changeArgs.insertString, changeArgs.file);
this.change(<protocol.ChangeRequestArgs>request.arguments);
responseRequired = false;
break;
}
case CommandNames.Configure: {
var configureArgs = <protocol.ConfigureRequestArguments>request.arguments;
this.projectService.setHostConfiguration(configureArgs);
this.projectService.setHostConfiguration(<protocol.ConfigureRequestArguments>request.arguments);
this.output(undefined, CommandNames.Configure, request.seq);
responseRequired = false;
break;
}
case CommandNames.Reload: {
var reloadArgs = <protocol.ReloadRequestArgs>request.arguments;
this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq);
this.reload(<protocol.ReloadRequestArgs>request.arguments);
responseRequired = false;
break;
}
case CommandNames.Saveto: {
var savetoArgs = <protocol.SavetoRequestArgs>request.arguments;
this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile);
this.saveToTmp(<protocol.SavetoRequestArgs>request.arguments);
responseRequired = false;
break;
}
case CommandNames.Close: {
var closeArgs = <protocol.FileRequestArgs>request.arguments;
this.closeClientFile(closeArgs.file);
this.closeClientFile(<protocol.FileRequestArgs>request.arguments);
responseRequired = false;
break;
}
case CommandNames.Navto: {
var navtoArgs = <protocol.NavtoRequestArgs>request.arguments;
response = this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount);
response = this.getNavigateToItems(<protocol.NavtoRequestArgs>request.arguments);
break;
}
case CommandNames.Brace: {
var braceArguments = <protocol.FileLocationRequestArgs>request.arguments;
response = this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file);
response = this.getBraceMatching(<protocol.FileLocationRequestArgs>request.arguments);
break;
}
case CommandNames.NavBar: {
var navBarArgs = <protocol.FileRequestArgs>request.arguments;
response = this.getNavigationBarItems(navBarArgs.file);
response = this.getNavigationBarItems(<protocol.FileRequestArgs>request.arguments);
break;
}
case CommandNames.Occurrences: {
response = this.getOccurrences(<protocol.FileLocationRequestArgs>request.arguments);
break;
}
default: {
-4
View File
@@ -174,10 +174,6 @@ module ts.BreakpointResolver {
return textSpan(node, (<ThrowStatement>node).expression);
case SyntaxKind.ExportAssignment:
if (!(<ExportAssignment>node).expression) {
return undefined;
}
// span on export = id
return textSpan(node, (<ExportAssignment>node).expression);
+19 -7
View File
@@ -329,8 +329,13 @@ module ts.formatting {
if (formattingScanner.isOnToken()) {
let startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line;
let undecoratedStartLine = startLine;
if (enclosingNode.decorators) {
undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line;
}
let delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile);
processNode(enclosingNode, enclosingNode, startLine, initialIndentation, delta);
processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta);
}
formattingScanner.close();
@@ -501,7 +506,7 @@ module ts.formatting {
}
}
function processNode(node: Node, contextNode: Node, nodeStartLine: number, indentation: number, delta: number) {
function processNode(node: Node, contextNode: Node, nodeStartLine: number, undecoratedNodeStartLine: number, indentation: number, delta: number) {
if (!rangeOverlapsWithStartEnd(originalRange, node.getStart(sourceFile), node.getEnd())) {
return;
}
@@ -527,7 +532,7 @@ module ts.formatting {
forEachChild(
node,
child => {
processChildNode(child, /*inheritedIndentation*/ Constants.Unknown, node, nodeDynamicIndentation, nodeStartLine, /*isListElement*/ false)
processChildNode(child, /*inheritedIndentation*/ Constants.Unknown, node, nodeDynamicIndentation, nodeStartLine, undecoratedNodeStartLine, /*isListElement*/ false)
},
(nodes: NodeArray<Node>) => {
processChildNodes(nodes, node, nodeStartLine, nodeDynamicIndentation);
@@ -548,11 +553,17 @@ module ts.formatting {
parent: Node,
parentDynamicIndentation: DynamicIndentation,
parentStartLine: number,
undecoratedParentStartLine: number,
isListItem: boolean): number {
let childStartPos = child.getStart(sourceFile);
let childStart = sourceFile.getLineAndCharacterOfPosition(childStartPos);
let childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line;
let undecoratedChildStartLine = childStartLine;
if (child.decorators) {
undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(getNonDecoratorTokenPosOfNode(child, sourceFile)).line;
}
// if child is a list item - try to get its indentation
let childIndentationAmount = Constants.Unknown;
@@ -595,9 +606,10 @@ module ts.formatting {
return inheritedIndentation;
}
let childIndentation = computeIndentation(child, childStart.line, childIndentationAmount, node, parentDynamicIndentation, parentStartLine);
let effectiveParentStartLine = child.kind === SyntaxKind.Decorator ? childStartLine : undecoratedParentStartLine;
let childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine);
processNode(child, childContextNode, childStart.line, childIndentation.indentation, childIndentation.delta);
processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta);
childContextNode = node;
@@ -641,7 +653,7 @@ module ts.formatting {
let inheritedIndentation = Constants.Unknown;
for (let child of nodes) {
inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, /*isListElement*/ true)
inheritedIndentation = processChildNode(child, inheritedIndentation, node, listDynamicIndentation, startLine, startLine, /*isListElement*/ true)
}
if (listEndToken !== SyntaxKind.Unknown) {
+28 -1
View File
@@ -194,6 +194,11 @@ module ts.formatting {
public SpaceAfterAnonymousFunctionKeyword: Rule;
public NoSpaceAfterAnonymousFunctionKeyword: Rule;
// Insert space after @ in decorator
public SpaceBeforeAt: Rule;
public NoSpaceAfterAt: Rule;
public SpaceAfterDecorator: Rule;
constructor() {
///
/// Common Rules
@@ -330,6 +335,11 @@ module ts.formatting {
// Remove spaces in empty interface literals. e.g.: x: {}
this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext, Rules.IsObjectTypeContext), RuleAction.Delete));
// decorators
this.SpaceBeforeAt = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.AtToken), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Space));
this.NoSpaceAfterAt = new Rule(RuleDescriptor.create3(SyntaxKind.AtToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsSameLineTokenContext), RuleAction.Delete));
this.SpaceAfterDecorator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.ExportKeyword, SyntaxKind.DefaultKeyword, SyntaxKind.ClassKeyword, SyntaxKind.StaticKeyword, SyntaxKind.PublicKeyword, SyntaxKind.PrivateKeyword, SyntaxKind.ProtectedKeyword, SyntaxKind.GetKeyword, SyntaxKind.SetKeyword, SyntaxKind.OpenBracketToken, SyntaxKind.AsteriskToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), RuleAction.Space));
// These rules are higher in priority than user-configurable rules.
this.HighPriorityCommonRules =
[
@@ -367,7 +377,10 @@ module ts.formatting {
this.NoSpaceBetweenCloseParenAndAngularBracket,
this.NoSpaceAfterOpenAngularBracket,
this.NoSpaceBeforeCloseAngularBracket,
this.NoSpaceAfterCloseAngularBracket
this.NoSpaceAfterCloseAngularBracket,
this.SpaceBeforeAt,
this.NoSpaceAfterAt,
this.SpaceAfterDecorator,
];
// These rules are lower in priority than user-configurable rules.
@@ -635,6 +648,20 @@ module ts.formatting {
return context.TokensAreOnSameLine();
}
static IsEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean {
return context.TokensAreOnSameLine() &&
context.contextNode.decorators &&
Rules.NodeIsInDecoratorContext(context.currentTokenParent) &&
!Rules.NodeIsInDecoratorContext(context.nextTokenParent);
}
static NodeIsInDecoratorContext(node: Node): boolean {
while (isExpression(node)) {
node = node.parent;
}
return node.kind === SyntaxKind.Decorator;
}
static IsStartOfVariableDeclarationList(context: FormattingContext): boolean {
return context.currentTokenParent.kind === SyntaxKind.VariableDeclarationList &&
context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos;
+179 -129
View File
@@ -1,130 +1,180 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
/** @internal */
module ts {
export module OutliningElementsCollector {
export function collectElements(sourceFile: SourceFile): OutliningSpan[] {
let elements: OutliningSpan[] = [];
let collapseText = "...";
function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean) {
if (hintSpanNode && startElement && endElement) {
let span: OutliningSpan = {
textSpan: createTextSpanFromBounds(startElement.pos, endElement.end),
hintSpan: createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end),
bannerText: collapseText,
autoCollapse: autoCollapse
};
elements.push(span);
}
}
function autoCollapse(node: Node) {
return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction;
}
let depth = 0;
let maxDepth = 20;
function walk(n: Node): void {
if (depth > maxDepth) {
return;
}
switch (n.kind) {
case SyntaxKind.Block:
if (!isFunctionBlock(n)) {
let parent = n.parent;
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
// Check if the block is standalone, or 'attached' to some parent statement.
// If the latter, we want to collaps the block, but consider its hint span
// to be the entire span of the parent.
if (parent.kind === SyntaxKind.DoStatement ||
parent.kind === SyntaxKind.ForInStatement ||
parent.kind === SyntaxKind.ForOfStatement ||
parent.kind === SyntaxKind.ForStatement ||
parent.kind === SyntaxKind.IfStatement ||
parent.kind === SyntaxKind.WhileStatement ||
parent.kind === SyntaxKind.WithStatement ||
parent.kind === SyntaxKind.CatchClause) {
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
break;
}
if (parent.kind === SyntaxKind.TryStatement) {
// Could be the try-block, or the finally-block.
let tryStatement = <TryStatement>parent;
if (tryStatement.tryBlock === n) {
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
break;
}
else if (tryStatement.finallyBlock === n) {
let finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile);
if (finallyKeyword) {
addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n));
break;
}
}
// fall through.
}
// Block was a standalone block. In this case we want to only collapse
// the span of the block, independent of any parent span.
let span = createTextSpanFromBounds(n.getStart(), n.end);
elements.push({
textSpan: span,
hintSpan: span,
bannerText: collapseText,
autoCollapse: autoCollapse(n)
});
break;
}
// Fallthrough.
case SyntaxKind.ModuleBlock: {
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n));
break;
}
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.CaseBlock: {
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n));
break;
}
case SyntaxKind.ArrayLiteralExpression:
let openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile);
let closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile);
addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n));
break;
}
depth++;
forEachChild(n, walk);
depth--;
}
walk(sourceFile);
return elements;
}
}
/** @internal */
module ts {
export module OutliningElementsCollector {
export function collectElements(sourceFile: SourceFile): OutliningSpan[] {
let elements: OutliningSpan[] = [];
let collapseText = "...";
function addOutliningSpan(hintSpanNode: Node, startElement: Node, endElement: Node, autoCollapse: boolean) {
if (hintSpanNode && startElement && endElement) {
let span: OutliningSpan = {
textSpan: createTextSpanFromBounds(startElement.pos, endElement.end),
hintSpan: createTextSpanFromBounds(hintSpanNode.getStart(), hintSpanNode.end),
bannerText: collapseText,
autoCollapse: autoCollapse
};
elements.push(span);
}
}
function addOutliningSpanComments(commentSpan: CommentRange, autoCollapse: boolean) {
if (commentSpan) {
let span: OutliningSpan = {
textSpan: createTextSpanFromBounds(commentSpan.pos, commentSpan.end),
hintSpan: createTextSpanFromBounds(commentSpan.pos, commentSpan.end),
bannerText: collapseText,
autoCollapse: autoCollapse
};
elements.push(span);
}
}
function addOutliningForLeadingCommentsForNode(n: Node) {
let comments = ts.getLeadingCommentRangesOfNode(n, sourceFile);
if (comments) {
let firstSingleLineCommentStart = -1;
let lastSingleLineCommentEnd = -1;
let isFirstSingleLineComment = true;
let singleLineCommentCount = 0;
for (let currentComment of comments) {
// For single line comments, combine consecutive ones (2 or more) into
// a single span from the start of the first till the end of the last
if (currentComment.kind === SyntaxKind.SingleLineCommentTrivia) {
if (isFirstSingleLineComment) {
firstSingleLineCommentStart = currentComment.pos;
}
isFirstSingleLineComment = false;
lastSingleLineCommentEnd = currentComment.end;
singleLineCommentCount++;
}
else if (currentComment.kind === SyntaxKind.MultiLineCommentTrivia) {
combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd);
addOutliningSpanComments(currentComment, /*autoCollapse*/ false);
singleLineCommentCount = 0;
lastSingleLineCommentEnd = -1;
isFirstSingleLineComment = true;
}
}
combineAndAddMultipleSingleLineComments(singleLineCommentCount, firstSingleLineCommentStart, lastSingleLineCommentEnd);
}
}
function combineAndAddMultipleSingleLineComments(count: number, start: number, end: number) {
// Only outline spans of two or more consecutive single line comments
if (count > 1) {
let multipleSingleLineComments = {
pos: start,
end: end,
kind: SyntaxKind.SingleLineCommentTrivia
}
addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false);
}
}
function autoCollapse(node: Node) {
return isFunctionBlock(node) && node.parent.kind !== SyntaxKind.ArrowFunction;
}
let depth = 0;
let maxDepth = 20;
function walk(n: Node): void {
if (depth > maxDepth) {
return;
}
if (isDeclaration(n)) {
addOutliningForLeadingCommentsForNode(n);
}
switch (n.kind) {
case SyntaxKind.Block:
if (!isFunctionBlock(n)) {
let parent = n.parent;
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
// Check if the block is standalone, or 'attached' to some parent statement.
// If the latter, we want to collaps the block, but consider its hint span
// to be the entire span of the parent.
if (parent.kind === SyntaxKind.DoStatement ||
parent.kind === SyntaxKind.ForInStatement ||
parent.kind === SyntaxKind.ForOfStatement ||
parent.kind === SyntaxKind.ForStatement ||
parent.kind === SyntaxKind.IfStatement ||
parent.kind === SyntaxKind.WhileStatement ||
parent.kind === SyntaxKind.WithStatement ||
parent.kind === SyntaxKind.CatchClause) {
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
break;
}
if (parent.kind === SyntaxKind.TryStatement) {
// Could be the try-block, or the finally-block.
let tryStatement = <TryStatement>parent;
if (tryStatement.tryBlock === n) {
addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n));
break;
}
else if (tryStatement.finallyBlock === n) {
let finallyKeyword = findChildOfKind(tryStatement, SyntaxKind.FinallyKeyword, sourceFile);
if (finallyKeyword) {
addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n));
break;
}
}
// fall through.
}
// Block was a standalone block. In this case we want to only collapse
// the span of the block, independent of any parent span.
let span = createTextSpanFromBounds(n.getStart(), n.end);
elements.push({
textSpan: span,
hintSpan: span,
bannerText: collapseText,
autoCollapse: autoCollapse(n)
});
break;
}
// Fallthrough.
case SyntaxKind.ModuleBlock: {
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n));
break;
}
case SyntaxKind.ClassDeclaration:
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.CaseBlock: {
let openBrace = findChildOfKind(n, SyntaxKind.OpenBraceToken, sourceFile);
let closeBrace = findChildOfKind(n, SyntaxKind.CloseBraceToken, sourceFile);
addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n));
break;
}
case SyntaxKind.ArrayLiteralExpression:
let openBracket = findChildOfKind(n, SyntaxKind.OpenBracketToken, sourceFile);
let closeBracket = findChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile);
addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n));
break;
}
depth++;
forEachChild(n, walk);
depth--;
}
walk(sourceFile);
return elements;
}
}
}
+672 -566
View File
File diff suppressed because it is too large Load Diff
+18
View File
@@ -137,11 +137,21 @@ module ts {
findReferences(fileName: string, position: number): string;
/**
* @deprecated
* Returns a JSON-encoded value of the type:
* { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[]
*/
getOccurrencesAtPosition(fileName: string, position: number): string;
/**
* Returns a JSON-encoded value of the type:
* { fileName: string; highlights: { start: number; length: number, isDefinition: boolean }[] }[]
*
* @param fileToSearch A JSON encoded string[] containing the file names that should be
* considered when searching.
*/
getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string;
/**
* Returns a JSON-encoded value of the type:
* { name: string; kind: string; kindModifiers: string; containerName: string; containerKind: string; matchKind: string; fileName: string; textSpan: { start: number; length: number}; } [] = [];
@@ -591,6 +601,14 @@ module ts {
});
}
public getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string {
return this.forwardJSONCall(
"getDocumentHighlights('" + fileName + "', " + position + ")",
() => {
return this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch));
});
}
/// COMPLETION LISTS
/**
@@ -1,12 +1,18 @@
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,6): error TS2461: Type 'string | number' is not an array type.
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,7): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error TS2322: Type 'string' is not assignable to type 'number'.
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts (1 errors) ====
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts (3 errors) ====
var a: string, b: number;
var tuple: [number, string] = [2, "3"];
for ([a = 1, b = ""] of tuple) {
~~~~~~~~~~~~~~~
!!! error TS2461: Type 'string | number' is not an array type.
~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
a;
b;
}
@@ -14,6 +14,7 @@ obj[Symbol.foo];
var Symbol;
var obj = (_a = {},
_a[Symbol.foo] = 0,
_a);
_a
);
obj[Symbol.foo];
var _a;
@@ -2,7 +2,5 @@
var v = { [yield]: foo }
//// [FunctionDeclaration8_es6.js]
var v = (_a = {},
_a[yield] = foo,
_a);
var v = (_a = {}, _a[yield] = foo, _a);
var _a;
@@ -5,8 +5,6 @@ function * foo() {
//// [FunctionDeclaration9_es6.js]
function foo() {
var v = (_a = {},
_a[] = foo,
_a);
var v = (_a = {}, _a[] = foo, _a);
var _a;
}
@@ -2,7 +2,5 @@
var v = { *[foo()]() { } }
//// [FunctionPropertyAssignments5_es6.js]
var v = (_a = {},
_a[foo()] = function () { },
_a);
var v = (_a = {}, _a[foo()] = function () { }, _a);
var _a;
@@ -9,44 +9,55 @@ function f0() {
var a1 = [...a];
>a1 : number[]
>[...a] : number[]
>...a : number
>a : number[]
var a2 = [1, ...a];
>a2 : number[]
>[1, ...a] : number[]
>...a : number
>a : number[]
var a3 = [1, 2, ...a];
>a3 : number[]
>[1, 2, ...a] : number[]
>...a : number
>a : number[]
var a4 = [...a, 1];
>a4 : number[]
>[...a, 1] : number[]
>...a : number
>a : number[]
var a5 = [...a, 1, 2];
>a5 : number[]
>[...a, 1, 2] : number[]
>...a : number
>a : number[]
var a6 = [1, 2, ...a, 1, 2];
>a6 : number[]
>[1, 2, ...a, 1, 2] : number[]
>...a : number
>a : number[]
var a7 = [1, ...a, 2, ...a];
>a7 : number[]
>[1, ...a, 2, ...a] : number[]
>...a : number
>a : number[]
>...a : number
>a : number[]
var a8 = [...a, ...a, ...a];
>a8 : number[]
>[...a, ...a, ...a] : number[]
>...a : number
>a : number[]
>...a : number
>a : number[]
>...a : number
>a : number[]
}
@@ -60,6 +71,7 @@ function f1() {
var b = ["hello", ...a, true];
>b : (string | number | boolean)[]
>["hello", ...a, true] : (string | number | boolean)[]
>...a : number
>a : number[]
var b: (string | number | boolean)[];
@@ -72,19 +84,29 @@ function f2() {
var a = [...[...[...[...[...[]]]]]];
>a : any[]
>[...[...[...[...[...[]]]]]] : undefined[]
>...[...[...[...[...[]]]]] : undefined
>[...[...[...[...[]]]]] : undefined[]
>...[...[...[...[]]]] : undefined
>[...[...[...[]]]] : undefined[]
>...[...[...[]]] : undefined
>[...[...[]]] : undefined[]
>...[...[]] : undefined
>[...[]] : undefined[]
>...[] : undefined
>[] : undefined[]
var b = [...[...[...[...[...[5]]]]]];
>b : number[]
>[...[...[...[...[...[5]]]]]] : number[]
>...[...[...[...[...[5]]]]] : number
>[...[...[...[...[5]]]]] : number[]
>...[...[...[...[5]]]] : number
>[...[...[...[5]]]] : number[]
>...[...[...[5]]] : number
>[...[...[5]]] : number[]
>...[...[5]] : number
>[...[5]] : number[]
>...[5] : number
>[5] : number[]
}
@@ -13,6 +13,17 @@ var d = n => c = n;
var d = (n) => c = n;
var d: (n: any) => any;
// Binding patterns in arrow functions
var p1 = ([a]) => { };
var p2 = ([...a]) => { };
var p3 = ([, a]) => { };
var p4 = ([, ...a]) => { };
var p5 = ([a = 1]) => { };
var p6 = ({ a }) => { };
var p7 = ({ a: { b } }) => { };
var p8 = ({ a = 1 }) => { };
var p9 = ({ a: { b = 1 } = { b: 1 } }) => { };
var p10 = ([{ value, done }]) => { };
// Arrow function used in class member initializer
// Arrow function used in class member function
@@ -100,6 +111,37 @@ var c;
var d = function (n) { return c = n; };
var d = function (n) { return c = n; };
var d;
// Binding patterns in arrow functions
var p1 = function (_a) {
var a = _a[0];
};
var p2 = function (_a) {
var a = _a.slice(0);
};
var p3 = function (_a) {
var a = _a[1];
};
var p4 = function (_a) {
var a = _a.slice(1);
};
var p5 = function (_a) {
var _b = _a[0], a = _b === void 0 ? 1 : _b;
};
var p6 = function (_a) {
var a = _a.a;
};
var p7 = function (_a) {
var b = _a.a.b;
};
var p8 = function (_a) {
var _b = _a.a, a = _b === void 0 ? 1 : _b;
};
var p9 = function (_a) {
var _b = _a.a, _c = (_b === void 0 ? { b: 1 } : _b).b, b = _c === void 0 ? 1 : _c;
};
var p10 = function (_a) {
var _b = _a[0], value = _b.value, done = _b.done;
};
// Arrow function used in class member initializer
// Arrow function used in class member function
var MyClass = (function () {
@@ -51,6 +51,61 @@ var d: (n: any) => any;
>d : (n: any) => any
>n : any
// Binding patterns in arrow functions
var p1 = ([a]) => { };
>p1 : ([a]: [any]) => void
>([a]) => { } : ([a]: [any]) => void
>a : any
var p2 = ([...a]) => { };
>p2 : ([...a]: any[]) => void
>([...a]) => { } : ([...a]: any[]) => void
>a : any[]
var p3 = ([, a]) => { };
>p3 : ([, a]: [any, any]) => void
>([, a]) => { } : ([, a]: [any, any]) => void
>a : any
var p4 = ([, ...a]) => { };
>p4 : ([, ...a]: any[]) => void
>([, ...a]) => { } : ([, ...a]: any[]) => void
>a : any[]
var p5 = ([a = 1]) => { };
>p5 : ([a = 1]: [number]) => void
>([a = 1]) => { } : ([a = 1]: [number]) => void
>a : number
var p6 = ({ a }) => { };
>p6 : ({ a }: { a: any; }) => void
>({ a }) => { } : ({ a }: { a: any; }) => void
>a : any
var p7 = ({ a: { b } }) => { };
>p7 : ({ a: { b } }: { a: { b: any; }; }) => void
>({ a: { b } }) => { } : ({ a: { b } }: { a: { b: any; }; }) => void
>a : unknown
>b : any
var p8 = ({ a = 1 }) => { };
>p8 : ({ a = 1 }: { a?: number; }) => void
>({ a = 1 }) => { } : ({ a = 1 }: { a?: number; }) => void
>a : number
var p9 = ({ a: { b = 1 } = { b: 1 } }) => { };
>p9 : ({ a: { b = 1 } = { b: 1 } }: { a?: { b: number; }; }) => void
>({ a: { b = 1 } = { b: 1 } }) => { } : ({ a: { b = 1 } = { b: 1 } }: { a?: { b: number; }; }) => void
>a : unknown
>b : number
>{ b: 1 } : { b: number; }
>b : number
var p10 = ([{ value, done }]) => { };
>p10 : ([{ value, done }]: [{ value: any; done: any; }]) => void
>([{ value, done }]) => { } : ([{ value, done }]: [{ value: any; done: any; }]) => void
>value : any
>done : any
// Arrow function used in class member initializer
// Arrow function used in class member function
@@ -38,11 +38,13 @@ foo(1, 2, "abc");
foo(1, 2, ...a);
>foo(1, 2, ...a) : void
>foo : (x: number, y: number, ...z: string[]) => void
>...a : string
>a : string[]
foo(1, 2, ...a, "abc");
>foo(1, 2, ...a, "abc") : void
>foo : (x: number, y: number, ...z: string[]) => void
>...a : string
>a : string[]
obj.foo(1, 2, "abc");
@@ -56,6 +58,7 @@ obj.foo(1, 2, ...a);
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>...a : string
>a : string[]
obj.foo(1, 2, ...a, "abc");
@@ -63,6 +66,7 @@ obj.foo(1, 2, ...a, "abc");
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>...a : string
>a : string[]
(obj.foo)(1, 2, "abc");
@@ -78,6 +82,7 @@ obj.foo(1, 2, ...a, "abc");
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>...a : string
>a : string[]
(obj.foo)(1, 2, ...a, "abc");
@@ -86,6 +91,7 @@ obj.foo(1, 2, ...a, "abc");
>obj.foo : (x: number, y: number, ...z: string[]) => any
>obj : X
>foo : (x: number, y: number, ...z: string[]) => any
>...a : string
>a : string[]
xa[1].foo(1, 2, "abc");
@@ -101,6 +107,7 @@ xa[1].foo(1, 2, ...a);
>xa[1] : X
>xa : X[]
>foo : (x: number, y: number, ...z: string[]) => any
>...a : string
>a : string[]
xa[1].foo(1, 2, ...a, "abc");
@@ -109,6 +116,7 @@ xa[1].foo(1, 2, ...a, "abc");
>xa[1] : X
>xa : X[]
>foo : (x: number, y: number, ...z: string[]) => any
>...a : string
>a : string[]
(<Function>xa[1].foo)(...[1, 2, "abc"]);
@@ -120,6 +128,7 @@ xa[1].foo(1, 2, ...a, "abc");
>xa[1] : X
>xa : X[]
>foo : (x: number, y: number, ...z: string[]) => any
>...[1, 2, "abc"] : string | number
>[1, 2, "abc"] : (string | number)[]
class C {
@@ -145,6 +154,7 @@ class C {
>foo : (x: number, y: number, ...z: string[]) => void
>x : number
>y : number
>...z : string
>z : string[]
}
foo(x: number, y: number, ...z: string[]) {
@@ -167,6 +177,7 @@ class D extends C {
super(1, 2, ...a);
>super(1, 2, ...a) : void
>super : typeof C
>...a : string
>a : string[]
}
foo() {
@@ -183,6 +194,7 @@ class D extends C {
>super.foo : (x: number, y: number, ...z: string[]) => void
>super : C
>foo : (x: number, y: number, ...z: string[]) => void
>...a : string
>a : string[]
}
}
@@ -192,5 +204,6 @@ var c = new C(1, 2, ...a);
>c : C
>new C(1, 2, ...a) : C
>C : typeof C
>...a : string
>a : string[]
@@ -32,5 +32,6 @@ var v = (_a = {},
_a[true] = function () { },
_a["hello bye"] = function () { },
_a["hello " + a + " bye"] = function () { },
_a);
_a
);
var _a;
@@ -21,16 +21,61 @@ var s;
var n;
var a;
var v = (_a = {},
_a[s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }),
_a[n] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }),
_a[s + s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }),
_a[s + n] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }),
_a[+s] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }),
_a[""] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }),
_a[0] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }),
_a[a] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }),
_a[true] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }),
_a["hello bye"] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }),
_a["hello " + a + " bye"] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }),
_a);
Object.defineProperty(_a, s, {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, n, {
set: function (v) { },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, s + s, {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, s + n, {
set: function (v) { },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, +s, {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, "", {
set: function (v) { },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, 0, {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, a, {
set: function (v) { },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, true, {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, "hello bye", {
set: function (v) { },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, "hello " + a + " bye", {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
_a
);
var _a;
@@ -9,6 +9,7 @@ function foo() {
function foo() {
var obj = (_a = {},
_a[this.bar] = 0,
_a);
_a
);
var _a;
}
@@ -10,6 +10,7 @@ var M;
(function (M) {
var obj = (_a = {},
_a[this.bar] = 0,
_a);
_a
);
var _a;
})(M || (M = {}));
@@ -6,7 +6,17 @@ var v = {
//// [computedPropertyNames1_ES5.js]
var v = (_a = {},
_a[0 + 1] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }),
_a[0 + 1] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }),
_a);
Object.defineProperty(_a, 0 + 1, {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, 0 + 1, {
set: function (v) { } //No error
,
enumerable: true,
configurable: true
}),
_a
);
var _a;
@@ -6,5 +6,6 @@ var obj = {
//// [computedPropertyNames20_ES5.js]
var obj = (_a = {},
_a[this.bar] = 0,
_a);
_a
);
var _a;
@@ -15,7 +15,8 @@ var C = (function () {
C.prototype.bar = function () {
var obj = (_a = {},
_a[this.bar()] = function () { },
_a);
_a
);
return 0;
var _a;
};
@@ -15,9 +15,7 @@ var C = (function () {
C.prototype.bar = function () {
return 0;
};
C.prototype[(_a = {},
_a[this.bar()] = 1,
_a)[0]] = function () { };
C.prototype[(_a = {}, _a[this.bar()] = 1, _a)[0]] = function () { };
return C;
var _a;
})();
@@ -36,7 +36,8 @@ var C = (function (_super) {
C.prototype.foo = function () {
var obj = (_a = {},
_a[_super.prototype.bar.call(this)] = function () { },
_a);
_a
);
return 0;
var _a;
};
@@ -30,9 +30,7 @@ var C = (function (_super) {
function C() {
_super.apply(this, arguments);
}
C.prototype[(_a = {},
_a[_super.bar.call(this)] = 1,
_a)[0]] = function () { };
C.prototype[(_a = {}, _a[_super.bar.call(this)] = 1, _a)[0]] = function () { };
return C;
var _a;
})(Base);
@@ -28,7 +28,8 @@ var C = (function (_super) {
_super.call(this);
var obj = (_a = {},
_a[(_super.call(this), "prop")] = function () { },
_a);
_a
);
var _a;
}
return C;
@@ -19,7 +19,8 @@ var C = (function () {
(function () {
var obj = (_a = {},
_a[_this.bar()] = function () { },
_a);
_a
);
var _a;
});
return 0;
@@ -33,8 +33,12 @@ var C = (function (_super) {
_super.call(this);
(function () {
var obj = (_a = {},
// Ideally, we would capture this. But the reference is
// illegal, and not capturing this is consistent with
//treatment of other similar violations.
_a[(_super.call(this), "prop")] = function () { },
_a);
_a
);
var _a;
});
}
@@ -40,7 +40,8 @@ var C = (function (_super) {
(function () {
var obj = (_a = {},
_a[_super.prototype.bar.call(_this)] = function () { },
_a);
_a
);
var _a;
});
return 0;
@@ -23,7 +23,6 @@ class Base {
}
class C extends Base {
foo() {
var _this = this;
(() => {
var obj = {
[super.bar()]() { } // needs capture
@@ -17,7 +17,8 @@ var C = (function () {
C.prototype.bar = function () {
var obj = (_a = {},
_a[foo()] = function () { },
_a);
_a
);
return 0;
var _a;
};
@@ -17,7 +17,8 @@ var C = (function () {
C.bar = function () {
var obj = (_a = {},
_a[foo()] = function () { },
_a);
_a
);
return 0;
var _a;
};
@@ -6,5 +6,6 @@ var o = {
//// [computedPropertyNames46_ES5.js]
var o = (_a = {},
_a["" || 0] = 0,
_a);
_a
);
var _a;
@@ -16,5 +16,6 @@ var E2;
})(E2 || (E2 = {}));
var o = (_a = {},
_a[E1.x || E2.x] = 0,
_a);
_a
);
var _a;
@@ -25,11 +25,14 @@ var E;
var a;
extractIndexer((_a = {},
_a[a] = "",
_a)); // Should return string
_a
)); // Should return string
extractIndexer((_b = {},
_b[E.x] = "",
_b)); // Should return string
_b
)); // Should return string
extractIndexer((_c = {},
_c["" || 0] = "",
_c)); // Should return any (widened form of undefined)
_c
)); // Should return any (widened form of undefined)
var _a, _b, _c;
@@ -27,24 +27,41 @@ var x = {
//// [computedPropertyNames49_ES5.js]
var x = (_a = {
p1: 10
},
_a.p1 = 10,
_a[1 + 1] = Object.defineProperty({ get: function () {
p1: 10
},
Object.defineProperty(_a, 1 + 1, {
get: function () {
throw 10;
}, enumerable: true, configurable: true }),
_a[1 + 1] = Object.defineProperty({ get: function () {
},
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, 1 + 1, {
get: function () {
return 10;
}, enumerable: true, configurable: true }),
_a[1 + 1] = Object.defineProperty({ set: function () {
},
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, 1 + 1, {
set: function () {
// just throw
throw 10;
}, enumerable: true, configurable: true }),
_a.foo = Object.defineProperty({ get: function () {
},
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, "foo", {
get: function () {
if (1 == 1) {
return 10;
}
}, enumerable: true, configurable: true }),
},
enumerable: true,
configurable: true
}),
,
_a.p2 = 20,
_a);
_a
);
var _a;
@@ -32,5 +32,6 @@ var v = (_a = {},
_a[true] = 0,
_a["hello bye"] = 0,
_a["hello " + a + " bye"] = 0,
_a);
_a
);
var _a;
@@ -27,29 +27,37 @@ var x = {
//// [computedPropertyNames50_ES5.js]
var x = (_a = {
p1: 10,
get foo() {
if (1 == 1) {
return 10;
}
}
},
_a.p1 = 10,
_a.foo = Object.defineProperty({ get: function () {
p1: 10,
get foo() {
if (1 == 1) {
return 10;
}
}, enumerable: true, configurable: true }),
_a[1 + 1] = Object.defineProperty({ get: function () {
}
},
Object.defineProperty(_a, 1 + 1, {
get: function () {
throw 10;
}, enumerable: true, configurable: true }),
_a[1 + 1] = Object.defineProperty({ set: function () {
},
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, 1 + 1, {
set: function () {
// just throw
throw 10;
}, enumerable: true, configurable: true }),
_a[1 + 1] = Object.defineProperty({ get: function () {
},
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, 1 + 1, {
get: function () {
return 10;
}, enumerable: true, configurable: true }),
},
enumerable: true,
configurable: true
}),
,
_a.p2 = 20,
_a);
_a
);
var _a;
@@ -18,5 +18,6 @@ var v = (_a = {},
_a[{}] = 0,
_a[undefined] = undefined,
_a[null] = null,
_a);
_a
);
var _a;
@@ -16,5 +16,6 @@ var v = (_a = {},
_a[p1] = 0,
_a[p2] = 1,
_a[p3] = 2,
_a);
_a
);
var _a;
@@ -13,5 +13,6 @@ var E;
})(E || (E = {}));
var v = (_a = {},
_a[E.member] = 0,
_a);
_a
);
var _a;
@@ -15,6 +15,7 @@ function f() {
var v = (_a = {},
_a[t] = 0,
_a[u] = 1,
_a);
_a
);
var _a;
}
@@ -16,5 +16,6 @@ var v = (_a = {},
_a[f("")] = 0,
_a[f(0)] = 0,
_a[f(true)] = 0,
_a);
_a
);
var _a;
@@ -12,5 +12,6 @@ var o: I = {
var o = (_a = {},
_a[+"foo"] = "",
_a[+"bar"] = 0,
_a);
_a
);
var _a;
@@ -13,5 +13,6 @@ var o: I = {
var o = (_a = {},
_a["" + 0] = function (y) { return y.length; },
_a["" + 1] = function (y) { return y.length; },
_a);
_a
);
var _a;
@@ -13,5 +13,6 @@ var o: I = {
var o = (_a = {},
_a[+"foo"] = function (y) { return y.length; },
_a[+"bar"] = function (y) { return y.length; },
_a);
_a
);
var _a;
@@ -12,5 +12,6 @@ var o: I = {
var o = (_a = {},
_a[+"foo"] = function (y) { return y.length; },
_a[+"bar"] = function (y) { return y.length; },
_a);
_a
);
var _a;
@@ -13,5 +13,6 @@ var o: I = {
var o = (_a = {},
_a["" + "foo"] = "",
_a["" + "bar"] = 0,
_a);
_a
);
var _a;
@@ -13,5 +13,6 @@ var o: I = {
var o = (_a = {},
_a[+"foo"] = "",
_a[+"bar"] = 0,
_a);
_a
);
var _a;
@@ -15,13 +15,12 @@ foo({
//// [computedPropertyNamesContextualType6_ES5.js]
foo((_a = {
p: "",
0: function () { }
},
_a.p = "",
_a[0] = function () { },
p: "",
0: function () { }
},
_a["hi" + "bye"] = true,
_a[0 + 1] = 0,
_a[+"hi"] = [0],
_a));
_a
));
var _a;
@@ -15,13 +15,12 @@ foo({
//// [computedPropertyNamesContextualType7_ES5.js]
foo((_a = {
p: "",
0: function () { }
},
_a.p = "",
_a[0] = function () { },
p: "",
0: function () { }
},
_a["hi" + "bye"] = true,
_a[0 + 1] = 0,
_a[+"hi"] = [0],
_a));
_a
));
var _a;
@@ -13,5 +13,6 @@ var o: I = {
var o = (_a = {},
_a["" + "foo"] = "",
_a["" + "bar"] = 0,
_a);
_a
);
var _a;
@@ -13,5 +13,6 @@ var o: I = {
var o = (_a = {},
_a[+"foo"] = "",
_a[+"bar"] = 0,
_a);
_a
);
var _a;
@@ -10,9 +10,18 @@ var v = {
var v = (_a = {},
_a["" + ""] = 0,
_a["" + ""] = function () { },
_a["" + ""] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }),
_a["" + ""] = Object.defineProperty({ set: function (x) { }, enumerable: true, configurable: true }),
_a);
Object.defineProperty(_a, "" + "", {
get: function () { return 0; },
enumerable: true,
configurable: true
}),
Object.defineProperty(_a, "" + "", {
set: function (x) { },
enumerable: true,
configurable: true
}),
_a
);
var _a;
@@ -10,6 +10,7 @@ var v = (_a = {},
_a["hello"] = function () {
debugger;
},
_a);
_a
);
var _a;
//# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map
@@ -1,2 +1,2 @@
//// [computedPropertyNamesSourceMap2_ES5.js.map]
{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG;OACH,OAAO;QACJ,QAAQ,CAAC;IACb,CAAC;OACJ,CAAA"}
{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":["[\"hello\"]"],"mappings":"AAAA,IAAI,CAAC,GAAG;IACJ,GAAC,OAAO,CAAC;QACLA,QAAQA,CAACA;IACbA,CAACA;;CACJ,CAAA"}
@@ -24,45 +24,53 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts
4 >Emitted(1, 9) Source(1, 9) + SourceIndex(0)
---
>>> _a["hello"] = function () {
1->^^^^^^^
2 > ^^^^^^^
3 > ^^^^->
1->^^^^
2 > ^^^
3 > ^^^^^^^
4 > ^
5 > ^^^->
1->{
> [
2 > "hello"
1->Emitted(2, 8) Source(2, 6) + SourceIndex(0)
2 >Emitted(2, 15) Source(2, 13) + SourceIndex(0)
>
2 > [
3 > "hello"
4 > ]
1->Emitted(2, 5) Source(2, 5) + SourceIndex(0)
2 >Emitted(2, 8) Source(2, 6) + SourceIndex(0)
3 >Emitted(2, 15) Source(2, 13) + SourceIndex(0)
4 >Emitted(2, 16) Source(2, 14) + SourceIndex(0)
---
>>> debugger;
1->^^^^^^^^
2 > ^^^^^^^^
3 > ^
1->]() {
1->() {
>
2 > debugger
3 > ;
1->Emitted(3, 9) Source(3, 9) + SourceIndex(0)
2 >Emitted(3, 17) Source(3, 17) + SourceIndex(0)
3 >Emitted(3, 18) Source(3, 18) + SourceIndex(0)
1->Emitted(3, 9) Source(3, 9) + SourceIndex(0) name (["hello"])
2 >Emitted(3, 17) Source(3, 17) + SourceIndex(0) name (["hello"])
3 >Emitted(3, 18) Source(3, 18) + SourceIndex(0) name (["hello"])
---
>>> },
1 >^^^^
2 > ^
3 > ^^^^->
3 > ^^->
1 >
>
2 > }
1 >Emitted(4, 5) Source(4, 5) + SourceIndex(0)
2 >Emitted(4, 6) Source(4, 6) + SourceIndex(0)
1 >Emitted(4, 5) Source(4, 5) + SourceIndex(0) name (["hello"])
2 >Emitted(4, 6) Source(4, 6) + SourceIndex(0) name (["hello"])
---
>>> _a);
1->^^^^^^^
2 > ^
>>> _a
>>>);
1->^
2 > ^
3 > ^^^^^^->
1->
>}
2 >
1->Emitted(5, 8) Source(5, 2) + SourceIndex(0)
2 >Emitted(5, 9) Source(5, 2) + SourceIndex(0)
2 >
1->Emitted(6, 2) Source(5, 2) + SourceIndex(0)
2 >Emitted(6, 3) Source(5, 2) + SourceIndex(0)
---
>>>var _a;
>>>//# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map
@@ -7,4 +7,5 @@ export default 1 + 2;
//// [declarationEmitDefaultExport5.d.ts]
export default : number;
declare var _default: number;
export default _default;
@@ -12,4 +12,5 @@ export default new A();
//// [declarationEmitDefaultExport6.d.ts]
export declare class A {
}
export default : A;
declare var _default: A;
export default _default;
@@ -0,0 +1,18 @@
//// [declarationEmitDefaultExport8.ts]
var _default = 1;
export {_default as d}
export default 1 + 2;
//// [declarationEmitDefaultExport8.js]
var _default = 1;
export { _default as d };
export default 1 + 2;
//// [declarationEmitDefaultExport8.d.ts]
declare var _default: number;
export { _default as d };
declare var _default_1: number;
export default _default_1;
@@ -0,0 +1,12 @@
=== tests/cases/compiler/declarationEmitDefaultExport8.ts ===
var _default = 1;
>_default : number
export {_default as d}
>_default : number
>d : number
export default 1 + 2;
>1 + 2 : number
@@ -7,7 +7,7 @@ declare function dec<T>(target: T): T;
>T : T
@dec
>dec : unknown
>dec : <T>(target: T) => T
class C {
>C : C
@@ -7,7 +7,7 @@ declare function dec<T>(target: T): T;
>T : T
@dec
>dec : unknown
>dec : <T>(target: T) => T
export class C {
>C : C
@@ -14,6 +14,6 @@ class C {
>C : C
@dec get accessor() { return 1; }
>dec : unknown
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>accessor : number
}
@@ -14,6 +14,6 @@ class C {
>C : C
@dec public get accessor() { return 1; }
>dec : unknown
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>accessor : number
}
@@ -14,7 +14,7 @@ class C {
>C : C
@dec set accessor(value: number) { }
>dec : unknown
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>accessor : number
>value : number
}
@@ -14,7 +14,7 @@ class C {
>C : C
@dec public set accessor(value: number) { }
>dec : unknown
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>accessor : number
>value : number
}
@@ -10,6 +10,6 @@ class C {
>C : C
constructor(@dec p: number) {}
>dec : unknown
>dec : (target: Function, propertyKey: string | symbol, parameterIndex: number) => void
>p : number
}
@@ -14,6 +14,6 @@ class C {
>C : C
@dec method() {}
>dec : unknown
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>method : () => void
}
@@ -0,0 +1,29 @@
//// [decoratorOnClassMethod13.ts]
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
class C {
@dec ["1"]() { }
@dec ["b"]() { }
}
//// [decoratorOnClassMethod13.js]
var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) {
switch (arguments.length) {
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
}
};
class C {
[_a = "1"]() { }
[_b = "b"]() { }
}
Object.defineProperty(C.prototype, _a,
__decorate([
dec
], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)));
Object.defineProperty(C.prototype, _b,
__decorate([
dec
], C.prototype, _b, Object.getOwnPropertyDescriptor(C.prototype, _b)));
var _a, _b;
@@ -0,0 +1,21 @@
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod13.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 ["1"]() { }
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
@dec ["b"]() { }
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
}
@@ -14,6 +14,6 @@ class C {
>C : C
@dec public method() {}
>dec : unknown
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
>method : () => void
}
@@ -14,5 +14,5 @@ class C {
>C : C
@dec ["method"]() {}
>dec : unknown
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
}
@@ -14,5 +14,5 @@ class C {
>C : C
@dec ["method"]() {}
>dec : unknown
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
}
@@ -14,5 +14,5 @@ class C {
>C : C
@dec public ["method"]() {}
>dec : unknown
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
}
@@ -10,6 +10,6 @@ class C {
>C : C
@dec method() {}
>dec : unknown
>dec : <T>(target: T) => T
>method : () => void
}
@@ -11,6 +11,6 @@ class C {
method(@dec p: number) {}
>method : (p: number) => void
>dec : unknown
>dec : (target: Function, propertyKey: string | symbol, parameterIndex: number) => void
>p : number
}
@@ -8,6 +8,6 @@ class C {
>C : C
@dec prop;
>dec : unknown
>dec : (target: any, propertyKey: string) => void
>prop : any
}
@@ -9,6 +9,6 @@ class C {
>C : C
@dec prop;
>dec : unknown
>dec : () => <T>(target: any, propertyKey: string) => void
>prop : any
}
@@ -8,6 +8,6 @@ class C {
>C : C
@dec public prop;
>dec : unknown
>dec : (target: any, propertyKey: string) => void
>prop : any
}
@@ -8,6 +8,6 @@ class C {
>C : C
@dec prop;
>dec : unknown
>dec : (target: Function) => void
>prop : any
}

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