Merge remote-tracking branch 'origin/master' into

serverConfigurationMessage.
This commit is contained in:
steveluc
2015-03-17 17:51:16 -07:00
485 changed files with 9597 additions and 2722 deletions
+1
View File
@@ -0,0 +1 @@
*.js linguist-language=TypeScript
+1 -10
View File
@@ -3,13 +3,4 @@ language: node_js
node_js:
- '0.10'
sudo: false
before_script: npm install -g codeclimate-test-reporter
after_script:
- cat coverage/lcov.info | codeclimate
addons:
code_climate:
repo_token: 9852ac5362c8cc38c07ca5adc0f94c20c6c79bd78e17933dc284598a65338656
sudo: false
+2 -3
View File
@@ -38,10 +38,9 @@
"mocha": "latest",
"chai": "latest",
"browserify": "latest",
"istanbul": "latest",
"codeclimate-test-reporter": "latest"
"istanbul": "latest"
},
"scripts": {
"test": "jake generate-code-coverage"
"test": "jake runtests"
}
}
+1 -2
View File
@@ -65,8 +65,7 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable, nameMap:
' ' + convertPropertyName(nameMap[name]) +
': { code: ' + diagnosticDetails.code +
', category: DiagnosticCategory.' + diagnosticDetails.category +
', key: "' + name.replace('"', '\\"') + '"' +
(diagnosticDetails.isEarly ? ', isEarly: true' : '') +
', key: "' + name.replace(/[\"]/g, '\\"') + '"' +
' },\r\n';
}
+8 -7
View File
@@ -322,13 +322,14 @@ module ts {
}
else {
bindDeclaration(node, SymbolFlags.ValueModule, SymbolFlags.ValueModuleExcludes, /*isBlockScopeContainer*/ true);
if (state === ModuleInstanceState.ConstEnumOnly) {
// mark value module as module that contains only enums
node.symbol.constEnumOnlyModule = true;
let currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly;
if (node.symbol.constEnumOnlyModule === undefined) {
// non-merged case - use the current state
node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly;
}
else if (node.symbol.constEnumOnlyModule) {
// const only value module was merged with instantiated module - reset flag
node.symbol.constEnumOnlyModule = false;
else {
// merged case: module is const enum only if all its pieces are non-instantiated or const enum
node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly;
}
}
}
@@ -505,7 +506,7 @@ module ts {
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
break;
case SyntaxKind.ExportAssignment:
if ((<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
if ((<ExportAssignment>node).expression && (<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.AliasExcludes);
}
+138 -72
View File
@@ -79,8 +79,7 @@ module ts {
let emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
let anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
let noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
let inferenceFailureType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
let anySignature = createSignature(undefined, undefined, emptyArray, anyType, 0, false, false);
let unknownSignature = createSignature(undefined, undefined, emptyArray, unknownType, 0, false, false);
@@ -567,7 +566,7 @@ module ts {
}
function getTargetOfExportAssignment(node: ExportAssignment): Symbol {
return resolveEntityName(<Identifier>node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace);
return node.expression && resolveEntityName(<Identifier>node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace);
}
function getTargetOfImportDeclaration(node: Declaration): Symbol {
@@ -623,7 +622,7 @@ module ts {
if (!links.referenced) {
links.referenced = true;
let node = getDeclarationOfAliasSymbol(symbol);
if (node.kind === SyntaxKind.ExportAssignment) {
if (node.kind === SyntaxKind.ExportAssignment && (<ExportAssignment>node).expression) {
// export default <symbol>
checkExpressionCached((<ExportAssignment>node).expression);
}
@@ -784,7 +783,7 @@ module ts {
}
function getExportsForModule(moduleSymbol: Symbol): SymbolTable {
if (compilerOptions.target < ScriptTarget.ES6) {
if (languageVersion < ScriptTarget.ES6) {
// A default export hides all other exports in CommonJS and AMD modules
let defaultSymbol = getExportAssignmentSymbol(moduleSymbol);
if (defaultSymbol) {
@@ -1813,6 +1812,11 @@ module ts {
case SyntaxKind.ParenthesizedType:
return isDeclarationVisible(<Declaration>node.parent);
case SyntaxKind.ImportClause:
case SyntaxKind.NamespaceImport:
case SyntaxKind.ImportSpecifier:
return false;
// Type parameters are always visible
case SyntaxKind.TypeParameter:
// Source file is always visible
@@ -2073,7 +2077,16 @@ module ts {
}
// Handle export default expressions
if (declaration.kind === SyntaxKind.ExportAssignment) {
return links.type = checkExpression((<ExportAssignment>declaration).expression);
var exportAssignment = <ExportAssignment>declaration;
if (exportAssignment.expression) {
return links.type = checkExpression(exportAssignment.expression);
}
else if (exportAssignment.type) {
return links.type = getTypeFromTypeNode(exportAssignment.type);
}
else {
return links.type = anyType;
}
}
// Handle variable, parameter or property
links.type = resolvingType;
@@ -3505,6 +3518,7 @@ module ts {
return t => {
for (let i = 0; i < context.typeParameters.length; i++) {
if (t === context.typeParameters[i]) {
context.inferences[i].isFixed = true;
return getInferredType(context, i);
}
}
@@ -4363,8 +4377,11 @@ module ts {
}
function reportNoCommonSupertypeError(types: Type[], errorLocation: Node, errorMessageChainHead: DiagnosticMessageChain): void {
// The downfallType/bestSupertypeDownfallType is the first type that caused a particular candidate
// to not be the common supertype. So if it weren't for this one downfallType (and possibly others),
// the type in question could have been the common supertype.
let bestSupertype: Type;
let bestSupertypeDownfallType: Type; // The type that caused bestSupertype not to be the common supertype
let bestSupertypeDownfallType: Type;
let bestSupertypeScore = 0;
for (let i = 0; i < types.length; i++) {
@@ -4379,6 +4396,8 @@ module ts {
}
}
Debug.assert(!!downfallType, "If there is no common supertype, each type should have a downfallType");
if (score > bestSupertypeScore) {
bestSupertype = types[i];
bestSupertypeDownfallType = downfallType;
@@ -4561,13 +4580,12 @@ module ts {
function createInferenceContext(typeParameters: TypeParameter[], inferUnionTypes: boolean): InferenceContext {
let inferences: TypeInferences[] = [];
for (let unused of typeParameters) {
inferences.push({ primary: undefined, secondary: undefined });
inferences.push({ primary: undefined, secondary: undefined, isFixed: false });
}
return {
typeParameters: typeParameters,
inferUnionTypes: inferUnionTypes,
inferenceCount: 0,
inferences: inferences,
typeParameters,
inferUnionTypes,
inferences,
inferredTypes: new Array(typeParameters.length),
};
}
@@ -4613,11 +4631,21 @@ module ts {
for (let i = 0; i < typeParameters.length; i++) {
if (target === typeParameters[i]) {
let inferences = context.inferences[i];
let candidates = inferiority ?
inferences.secondary || (inferences.secondary = []) :
inferences.primary || (inferences.primary = []);
if (!contains(candidates, source)) candidates.push(source);
break;
if (!inferences.isFixed) {
// Any inferences that are made to a type parameter in a union type are inferior
// to inferences made to a flat (non-union) type. This is because if we infer to
// T | string[], we really don't know if we should be inferring to T or not (because
// the correct constituent on the target side could be string[]). Therefore, we put
// such inferior inferences into a secondary bucket, and only use them if the primary
// bucket is empty.
let candidates = inferiority ?
inferences.secondary || (inferences.secondary = []) :
inferences.primary || (inferences.primary = []);
if (!contains(candidates, source)) {
candidates.push(source);
}
}
return;
}
}
}
@@ -4723,21 +4751,35 @@ module ts {
function getInferredType(context: InferenceContext, index: number): Type {
let inferredType = context.inferredTypes[index];
let inferenceSucceeded: boolean;
if (!inferredType) {
let inferences = getInferenceCandidates(context, index);
if (inferences.length) {
// Infer widened union or supertype, or the undefined type for no common supertype
// Infer widened union or supertype, or the unknown type for no common supertype
let unionOrSuperType = context.inferUnionTypes ? getUnionType(inferences) : getCommonSupertype(inferences);
inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : inferenceFailureType;
inferredType = unionOrSuperType ? getWidenedType(unionOrSuperType) : unknownType;
inferenceSucceeded = !!unionOrSuperType;
}
else {
// Infer the empty object type when no inferences were made
// Infer the empty object type when no inferences were made. It is important to remember that
// in this case, inference still succeeds, meaning there is no error for not having inference
// candidates. An inference error only occurs when there are *conflicting* candidates, i.e.
// candidates with no common supertype.
inferredType = emptyObjectType;
inferenceSucceeded = true;
}
if (inferredType !== inferenceFailureType) {
// Only do the constraint check if inference succeeded (to prevent cascading errors)
if (inferenceSucceeded) {
let constraint = getConstraintOfTypeParameter(context.typeParameters[index]);
inferredType = constraint && !isTypeAssignableTo(inferredType, constraint) ? constraint : inferredType;
}
else if (context.failedTypeParameterIndex === undefined || context.failedTypeParameterIndex > index) {
// If inference failed, it is necessary to record the index of the failed type parameter (the one we are on).
// It might be that inference has already failed on a later type parameter on a previous call to inferTypeArguments.
// So if this failure is on preceding type parameter, this type parameter is the new failure index.
context.failedTypeParameterIndex = index;
}
context.inferredTypes[index] = inferredType;
}
return inferredType;
@@ -6334,11 +6376,32 @@ module ts {
return getSignatureInstantiation(signature, getInferredTypes(context));
}
function inferTypeArguments(signature: Signature, args: Expression[], excludeArgument: boolean[]): InferenceContext {
function inferTypeArguments(signature: Signature, args: Expression[], excludeArgument: boolean[], context: InferenceContext): void {
let typeParameters = signature.typeParameters;
let context = createInferenceContext(typeParameters, /*inferUnionTypes*/ false);
let inferenceMapper = createInferenceMapper(context);
// Clear out all the inference results from the last time inferTypeArguments was called on this context
for (let i = 0; i < typeParameters.length; i++) {
// As an optimization, we don't have to clear (and later recompute) inferred types
// for type parameters that have already been fixed on the previous call to inferTypeArguments.
// It would be just as correct to reset all of them. But then we'd be repeating the same work
// for the type parameters that were fixed, namely the work done by getInferredType.
if (!context.inferences[i].isFixed) {
context.inferredTypes[i] = undefined;
}
}
// On this call to inferTypeArguments, we may get more inferences for certain type parameters that were not
// fixed last time. This means that a type parameter that failed inference last time may succeed this time,
// or vice versa. Therefore, the failedTypeParameterIndex is useless if it points to an unfixed type parameter,
// because it may change. So here we reset it. However, getInferredType will not revisit any type parameters
// that were previously fixed. So if a fixed type parameter failed previously, it will fail again because
// it will contain the exact same set of inferences. So if we reset the index from a fixed type parameter,
// we will lose information that we won't recover this time around.
if (context.failedTypeParameterIndex !== undefined && !context.inferences[context.failedTypeParameterIndex].isFixed) {
context.failedTypeParameterIndex = undefined;
}
// We perform two passes over the arguments. In the first pass we infer from all arguments, but use
// wildcards for all context sensitive function expressions.
for (let i = 0; i < args.length; i++) {
@@ -6373,18 +6436,7 @@ module ts {
}
}
let inferredTypes = getInferredTypes(context);
// Inference has failed if the inferenceFailureType type is in list of inferences
context.failedTypeParameterIndex = indexOf(inferredTypes, inferenceFailureType);
// Wipe out the inferenceFailureType from the array so that error recovery can work properly
for (let i = 0; i < inferredTypes.length; i++) {
if (inferredTypes[i] === inferenceFailureType) {
inferredTypes[i] = unknownType;
}
}
return context;
getInferredTypes(context);
}
function checkTypeArguments(signature: Signature, typeArguments: TypeNode[], typeArgumentResultTypes: Type[], reportErrors: boolean): boolean {
@@ -6618,15 +6670,17 @@ module ts {
return resolveErrorCall(node);
function chooseOverload(candidates: Signature[], relation: Map<RelationComparisonResult>) {
for (let current of candidates) {
if (!hasCorrectArity(node, args, current)) {
for (let originalCandidate of candidates) {
if (!hasCorrectArity(node, args, originalCandidate)) {
continue;
}
let originalCandidate = current;
let inferenceResult: InferenceContext;
let candidate: Signature;
let typeArgumentsAreValid: boolean;
let inferenceContext = originalCandidate.typeParameters
? createInferenceContext(originalCandidate.typeParameters, /*inferUnionTypes*/ false)
: undefined;
while (true) {
candidate = originalCandidate;
if (candidate.typeParameters) {
@@ -6636,9 +6690,9 @@ module ts {
typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false)
}
else {
inferenceResult = inferTypeArguments(candidate, args, excludeArgument);
typeArgumentsAreValid = inferenceResult.failedTypeParameterIndex < 0;
typeArgumentTypes = inferenceResult.inferredTypes;
inferTypeArguments(candidate, args, excludeArgument, inferenceContext);
typeArgumentsAreValid = inferenceContext.failedTypeParameterIndex === undefined;
typeArgumentTypes = inferenceContext.inferredTypes;
}
if (!typeArgumentsAreValid) {
break;
@@ -6668,7 +6722,7 @@ module ts {
else {
candidateForTypeArgumentError = originalCandidate;
if (!typeArguments) {
resultOfFailedInference = inferenceResult;
resultOfFailedInference = inferenceContext;
}
}
}
@@ -10044,6 +10098,12 @@ module ts {
}
}
}
else {
if (languageVersion >= ScriptTarget.ES6) {
// Import equals declaration is deprecated in es6 or above
grammarErrorOnNode(node, Diagnostics.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);
}
}
}
}
@@ -10075,13 +10135,27 @@ module ts {
if (!checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers);
}
if (node.expression.kind === SyntaxKind.Identifier) {
markExportAsReferenced(node);
if (node.expression) {
if (node.expression.kind === SyntaxKind.Identifier) {
markExportAsReferenced(node);
}
else {
checkExpressionCached(node.expression);
}
}
else {
checkExpressionCached(node.expression);
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);
}
}
checkExternalModuleExports(container);
if (node.isExportEquals && languageVersion >= ScriptTarget.ES6) {
// export assignment is deprecated in es6 or above
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead);
}
}
function getModuleStatements(node: Declaration): ModuleElement[] {
@@ -10124,7 +10198,7 @@ module ts {
if (!links.exportsChecked) {
let defaultSymbol = getExportAssignmentSymbol(moduleSymbol);
if (defaultSymbol) {
if (hasExportedMembers(moduleSymbol)) {
if (languageVersion < ScriptTarget.ES6 && hasExportedMembers(moduleSymbol)) {
let declaration = getDeclarationOfAliasSymbol(defaultSymbol) || defaultSymbol.valueDeclaration;
error(declaration, Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
}
@@ -10914,7 +10988,7 @@ module ts {
}
function generateNameForExportAssignment(node: ExportAssignment) {
if (node.expression.kind !== SyntaxKind.Identifier) {
if (node.expression && node.expression.kind !== SyntaxKind.Identifier) {
assignGeneratedName(node, makeUniqueName("default"));
}
}
@@ -10947,7 +11021,15 @@ module ts {
function getExportNameSubstitution(symbol: Symbol, location: Node): string {
if (isExternalModuleSymbol(symbol.parent)) {
return "exports." + unescapeIdentifier(symbol.name);
var symbolName = unescapeIdentifier(symbol.name);
// If this is es6 or higher, just use the name of the export
// no need to qualify it.
if (languageVersion >= ScriptTarget.ES6) {
return symbolName;
}
else {
return "exports." + symbolName;
}
}
let node = location;
let containerSymbol = getParentOfSymbol(symbol);
@@ -10975,7 +11057,7 @@ module ts {
return getExportNameSubstitution(exportSymbol, node.parent);
}
// Named imports from ES6 import declarations are rewritten
if (symbol.flags & SymbolFlags.Alias) {
if (symbol.flags & SymbolFlags.Alias && languageVersion < ScriptTarget.ES6) {
return getAliasNameSubstitution(symbol);
}
}
@@ -11011,7 +11093,6 @@ module ts {
return true;
}
}
return forEachChild(node, isReferencedAliasDeclaration);
}
function isImplementationOfOverload(node: FunctionLikeDeclaration) {
@@ -11085,26 +11166,11 @@ module ts {
function getBlockScopedVariableId(n: Identifier): number {
Debug.assert(!nodeIsSynthesized(n));
// ignore name parts of property access expressions
if (n.parent.kind === SyntaxKind.PropertyAccessExpression &&
(<PropertyAccessExpression>n.parent).name === n) {
return undefined;
}
let isVariableDeclarationOrBindingElement =
n.parent.kind === SyntaxKind.BindingElement || (n.parent.kind === SyntaxKind.VariableDeclaration && (<VariableDeclaration>n.parent).name === n);
// ignore property names in object binding patterns
if (n.parent.kind === SyntaxKind.BindingElement &&
(<BindingElement>n.parent).propertyName === n) {
return undefined;
}
// for names in variable declarations and binding elements try to short circuit and fetch symbol from the node
let declarationSymbol: Symbol =
(n.parent.kind === SyntaxKind.VariableDeclaration && (<VariableDeclaration>n.parent).name === n) ||
n.parent.kind === SyntaxKind.BindingElement
? getSymbolOfNode(n.parent)
: undefined;
let symbol = declarationSymbol ||
let symbol =
(isVariableDeclarationOrBindingElement ? getSymbolOfNode(n.parent) : undefined) ||
getNodeLinks(n).resolvedSymbol ||
resolveName(n, n.text, SymbolFlags.Value | SymbolFlags.Alias, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined);
@@ -158,6 +158,10 @@ 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." },
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
+18 -1
View File
@@ -617,12 +617,29 @@
},
"Unterminated Unicode escape sequence.": {
"category": "Error",
"code": 1199
"code": 1199
},
"Line terminator not permitted before arrow.": {
"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
},
"Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.": {
"category": "Error",
"code": 1203
},
"Cannot compile external modules into amd or commonjs when targeting es6 or higher.": {
"category": "Error",
"code": 1204
},
"Duplicate identifier '{0}'.": {
"category": "Error",
"code": 2300
+579 -210
View File
File diff suppressed because it is too large Load Diff
+29 -14
View File
@@ -283,7 +283,8 @@ module ts {
visitNode(cbNode, (<ImportOrExportSpecifier>node).name);
case SyntaxKind.ExportAssignment:
return visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<ExportAssignment>node).expression);
visitNode(cbNode, (<ExportAssignment>node).expression) ||
visitNode(cbNode, (<ExportAssignment>node).type);
case SyntaxKind.TemplateExpression:
return visitNode(cbNode, (<TemplateExpression>node).head) || visitNodes(cbNodes, (<TemplateExpression>node).templateSpans);
case SyntaxKind.TemplateSpan:
@@ -613,7 +614,7 @@ module ts {
// change the token touching it, we actually need to look back *at least* one token so
// that the prior token sees that change.
let maxLookahead = 1;
let start = changeRange.span.start;
// the first iteration aligns us with the change start. subsequent iteration move us to
@@ -831,7 +832,7 @@ module ts {
// will immediately bail out of walking any subtrees when we can see that their parents
// are already correct.
let result = parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true)
return result;
}
@@ -1986,7 +1987,7 @@ module ts {
//
// let v = new List < A, B >()
//
// then we have a problem. "v = new List<A" doesn't intersect the change range, so we
// then we have a problem. "v = new List<A" doesn't intersect the change range, so we
// start reparsing at "B" and we completely fail to handle this properly.
//
// In order to prevent this, we do not allow a variable declarator to be reused if it
@@ -3008,9 +3009,9 @@ module ts {
Debug.assert(token === SyntaxKind.EqualsGreaterThanToken, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
let node = <ArrowFunction>createNode(SyntaxKind.ArrowFunction, identifier.pos);
let parameter = <ParameterDeclaration>createNode(SyntaxKind.Parameter, identifier.pos);
parameter.name = identifier;
parameter.name = identifier;
finishNode(parameter);
node.parameters = <NodeArray<ParameterDeclaration>>[parameter];
@@ -3140,8 +3141,8 @@ module ts {
function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction {
let node = <ArrowFunction>createNode(SyntaxKind.ArrowFunction);
// Arrow functions are never generators.
//
// Arrow functions are never generators.
//
// If we're speculatively parsing a signature for a parenthesized arrow function, then
// we have to have a complete parameter list. Otherwise we might see something like
// a => (b => c)
@@ -3206,7 +3207,7 @@ module ts {
// Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and
// we do not that for the 'whenFalse' part.
let node = <ConditionalExpression>createNode(SyntaxKind.ConditionalExpression, leftOperand.pos);
node.condition = leftOperand;
node.condition = leftOperand;
node.questionToken = questionToken;
node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher);
node.colonToken = parseExpectedToken(SyntaxKind.ColonToken, /*reportAtCurrentPosition:*/ false,
@@ -4526,7 +4527,13 @@ module ts {
}
function parseClassDeclaration(fullStart: number, modifiers: ModifiersArray): ClassDeclaration {
let node = <ClassDeclaration>createNode(SyntaxKind.ClassDeclaration, fullStart);
// In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code
let savedStrictModeContext = inStrictModeContext();
if (languageVersion >= ScriptTarget.ES6) {
setStrictModeContext(true);
}
var node = <ClassDeclaration>createNode(SyntaxKind.ClassDeclaration, fullStart);
setModifiers(node, modifiers);
parseExpected(SyntaxKind.ClassKeyword);
node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier();
@@ -4546,7 +4553,10 @@ module ts {
else {
node.members = createMissingList<ClassElement>();
}
return finishNode(node);
var finishedNode = finishNode(node);
setStrictModeContext(savedStrictModeContext);
return finishedNode;
}
function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray<HeritageClause> {
@@ -4774,7 +4784,7 @@ module ts {
// walker.
let result = parseExpression();
// Ensure the string being required is in our 'identifier' table. This will ensure
// that features like 'find refs' will look inside this file when search for its name.
// that features like 'find refs' will look inside this file when search for its name.
if (result.kind === SyntaxKind.StringLiteral) {
internIdentifier((<LiteralExpression>result).text);
}
@@ -4867,12 +4877,17 @@ 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.exportName = parseIdentifier();
node.expression = parseAssignmentExpressionOrHigher();
parseSemicolon();
return finishNode(node);
}
+41 -26
View File
@@ -2,8 +2,10 @@
/// <reference path="emitter.ts" />
module ts {
/* @internal */ export let programTime = 0;
/* @internal */ export let emitTime = 0;
/* @internal */ export let ioReadTime = 0;
/* @internal */ export let ioWriteTime = 0;
/** The version of the TypeScript compiler release */
export let version = "1.5.0.0";
@@ -36,33 +38,34 @@ module ts {
}
text = "";
}
return text !== undefined ? createSourceFile(fileName, text, languageVersion) : undefined;
}
function directoryExists(directoryPath: string): boolean {
if (hasProperty(existingDirectories, directoryPath)) {
return true;
}
if (sys.directoryExists(directoryPath)) {
existingDirectories[directoryPath] = true;
return true;
}
return false;
}
function ensureDirectoriesExist(directoryPath: string) {
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
let parentDirectory = getDirectoryPath(directoryPath);
ensureDirectoriesExist(parentDirectory);
sys.createDirectory(directoryPath);
}
}
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {
function directoryExists(directoryPath: string): boolean {
if (hasProperty(existingDirectories, directoryPath)) {
return true;
}
if (sys.directoryExists(directoryPath)) {
existingDirectories[directoryPath] = true;
return true;
}
return false;
}
function ensureDirectoriesExist(directoryPath: string) {
if (directoryPath.length > getRootLength(directoryPath) && !directoryExists(directoryPath)) {
let parentDirectory = getDirectoryPath(directoryPath);
ensureDirectoriesExist(parentDirectory);
sys.createDirectory(directoryPath);
}
}
try {
var start = new Date().getTime();
ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName)));
sys.writeFile(fileName, data, writeByteOrderMark);
ioWriteTime += new Date().getTime() - start;
}
catch (e) {
if (onError) {
@@ -120,16 +123,19 @@ module ts {
let diagnostics = createDiagnosticCollection();
let seenNoDefaultLib = options.noLib;
let commonSourceDirectory: string;
host = host || createCompilerHost(options);
let diagnosticsProducingTypeChecker: TypeChecker;
let noDiagnosticsTypeChecker: TypeChecker;
let start = new Date().getTime();
host = host || createCompilerHost(options);
forEach(rootNames, name => processRootFile(name, false));
if (!seenNoDefaultLib) {
processRootFile(host.getDefaultLibFileName(options), true);
}
verifyCompilerOptions();
let diagnosticsProducingTypeChecker: TypeChecker;
let noDiagnosticsTypeChecker: TypeChecker;
programTime += new Date().getTime() - start;
program = {
getSourceFile: getSourceFile,
@@ -430,11 +436,20 @@ module ts {
return;
}
let languageVersion = options.target || ScriptTarget.ES3;
let firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
if (firstExternalModuleSourceFile && !options.module) {
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided));
if (!options.module && languageVersion < ScriptTarget.ES6) {
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
let span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided));
}
}
// Cannot specify module gen target when in es6 or above
if (options.module && languageVersion >= ScriptTarget.ES6) {
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher));
}
// there has to be common source directory if user specified --outdir || --sourcRoot
+15 -24
View File
@@ -320,22 +320,16 @@ module ts {
}
function compile(fileNames: string[], compilerOptions: CompilerOptions, compilerHost: CompilerHost) {
ts.ioReadTime = 0;
ts.parseTime = 0;
ts.bindTime = 0;
ts.checkTime = 0;
ts.emitTime = 0;
var start = new Date().getTime();
ioReadTime = 0;
ioWriteTime = 0;
programTime = 0;
bindTime = 0;
checkTime = 0;
emitTime = 0;
var program = createProgram(fileNames, compilerOptions, compilerHost);
var programTime = new Date().getTime() - start;
var exitStatus = compileProgram();
var end = new Date().getTime() - start;
var compileTime = end - programTime;
if (compilerOptions.listFiles) {
forEach(program.getSourceFiles(), file => {
sys.write(file.fileName + sys.newLine);
@@ -356,19 +350,16 @@ module ts {
}
// Individual component times.
// Note: we output 'programTime' as parseTime to match the tsc 1.3 behavior. tsc 1.3
// measured parse time along with read IO as a single counter. We preserve that
// behavior so we can accurately compare times. For actual parse times (in isolation)
// is reported below.
// Note: To match the behavior of previous versions of the compiler, the reported parse time includes
// I/O read time and processing time for triple-slash references and module imports, and the reported
// emit time includes I/O write time. We preserve this behavior so we can accurately compare times.
reportTimeStatistic("I/O read", ioReadTime);
reportTimeStatistic("I/O write", ioWriteTime);
reportTimeStatistic("Parse time", programTime);
reportTimeStatistic("Bind time", ts.bindTime);
reportTimeStatistic("Check time", ts.checkTime);
reportTimeStatistic("Emit time", ts.emitTime);
reportTimeStatistic("Parse time w/o IO", ts.parseTime);
reportTimeStatistic("IO read", ts.ioReadTime);
reportTimeStatistic("Compile time", compileTime);
reportTimeStatistic("Total time", end);
reportTimeStatistic("Bind time", bindTime);
reportTimeStatistic("Check time", checkTime);
reportTimeStatistic("Emit time", emitTime);
reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
}
return { program, exitStatus };
+6 -1
View File
@@ -944,7 +944,8 @@ module ts {
export interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression: Expression;
expression?: Expression;
type?: TypeNode;
}
export interface FileReference extends TextRange {
@@ -1486,11 +1487,15 @@ module ts {
(t: Type): Type;
}
// @internal
export interface TypeInferences {
primary: Type[]; // Inferences made directly to a type parameter
secondary: Type[]; // Inferences made to a type parameter in a union type
isFixed: boolean; // Whether the type parameter is fixed, as defined in section 4.12.2 of the TypeScript spec
// If a type parameter is fixed, no more inferences can be made for the type parameter
}
// @internal
export interface InferenceContext {
typeParameters: TypeParameter[]; // Type parameters for which inferences are made
inferUnionTypes: boolean; // Infer union types for disjoint candidates (otherwise undefinedType)
+5 -3
View File
@@ -1621,8 +1621,9 @@ module FourSlash {
this.taoInvalidReason = 'verifyIndentationAtCurrentPosition NYI';
var actual = this.getIndentation(this.activeFile.fileName, this.currentCaretPosition);
if (actual != numberOfSpaces) {
this.raiseError('verifyIndentationAtCurrentPosition failed - expected: ' + numberOfSpaces + ', actual: ' + actual);
var lineCol = this.getLineColStringAtPosition(this.currentCaretPosition);
if (actual !== numberOfSpaces) {
this.raiseError('verifyIndentationAtCurrentPosition failed at ' + lineCol + ' - expected: ' + numberOfSpaces + ', actual: ' + actual);
}
}
@@ -1630,8 +1631,9 @@ module FourSlash {
this.taoInvalidReason = 'verifyIndentationAtPosition NYI';
var actual = this.getIndentation(fileName, position);
var lineCol = this.getLineColStringAtPosition(position);
if (actual !== numberOfSpaces) {
this.raiseError('verifyIndentationAtPosition failed - expected: ' + numberOfSpaces + ', actual: ' + actual);
this.raiseError('verifyIndentationAtPosition failed at ' + lineCol + ' - expected: ' + numberOfSpaces + ', actual: ' + actual);
}
}
+59 -20
View File
@@ -19,15 +19,19 @@ module ts.server {
class ScriptInfo {
svc: ScriptVersionCache;
children: ScriptInfo[] = []; // files referenced by this file
defaultProject: Project; // project to use by default for file
fileWatcher: FileWatcher;
formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions);
constructor(private host: ServerHost, public fileName: string, public content: string, public isOpen = false) {
this.svc = ScriptVersionCache.fromString(content);
}
setFormatOptions(tabSize: number, indentSize: number) {
this.formatCodeOptions.TabSize = tabSize;
this.formatCodeOptions.IndentSize = indentSize;
}
close() {
this.isOpen = false;
}
@@ -153,15 +157,18 @@ module ts.server {
}
}
reloadScript(filename: string, tmpfilename: string, tabSize: number, cb: () => any) {
reloadScript(filename: string, tmpfilename: string, cb: () => any) {
var script = this.getScriptInfo(filename);
if (script) {
script.svc.reloadFromFile(tmpfilename, tabSize, cb);
script.svc.reloadFromFile(tmpfilename, script.formatCodeOptions.TabSize, cb);
}
}
editScript(filename: string, start: number, end: number, newText: string) {
var script = this.getScriptInfo(filename);
if (newText && (newText.length > 0)) {
newText = expandTabs(newText, script.formatCodeOptions.TabSize);
}
if (script) {
script.editContent(start, end, newText);
return;
@@ -365,6 +372,12 @@ module ts.server {
hostInfo: string;
}
export function expandTabs(text: string, tabSize: number) {
var spaces = generateSpaces(tabSize);
return text.replace(/\t/g, spaces);
}
export class ProjectService {
filenameToScriptInfo: ts.Map<ScriptInfo> = {};
// open, non-configured files in two lists
@@ -386,7 +399,13 @@ module ts.server {
}
}
getFormatCodeOptions() {
getFormatCodeOptions(file?: string) {
if (file) {
var info = this.filenameToScriptInfo[file];
if (info) {
return info.formatCodeOptions;
}
}
return this.hostConfiguration.formatCodeOptions;
}
@@ -402,7 +421,7 @@ module ts.server {
}
else {
if (info && (!info.isOpen)) {
info.svc.reloadFromFile(info.fileName, this.hostConfiguration.formatCodeOptions.TabSize);
info.svc.reloadFromFile(info.fileName, info.formatCodeOptions.TabSize);
}
}
}
@@ -412,15 +431,19 @@ module ts.server {
}
setHostConfiguration(args: ts.server.protocol.ConfigureRequestArguments) {
this.hostConfiguration.formatCodeOptions.TabSize = args.tabSize;
this.hostConfiguration.formatCodeOptions.IndentSize = args.indentSize;
this.hostConfiguration.hostInfo = args.hostInfo;
this.log("Host information " + args.hostInfo, "Info");
}
expandTabs(text: string) {
var spaces = generateSpaces(this.hostConfiguration.formatCodeOptions.TabSize);
return text.replace(/\t/g, spaces);
if (args.file) {
var info = this.filenameToScriptInfo[args.file];
if (info) {
info.setFormatOptions(args.tabSize, args.indentSize);
this.log("Host configuration update for file " + args.file + " tab size " + args.tabSize);
}
}
else {
this.hostConfiguration.formatCodeOptions.TabSize = args.tabSize;
this.hostConfiguration.formatCodeOptions.IndentSize = args.indentSize;
this.hostConfiguration.hostInfo = args.hostInfo;
this.log("Host information " + args.hostInfo, "Info");
}
}
closeLog() {
@@ -623,7 +646,7 @@ module ts.server {
/**
* @param filename is absolute pathname
*/
openFile(fileName: string, openedByClient = false) {
openFile(fileName: string, openedByClient: boolean, tabSize?: number) {
fileName = ts.normalizePath(fileName);
var info = ts.lookUp(this.filenameToScriptInfo, fileName);
if (!info) {
@@ -637,12 +660,26 @@ module ts.server {
}
}
if (content !== undefined) {
content = this.expandTabs(content);
var indentSize: number;
if (!tabSize) {
tabSize = this.hostConfiguration.formatCodeOptions.TabSize;
indentSize = this.hostConfiguration.formatCodeOptions.IndentSize;
}
else {
indentSize = tabSize;
}
if (openedByClient) {
this.log("Expanding tabs for file " + fileName + " with tab size " + tabSize.toString());
content = expandTabs(content, tabSize);
}
info = new ScriptInfo(this.host, fileName, content, openedByClient);
this.filenameToScriptInfo[fileName] = info;
if (!info.isOpen) {
info.fileWatcher = this.host.watchFile(fileName, _ => { this.watchedFileChanged(fileName); });
}
else {
info.setFormatOptions(tabSize, indentSize);
}
}
}
if (info) {
@@ -658,9 +695,9 @@ module ts.server {
* @param filename is absolute pathname
*/
openClientFile(filename: string) {
openClientFile(filename: string, tabSize?: number) {
// TODO: tsconfig check
var info = this.openFile(filename, true);
var info = this.openFile(filename, true, tabSize);
this.addOpenFile(info);
this.printProjects();
return info;
@@ -760,7 +797,8 @@ module ts.server {
var normRootFilename = ts.normalizePath(rootFilename);
normRootFilename = getAbsolutePath(normRootFilename, dirPath);
if (this.host.fileExists(normRootFilename)) {
var info = this.openFile(normRootFilename);
// TODO: pass true for file exiplicitly opened
var info = this.openFile(normRootFilename, false);
proj.addRoot(info);
}
else {
@@ -1123,6 +1161,7 @@ module ts.server {
reloadFromFile(filename: string, tabSize: number, cb?: () => any) {
var content = ts.sys.readFile(filename);
content = expandTabs(content, tabSize);
this.reload(content);
if (cb)
cb();
+14 -1
View File
@@ -312,6 +312,10 @@ declare module ts.server.protocol {
* 'Sublime Text version 3075'
*/
hostInfo: string;
/**
* If present, tab settings apply only to this file.
*/
file?: string;
}
/**
@@ -329,6 +333,14 @@ declare module ts.server.protocol {
export interface ConfigureResponse extends Response {
}
/**
* Information found in an "open" request.
*/
export interface OpenRequestArgs extends FileRequestArgs {
/** Initial tab size of file. */
tabSize?: number;
}
/**
* Open request; value of command field is "open". Notify the
* server that the client has file open. The server will not
@@ -337,7 +349,8 @@ declare module ts.server.protocol {
* reload messages) when the file changes. Server does not currently
* send a response to an open request.
*/
export interface OpenRequest extends FileRequest {
export interface OpenRequest extends Request {
arguments: OpenRequestArgs;
}
/**
+8 -9
View File
@@ -5,7 +5,7 @@
/// <reference path="editorServices.ts" />
module ts.server {
var spaceCache = [" ", " ", " ", " "];
var spaceCache:string[] = [];
interface StackTraceError extends Error {
stack?: string;
@@ -397,9 +397,9 @@ module ts.server {
};
}
openClientFile(fileName: string) {
openClientFile(fileName: string, tabSize?: number) {
var file = ts.normalizePath(fileName);
this.projectService.openClientFile(file);
this.projectService.openClientFile(file, tabSize);
}
getQuickInfo(line: number, col: number, fileName: string): protocol.QuickInfoResponseBody {
@@ -441,7 +441,7 @@ module ts.server {
// TODO: avoid duplicate code (with formatonkey)
var edits = compilerService.languageService.getFormattingEditsForRange(file, startPosition, endPosition,
this.projectService.getFormatCodeOptions());
this.projectService.getFormatCodeOptions(file));
if (!edits) {
return undefined;
}
@@ -465,7 +465,7 @@ module ts.server {
var compilerService = project.compilerService;
var position = compilerService.host.lineColToPosition(file, line, col);
var formatOptions = this.projectService.getFormatCodeOptions();
var formatOptions = this.projectService.getFormatCodeOptions(file);
var edits = compilerService.languageService.getFormattingEditsAfterKeystroke(file, position, key,
formatOptions);
// Check whether we should auto-indent. This will be when
@@ -611,8 +611,7 @@ module ts.server {
if (project) {
this.changeSeq++;
// make sure no changes happen before this one is finished
project.compilerService.host.reloadScript(file, tmpfile,
this.projectService.getFormatCodeOptions().TabSize, () => {
project.compilerService.host.reloadScript(file, tmpfile, () => {
this.output(undefined, CommandNames.Reload, reqSeq);
});
}
@@ -756,8 +755,8 @@ module ts.server {
break;
}
case CommandNames.Open: {
var openArgs = <protocol.FileRequestArgs>request.arguments;
this.openClientFile(openArgs.file);
var openArgs = <protocol.OpenRequestArgs>request.arguments;
this.openClientFile(openArgs.file,openArgs.tabSize);
responseRequired = false;
break;
}
+4
View File
@@ -173,6 +173,10 @@ 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);
+12 -2
View File
@@ -1008,10 +1008,20 @@ module ts.formatting {
return SyntaxKind.Unknown;
}
let internedTabsIndentation: string[];
let internedSpacesIndentation: string[];
var internedSizes: { tabSize: number; indentSize: number };
var internedTabsIndentation: string[];
var internedSpacesIndentation: string[];
export function getIndentationString(indentation: number, options: FormatCodeOptions): string {
// reset interned strings if FormatCodeOptions were changed
let resetInternedStrings =
!internedSizes || (internedSizes.tabSize !== options.TabSize || internedSizes.indentSize !== options.IndentSize);
if (resetInternedStrings) {
internedSizes = { tabSize: options.TabSize, indentSize: options.IndentSize };
internedTabsIndentation = internedSpacesIndentation = undefined;
}
if (!options.ConvertTabsToSpaces) {
let tabs = Math.floor(indentation / options.TabSize);
let spaces = indentation - tabs * options.TabSize;
-54
View File
@@ -1,54 +0,0 @@
module ts.formatting {
var internedTabsIndentation: string[];
var internedSpacesIndentation: string[];
export function getIndentationString(indentation: number, options: FormatCodeOptions): string {
if (!options.ConvertTabsToSpaces) {
var tabs = Math.floor(indentation / options.TabSize);
var spaces = indentation - tabs * options.TabSize;
var tabString: string;
if (!internedTabsIndentation) {
internedTabsIndentation = [];
}
if (internedTabsIndentation[tabs] === undefined) {
internedTabsIndentation[tabs] = tabString = repeat('\t', tabs);
}
else {
tabString = internedTabsIndentation[tabs];
}
return spaces ? tabString + repeat(" ", spaces) : tabString;
}
else {
var spacesString: string;
var quotient = Math.floor(indentation / options.IndentSize);
var remainder = indentation % options.IndentSize;
if (!internedSpacesIndentation) {
internedSpacesIndentation = [];
}
if (internedSpacesIndentation[quotient] === undefined) {
spacesString = repeat(" ", options.IndentSize * quotient);
internedSpacesIndentation[quotient] = spacesString;
}
else {
spacesString = internedSpacesIndentation[quotient];
}
return remainder ? spacesString + repeat(" ", remainder) : spacesString;
}
function repeat(value: string, count: number): string {
var s = "";
for (var i = 0; i < count; ++i) {
s += value;
}
return s;
}
}
}
+53 -9
View File
@@ -359,6 +359,7 @@ module ts.formatting {
case SyntaxKind.ModuleBlock:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.TypeLiteral:
case SyntaxKind.TupleType:
case SyntaxKind.CaseBlock:
case SyntaxKind.DefaultClause:
case SyntaxKind.CaseClause:
@@ -370,6 +371,8 @@ module ts.formatting {
case SyntaxKind.ExportAssignment:
case SyntaxKind.ReturnStatement:
case SyntaxKind.ConditionalExpression:
case SyntaxKind.ArrayBindingPattern:
case SyntaxKind.ObjectBindingPattern:
return true;
}
return false;
@@ -390,6 +393,7 @@ module ts.formatting {
case SyntaxKind.FunctionExpression:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.ArrowFunction:
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
@@ -431,46 +435,85 @@ module ts.formatting {
case SyntaxKind.InterfaceDeclaration:
case SyntaxKind.EnumDeclaration:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.ObjectBindingPattern:
case SyntaxKind.TypeLiteral:
case SyntaxKind.Block:
case SyntaxKind.ModuleBlock:
case SyntaxKind.CaseBlock:
return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile);
case SyntaxKind.CatchClause:
return isCompletedNode((<CatchClause>n).block, sourceFile);
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.CallSignature:
case SyntaxKind.NewExpression:
if (!(<NewExpression>n).arguments) {
return true;
}
// fall through
case SyntaxKind.CallExpression:
case SyntaxKind.ConstructSignature:
case SyntaxKind.ParenthesizedExpression:
case SyntaxKind.ParenthesizedType:
return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile);
case SyntaxKind.FunctionType:
case SyntaxKind.ConstructorType:
return isCompletedNode((<SignatureDeclaration>n).type, sourceFile);
case SyntaxKind.Constructor:
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
case SyntaxKind.FunctionDeclaration:
case SyntaxKind.FunctionExpression:
case SyntaxKind.MethodDeclaration:
case SyntaxKind.MethodSignature:
case SyntaxKind.ConstructSignature:
case SyntaxKind.CallSignature:
case SyntaxKind.ArrowFunction:
return !(<FunctionLikeDeclaration>n).body || isCompletedNode((<FunctionLikeDeclaration>n).body, sourceFile);
if ((<FunctionLikeDeclaration>n).body) {
return isCompletedNode((<FunctionLikeDeclaration>n).body, sourceFile);
}
if ((<FunctionLikeDeclaration>n).type) {
return isCompletedNode((<FunctionLikeDeclaration>n).type, sourceFile);
}
// Even though type parameters can be unclosed, we can get away with
// having at least a closing paren.
return hasChildOfKind(n, SyntaxKind.CloseParenToken, sourceFile);
case SyntaxKind.ModuleDeclaration:
return (<ModuleDeclaration>n).body && isCompletedNode((<ModuleDeclaration>n).body, sourceFile);
case SyntaxKind.IfStatement:
if ((<IfStatement>n).elseStatement) {
return isCompletedNode((<IfStatement>n).elseStatement, sourceFile);
}
return isCompletedNode((<IfStatement>n).thenStatement, sourceFile);
case SyntaxKind.ExpressionStatement:
return isCompletedNode((<ExpressionStatement>n).expression, sourceFile);
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.ArrayBindingPattern:
case SyntaxKind.ComputedPropertyName:
case SyntaxKind.TupleType:
return nodeEndsWith(n, SyntaxKind.CloseBracketToken, sourceFile);
case SyntaxKind.IndexSignature:
if ((<IndexSignatureDeclaration>n).type) {
return isCompletedNode((<IndexSignatureDeclaration>n).type, sourceFile);
}
return hasChildOfKind(n, SyntaxKind.CloseBracketToken, sourceFile);
case SyntaxKind.CaseClause:
case SyntaxKind.DefaultClause:
// there is no such thing as terminator token for CaseClause\DefaultClause so for simplicitly always consider them non-completed
// there is no such thing as terminator token for CaseClause/DefaultClause so for simplicitly always consider them non-completed
return false;
case SyntaxKind.ForStatement:
return isCompletedNode((<ForStatement>n).statement, sourceFile);
case SyntaxKind.ForInStatement:
return isCompletedNode((<ForInStatement>n).statement, sourceFile);
case SyntaxKind.ForOfStatement:
return isCompletedNode((<ForOfStatement>n).statement, sourceFile);
case SyntaxKind.WhileStatement:
return isCompletedNode((<WhileStatement>n).statement, sourceFile);
return isCompletedNode((<IterationStatement>n).statement, sourceFile);
case SyntaxKind.DoStatement:
// rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')';
let hasWhileKeyword = findChildOfKind(n, SyntaxKind.WhileKeyword, sourceFile);
@@ -478,6 +521,7 @@ module ts.formatting {
return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile);
}
return isCompletedNode((<DoStatement>n).statement, sourceFile);
default:
return true;
}
+2
View File
@@ -833,3 +833,5 @@ module ts {
module TypeScript.Services {
export var TypeScriptServicesFactory = ts.TypeScriptServicesFactory;
}
let toolsVersion = "1.4";
+4
View File
@@ -79,6 +79,10 @@ module ts {
};
}
export function hasChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): boolean {
return !!findChildOfKind(n, kind, sourceFile);
}
export function findChildOfKind(n: Node, kind: SyntaxKind, sourceFile?: SourceFile): Node {
return forEach(n.getChildren(sourceFile), c => c.kind === kind && c);
}
+2 -12
View File
@@ -765,7 +765,8 @@ declare module "typescript" {
type ExportSpecifier = ImportOrExportSpecifier;
interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression: Expression;
expression?: Expression;
type?: TypeNode;
}
interface FileReference extends TextRange {
fileName: string;
@@ -1175,17 +1176,6 @@ declare module "typescript" {
interface TypeMapper {
(t: Type): Type;
}
interface TypeInferences {
primary: Type[];
secondary: Type[];
}
interface InferenceContext {
typeParameters: TypeParameter[];
inferUnionTypes: boolean;
inferences: TypeInferences[];
inferredTypes: Type[];
failedTypeParameterIndex?: number;
}
interface DiagnosticMessage {
key: string;
category: DiagnosticCategory;
@@ -2333,9 +2333,13 @@ declare module "typescript" {
isExportEquals?: boolean;
>isExportEquals : boolean
expression: Expression;
expression?: Expression;
>expression : Expression
>Expression : Expression
type?: TypeNode;
>type : TypeNode
>TypeNode : TypeNode
}
interface FileReference extends TextRange {
>FileReference : FileReference
@@ -3765,38 +3769,6 @@ declare module "typescript" {
>t : Type
>Type : Type
>Type : Type
}
interface TypeInferences {
>TypeInferences : TypeInferences
primary: Type[];
>primary : Type[]
>Type : Type
secondary: Type[];
>secondary : Type[]
>Type : Type
}
interface InferenceContext {
>InferenceContext : InferenceContext
typeParameters: TypeParameter[];
>typeParameters : TypeParameter[]
>TypeParameter : TypeParameter
inferUnionTypes: boolean;
>inferUnionTypes : boolean
inferences: TypeInferences[];
>inferences : TypeInferences[]
>TypeInferences : TypeInferences
inferredTypes: Type[];
>inferredTypes : Type[]
>Type : Type
failedTypeParameterIndex?: number;
>failedTypeParameterIndex : number
}
interface DiagnosticMessage {
>DiagnosticMessage : DiagnosticMessage
+2 -12
View File
@@ -796,7 +796,8 @@ declare module "typescript" {
type ExportSpecifier = ImportOrExportSpecifier;
interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression: Expression;
expression?: Expression;
type?: TypeNode;
}
interface FileReference extends TextRange {
fileName: string;
@@ -1206,17 +1207,6 @@ declare module "typescript" {
interface TypeMapper {
(t: Type): Type;
}
interface TypeInferences {
primary: Type[];
secondary: Type[];
}
interface InferenceContext {
typeParameters: TypeParameter[];
inferUnionTypes: boolean;
inferences: TypeInferences[];
inferredTypes: Type[];
failedTypeParameterIndex?: number;
}
interface DiagnosticMessage {
key: string;
category: DiagnosticCategory;
@@ -2479,9 +2479,13 @@ declare module "typescript" {
isExportEquals?: boolean;
>isExportEquals : boolean
expression: Expression;
expression?: Expression;
>expression : Expression
>Expression : Expression
type?: TypeNode;
>type : TypeNode
>TypeNode : TypeNode
}
interface FileReference extends TextRange {
>FileReference : FileReference
@@ -3911,38 +3915,6 @@ declare module "typescript" {
>t : Type
>Type : Type
>Type : Type
}
interface TypeInferences {
>TypeInferences : TypeInferences
primary: Type[];
>primary : Type[]
>Type : Type
secondary: Type[];
>secondary : Type[]
>Type : Type
}
interface InferenceContext {
>InferenceContext : InferenceContext
typeParameters: TypeParameter[];
>typeParameters : TypeParameter[]
>TypeParameter : TypeParameter
inferUnionTypes: boolean;
>inferUnionTypes : boolean
inferences: TypeInferences[];
>inferences : TypeInferences[]
>TypeInferences : TypeInferences
inferredTypes: Type[];
>inferredTypes : Type[]
>Type : Type
failedTypeParameterIndex?: number;
>failedTypeParameterIndex : number
}
interface DiagnosticMessage {
>DiagnosticMessage : DiagnosticMessage
@@ -797,7 +797,8 @@ declare module "typescript" {
type ExportSpecifier = ImportOrExportSpecifier;
interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression: Expression;
expression?: Expression;
type?: TypeNode;
}
interface FileReference extends TextRange {
fileName: string;
@@ -1207,17 +1208,6 @@ declare module "typescript" {
interface TypeMapper {
(t: Type): Type;
}
interface TypeInferences {
primary: Type[];
secondary: Type[];
}
interface InferenceContext {
typeParameters: TypeParameter[];
inferUnionTypes: boolean;
inferences: TypeInferences[];
inferredTypes: Type[];
failedTypeParameterIndex?: number;
}
interface DiagnosticMessage {
key: string;
category: DiagnosticCategory;
@@ -2429,9 +2429,13 @@ declare module "typescript" {
isExportEquals?: boolean;
>isExportEquals : boolean
expression: Expression;
expression?: Expression;
>expression : Expression
>Expression : Expression
type?: TypeNode;
>type : TypeNode
>TypeNode : TypeNode
}
interface FileReference extends TextRange {
>FileReference : FileReference
@@ -3861,38 +3865,6 @@ declare module "typescript" {
>t : Type
>Type : Type
>Type : Type
}
interface TypeInferences {
>TypeInferences : TypeInferences
primary: Type[];
>primary : Type[]
>Type : Type
secondary: Type[];
>secondary : Type[]
>Type : Type
}
interface InferenceContext {
>InferenceContext : InferenceContext
typeParameters: TypeParameter[];
>typeParameters : TypeParameter[]
>TypeParameter : TypeParameter
inferUnionTypes: boolean;
>inferUnionTypes : boolean
inferences: TypeInferences[];
>inferences : TypeInferences[]
>TypeInferences : TypeInferences
inferredTypes: Type[];
>inferredTypes : Type[]
>Type : Type
failedTypeParameterIndex?: number;
>failedTypeParameterIndex : number
}
interface DiagnosticMessage {
>DiagnosticMessage : DiagnosticMessage
+2 -12
View File
@@ -834,7 +834,8 @@ declare module "typescript" {
type ExportSpecifier = ImportOrExportSpecifier;
interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression: Expression;
expression?: Expression;
type?: TypeNode;
}
interface FileReference extends TextRange {
fileName: string;
@@ -1244,17 +1245,6 @@ declare module "typescript" {
interface TypeMapper {
(t: Type): Type;
}
interface TypeInferences {
primary: Type[];
secondary: Type[];
}
interface InferenceContext {
typeParameters: TypeParameter[];
inferUnionTypes: boolean;
inferences: TypeInferences[];
inferredTypes: Type[];
failedTypeParameterIndex?: number;
}
interface DiagnosticMessage {
key: string;
category: DiagnosticCategory;
@@ -2602,9 +2602,13 @@ declare module "typescript" {
isExportEquals?: boolean;
>isExportEquals : boolean
expression: Expression;
expression?: Expression;
>expression : Expression
>Expression : Expression
type?: TypeNode;
>type : TypeNode
>TypeNode : TypeNode
}
interface FileReference extends TextRange {
>FileReference : FileReference
@@ -4034,38 +4038,6 @@ declare module "typescript" {
>t : Type
>Type : Type
>Type : Type
}
interface TypeInferences {
>TypeInferences : TypeInferences
primary: Type[];
>primary : Type[]
>Type : Type
secondary: Type[];
>secondary : Type[]
>Type : Type
}
interface InferenceContext {
>InferenceContext : InferenceContext
typeParameters: TypeParameter[];
>typeParameters : TypeParameter[]
>TypeParameter : TypeParameter
inferUnionTypes: boolean;
>inferUnionTypes : boolean
inferences: TypeInferences[];
>inferences : TypeInferences[]
>TypeInferences : TypeInferences
inferredTypes: Type[];
>inferredTypes : Type[]
>Type : Type
failedTypeParameterIndex?: number;
>failedTypeParameterIndex : number
}
interface DiagnosticMessage {
>DiagnosticMessage : DiagnosticMessage
+14 -23
View File
@@ -55,12 +55,6 @@ var c = new C(1, 2, ...a);
//// [callWithSpreadES6.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
function foo(x, y, ...z) {
}
var a;
@@ -84,26 +78,23 @@ xa[1].foo(...[
2,
"abc"
]);
var C = (function () {
function C(x, y, ...z) {
class C {
constructor(x, y, ...z) {
this.foo(x, y);
this.foo(x, y, ...z);
}
C.prototype.foo = function (x, y, ...z) {
};
return C;
})();
var D = (function (_super) {
__extends(D, _super);
function D() {
_super.call(this, 1, 2);
_super.call(this, 1, 2, ...a);
foo(x, y, ...z) {
}
D.prototype.foo = function () {
_super.prototype.foo.call(this, 1, 2);
_super.prototype.foo.call(this, 1, 2, ...a);
};
return D;
})(C);
}
class D extends C {
constructor() {
super(1, 2);
super(1, 2, ...a);
}
foo() {
super.foo(1, 2);
super.foo(1, 2, ...a);
}
}
// Only supported in when target is ES6
var c = new C(1, 2, ...a);
@@ -20,12 +20,11 @@ class C {
var s;
var n;
var a;
var C = (function () {
function C() {
class C {
constructor() {
this[n] = n;
this[s + n] = 2;
this[`hello bye`] = 0;
}
C[`hello ${a} bye`] = 0;
return C;
})();
}
C[`hello ${a} bye`] = 0;
@@ -20,30 +20,27 @@ class C {
var s;
var n;
var a;
var C = (function () {
function C() {
class C {
[s]() {
}
C.prototype[s] = function () {
};
C.prototype[n] = function () {
};
C[s + s] = function () {
};
C.prototype[s + n] = function () {
};
C.prototype[+s] = function () {
};
C[""] = function () {
};
C.prototype[0] = function () {
};
C.prototype[a] = function () {
};
C[true] = function () {
};
C.prototype[`hello bye`] = function () {
};
C[`hello ${a} bye`] = function () {
};
return C;
})();
[n]() {
}
static [s + s]() {
}
[s + n]() {
}
[+s]() {
}
static [""]() {
}
[0]() {
}
[a]() {
}
static [true]() {
}
[`hello bye`]() {
}
static [`hello ${a} bye`]() {
}
}
@@ -11,20 +11,17 @@ class C {
//// [computedPropertyNames14_ES6.js]
var b;
var C = (function () {
function C() {
class C {
[b]() {
}
C.prototype[b] = function () {
};
C[true] = function () {
};
C.prototype[[]] = function () {
};
C[{}] = function () {
};
C.prototype[undefined] = function () {
};
C[null] = function () {
};
return C;
})();
static [true]() {
}
[[]]() {
}
static [{}]() {
}
[undefined]() {
}
static [null]() {
}
}
@@ -12,14 +12,11 @@ class C {
var p1;
var p2;
var p3;
var C = (function () {
function C() {
class C {
[p1]() {
}
C.prototype[p1] = function () {
};
C.prototype[p2] = function () {
};
C.prototype[p3] = function () {
};
return C;
})();
[p2]() {
}
[p3]() {
}
}
@@ -20,80 +20,33 @@ class C {
var s;
var n;
var a;
var C = (function () {
function C() {
class C {
get [s]() {
return 0;
}
Object.defineProperty(C.prototype, s, {
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, n, {
set: function (v) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, s + s, {
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, s + n, {
set: function (v) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, +s, {
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, "", {
set: function (v) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, 0, {
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, a, {
set: function (v) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, true, {
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, `hello bye`, {
set: function (v) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, `hello ${a} bye`, {
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
return C;
})();
set [n](v) {
}
static get [s + s]() {
return 0;
}
set [s + n](v) {
}
get [+s]() {
return 0;
}
static set [""](v) {
}
get [0]() {
return 0;
}
set [a](v) {
}
static get [true]() {
return 0;
}
set [`hello bye`](v) {
}
get [`hello ${a} bye`]() {
return 0;
}
}
@@ -11,47 +11,20 @@ class C {
//// [computedPropertyNames17_ES6.js]
var b;
var C = (function () {
function C() {
class C {
get [b]() {
return 0;
}
Object.defineProperty(C.prototype, b, {
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, true, {
set: function (v) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, [], {
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, {}, {
set: function (v) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, undefined, {
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, null, {
set: function (v) {
},
enumerable: true,
configurable: true
});
return C;
})();
static set [true](v) {
}
get [[]]() {
return 0;
}
set [{}](v) {
}
static get [undefined]() {
return 0;
}
set [null](v) {
}
}
@@ -7,13 +7,10 @@ class C {
}
//// [computedPropertyNames21_ES6.js]
var C = (function () {
function C() {
}
C.prototype.bar = function () {
class C {
bar() {
return 0;
};
C.prototype[this.bar()] = function () {
};
return C;
})();
}
[this.bar()]() {
}
}
@@ -9,15 +9,12 @@ class C {
}
//// [computedPropertyNames22_ES6.js]
var C = (function () {
function C() {
}
C.prototype.bar = function () {
class C {
bar() {
var obj = {
[this.bar()]() {
}
};
return 0;
};
return C;
})();
}
}
@@ -9,15 +9,12 @@ class C {
}
//// [computedPropertyNames23_ES6.js]
var C = (function () {
function C() {
}
C.prototype.bar = function () {
class C {
bar() {
return 0;
};
C.prototype[{
}
[{
[this.bar()]: 1
}[0]] = function () {
};
return C;
})();
}[0]]() {
}
}
@@ -1,4 +1,4 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts(9,6): error TS2466: 'super' cannot be referenced in a computed property name.
tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts(7,6): error TS2466: 'super' cannot be referenced in a computed property name.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts (1 errors) ====
@@ -8,8 +8,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts(9,
}
}
class C extends Base {
// Gets emitted as super, not _super, which is consistent with
// use of super in static properties initializers.
[super.bar()]() { }
~~~~~
!!! error TS2466: 'super' cannot be referenced in a computed property name.
@@ -5,8 +5,6 @@ class Base {
}
}
class C extends Base {
// Gets emitted as super, not _super, which is consistent with
// use of super in static properties initializers.
[super.bar()]() { }
}
@@ -30,9 +28,7 @@ var C = (function (_super) {
function C() {
_super.apply(this, arguments);
}
// Gets emitted as super, not _super, which is consistent with
// use of super in static properties initializers.
C.prototype[super.bar.call(this)] = function () {
C.prototype[_super.bar.call(this)] = function () {
};
return C;
})(Base);
@@ -11,28 +11,14 @@ class C extends Base {
}
//// [computedPropertyNames24_ES6.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Base = (function () {
function Base() {
}
Base.prototype.bar = function () {
class Base {
bar() {
return 0;
};
return Base;
})();
var C = (function (_super) {
__extends(C, _super);
function C() {
_super.apply(this, arguments);
}
}
class C extends Base {
// Gets emitted as super, not _super, which is consistent with
// use of super in static properties initializers.
C.prototype[super.bar.call(this)] = function () {
};
return C;
})(Base);
[super.bar()]() {
}
}
@@ -14,31 +14,17 @@ class C extends Base {
}
//// [computedPropertyNames25_ES6.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Base = (function () {
function Base() {
}
Base.prototype.bar = function () {
class Base {
bar() {
return 0;
};
return Base;
})();
var C = (function (_super) {
__extends(C, _super);
function C() {
_super.apply(this, arguments);
}
C.prototype.foo = function () {
}
class C extends Base {
foo() {
var obj = {
[_super.prototype.bar.call(this)]() {
[super.bar()]() {
}
};
return 0;
};
return C;
})(Base);
}
}
@@ -1,4 +1,4 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts(10,12): error TS2466: 'super' cannot be referenced in a computed property name.
tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts(8,12): error TS2466: 'super' cannot be referenced in a computed property name.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts (1 errors) ====
@@ -8,8 +8,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts(10
}
}
class C extends Base {
// Gets emitted as super, not _super, which is consistent with
// use of super in static properties initializers.
[
{ [super.bar()]: 1 }[0]
~~~~~
@@ -5,8 +5,6 @@ class Base {
}
}
class C extends Base {
// Gets emitted as super, not _super, which is consistent with
// use of super in static properties initializers.
[
{ [super.bar()]: 1 }[0]
]() { }
@@ -32,10 +30,8 @@ var C = (function (_super) {
function C() {
_super.apply(this, arguments);
}
// Gets emitted as super, not _super, which is consistent with
// use of super in static properties initializers.
C.prototype[(_a = {},
_a[super.bar.call(this)] = 1,
_a[_super.bar.call(this)] = 1,
_a)[0]] = function () {
};
return C;
@@ -13,30 +13,16 @@ class C extends Base {
}
//// [computedPropertyNames26_ES6.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Base = (function () {
function Base() {
}
Base.prototype.bar = function () {
class Base {
bar() {
return 0;
};
return Base;
})();
var C = (function (_super) {
__extends(C, _super);
function C() {
_super.apply(this, arguments);
}
}
class C extends Base {
// Gets emitted as super, not _super, which is consistent with
// use of super in static properties initializers.
C.prototype[{
[super.bar.call(this)]: 1
}[0]] = function () {
};
return C;
})(Base);
[{
[super.bar()]: 1
}[0]]() {
}
}
@@ -6,23 +6,9 @@ class C extends Base {
}
//// [computedPropertyNames27_ES6.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Base = (function () {
function Base() {
class Base {
}
class C extends Base {
[(super(), "prop")]() {
}
return Base;
})();
var C = (function (_super) {
__extends(C, _super);
function C() {
_super.apply(this, arguments);
}
C.prototype[(_super.call(this), "prop")] = function () {
};
return C;
})(Base);
}
@@ -11,25 +11,14 @@ class C extends Base {
}
//// [computedPropertyNames28_ES6.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Base = (function () {
function Base() {
}
return Base;
})();
var C = (function (_super) {
__extends(C, _super);
function C() {
_super.call(this);
class Base {
}
class C extends Base {
constructor() {
super();
var obj = {
[(_super.call(this), "prop")]() {
[(super(), "prop")]() {
}
};
}
return C;
})(Base);
}
@@ -11,10 +11,8 @@ class C {
}
//// [computedPropertyNames29_ES6.js]
var C = (function () {
function C() {
}
C.prototype.bar = function () {
class C {
bar() {
(() => {
var obj = {
[this.bar()]() {
@@ -22,6 +20,5 @@ var C = (function () {
};
});
return 0;
};
return C;
})();
}
}
@@ -13,36 +13,17 @@ class C {
//// [computedPropertyNames2_ES6.js]
var methodName = "method";
var accessorName = "accessor";
var C = (function () {
function C() {
class C {
[methodName]() {
}
C.prototype[methodName] = function () {
};
C[methodName] = function () {
};
Object.defineProperty(C.prototype, accessorName, {
get: function () {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, accessorName, {
set: function (v) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, accessorName, {
get: function () {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, accessorName, {
set: function (v) {
},
enumerable: true,
configurable: true
});
return C;
})();
static [methodName]() {
}
get [accessorName]() {
}
set [accessorName](v) {
}
static get [accessorName]() {
}
static set [accessorName](v) {
}
}
@@ -16,30 +16,19 @@ class C extends Base {
}
//// [computedPropertyNames30_ES6.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Base = (function () {
function Base() {
}
return Base;
})();
var C = (function (_super) {
__extends(C, _super);
function C() {
_super.call(this);
class Base {
}
class C extends Base {
constructor() {
super();
(() => {
var obj = {
// Ideally, we would capture this. But the reference is
// illegal, and not capturing this is consistent with
//treatment of other similar violations.
[(_super.call(this), "prop")]() {
[(super(), "prop")]() {
}
};
});
}
return C;
})(Base);
}
@@ -16,34 +16,20 @@ class C extends Base {
}
//// [computedPropertyNames31_ES6.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Base = (function () {
function Base() {
}
Base.prototype.bar = function () {
class Base {
bar() {
return 0;
};
return Base;
})();
var C = (function (_super) {
__extends(C, _super);
function C() {
_super.apply(this, arguments);
}
C.prototype.foo = function () {
}
class C extends Base {
foo() {
var _this = this;
(() => {
var obj = {
[_super.prototype.bar.call(_this)]() {
[super.bar()]() {
} // needs capture
};
});
return 0;
};
return C;
})(Base);
}
}
@@ -11,13 +11,10 @@ class C<T> {
function foo() {
return '';
}
var C = (function () {
function C() {
}
C.prototype.bar = function () {
class C {
bar() {
return 0;
};
C.prototype[foo()] = function () {
};
return C;
})();
}
[foo()]() {
}
}
@@ -13,15 +13,12 @@ class C<T> {
function foo() {
return '';
}
var C = (function () {
function C() {
}
C.prototype.bar = function () {
class C {
bar() {
var obj = {
[foo()]() {
}
};
return 0;
};
return C;
})();
}
}
@@ -13,15 +13,12 @@ class C<T> {
function foo() {
return '';
}
var C = (function () {
function C() {
}
C.bar = function () {
class C {
static bar() {
var obj = {
[foo()]() {
}
};
return 0;
};
return C;
})();
}
}
@@ -11,32 +11,15 @@ class C {
}
//// [computedPropertyNames36_ES6.js]
var Foo = (function () {
function Foo() {
class Foo {
}
class Foo2 {
}
class C {
// Computed properties
get ["get1"]() {
return new Foo;
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
set ["set1"](p) {
}
return Foo2;
})();
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "get1", {
// Computed properties
get: function () {
return new Foo;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, "set1", {
set: function (p) {
},
enumerable: true,
configurable: true
});
return C;
})();
}
@@ -11,32 +11,15 @@ class C {
}
//// [computedPropertyNames37_ES6.js]
var Foo = (function () {
function Foo() {
class Foo {
}
class Foo2 {
}
class C {
// Computed properties
get ["get1"]() {
return new Foo;
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
set ["set1"](p) {
}
return Foo2;
})();
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "get1", {
// Computed properties
get: function () {
return new Foo;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, "set1", {
set: function (p) {
},
enumerable: true,
configurable: true
});
return C;
})();
}
@@ -11,32 +11,15 @@ class C {
}
//// [computedPropertyNames38_ES6.js]
var Foo = (function () {
function Foo() {
class Foo {
}
class Foo2 {
}
class C {
// Computed properties
get [1 << 6]() {
return new Foo;
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
set [1 << 6](p) {
}
return Foo2;
})();
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, 1 << 6, {
// Computed properties
get: function () {
return new Foo;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, 1 << 6, {
set: function (p) {
},
enumerable: true,
configurable: true
});
return C;
})();
}
@@ -11,32 +11,15 @@ class C {
}
//// [computedPropertyNames39_ES6.js]
var Foo = (function () {
function Foo() {
class Foo {
}
class Foo2 {
}
class C {
// Computed properties
get [1 << 6]() {
return new Foo;
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
set [1 << 6](p) {
}
return Foo2;
})();
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, 1 << 6, {
// Computed properties
get: function () {
return new Foo;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, 1 << 6, {
set: function (p) {
},
enumerable: true,
configurable: true
});
return C;
})();
}
@@ -1,12 +1,13 @@
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,17): error TS1102: 'delete' cannot be called on an identifier in strict mode.
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts (6 errors) ====
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts (7 errors) ====
var id;
class C {
[0 + 1]() { }
@@ -18,6 +19,8 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,1
!!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement.
~~~~~~~~~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
~~
!!! error TS1102: 'delete' cannot be called on an identifier in strict mode.
set [[0, 1]](v) { }
~~~~~~~~
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
@@ -11,40 +11,21 @@ class C {
//// [computedPropertyNames3_ES6.js]
var id;
var C = (function () {
function C() {
class C {
[0 + 1]() {
}
C.prototype[0 + 1] = function () {
};
C[() => {
}] = function () {
};
Object.defineProperty(C.prototype, delete id, {
get: function () {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, [
static [() => {
}]() {
}
get [delete id]() {
}
set [[
0,
1
], {
set: function (v) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, "", {
get: function () {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, id.toString(), {
set: function (v) {
},
enumerable: true,
configurable: true
});
return C;
})();
]](v) {
}
static get [""]() {
}
static set [id.toString()](v) {
}
}
@@ -11,25 +11,16 @@ class C {
}
//// [computedPropertyNames40_ES6.js]
var Foo = (function () {
function Foo() {
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
}
return Foo2;
})();
var C = (function () {
function C() {
}
class Foo {
}
class Foo2 {
}
class C {
// Computed properties
C.prototype[""] = function () {
[""]() {
return new Foo;
};
C.prototype[""] = function () {
}
[""]() {
return new Foo2;
};
return C;
})();
}
}
@@ -10,22 +10,13 @@ class C {
}
//// [computedPropertyNames41_ES6.js]
var Foo = (function () {
function Foo() {
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
}
return Foo2;
})();
var C = (function () {
function C() {
}
class Foo {
}
class Foo2 {
}
class C {
// Computed properties
C[""] = function () {
static [""]() {
return new Foo;
};
return C;
})();
}
}
@@ -10,18 +10,9 @@ class C {
}
//// [computedPropertyNames42_ES6.js]
var Foo = (function () {
function Foo() {
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
}
return Foo2;
})();
var C = (function () {
function C() {
}
return C;
})();
class Foo {
}
class Foo2 {
}
class C {
}
@@ -13,45 +13,17 @@ class D extends C {
}
//// [computedPropertyNames43_ES6.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Foo = (function () {
function Foo() {
class Foo {
}
class Foo2 {
}
class C {
}
class D extends C {
// Computed properties
get ["get1"]() {
return new Foo;
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
set ["set1"](p) {
}
return Foo2;
})();
var C = (function () {
function C() {
}
return C;
})();
var D = (function (_super) {
__extends(D, _super);
function D() {
_super.apply(this, arguments);
}
Object.defineProperty(D.prototype, "get1", {
// Computed properties
get: function () {
return new Foo;
},
enumerable: true,
configurable: true
});
Object.defineProperty(D.prototype, "set1", {
set: function (p) {
},
enumerable: true,
configurable: true
});
return D;
})(C);
}
@@ -12,44 +12,16 @@ class D extends C {
}
//// [computedPropertyNames44_ES6.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Foo = (function () {
function Foo() {
class Foo {
}
class Foo2 {
}
class C {
get ["get1"]() {
return new Foo;
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
}
class D extends C {
set ["set1"](p) {
}
return Foo2;
})();
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "get1", {
get: function () {
return new Foo;
},
enumerable: true,
configurable: true
});
return C;
})();
var D = (function (_super) {
__extends(D, _super);
function D() {
_super.apply(this, arguments);
}
Object.defineProperty(D.prototype, "set1", {
set: function (p) {
},
enumerable: true,
configurable: true
});
return D;
})(C);
}
@@ -13,44 +13,16 @@ class D extends C {
}
//// [computedPropertyNames45_ES6.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Foo = (function () {
function Foo() {
class Foo {
}
class Foo2 {
}
class C {
get ["get1"]() {
return new Foo;
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
}
class D extends C {
set ["set1"](p) {
}
return Foo2;
})();
var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "get1", {
get: function () {
return new Foo;
},
enumerable: true,
configurable: true
});
return C;
})();
var D = (function (_super) {
__extends(D, _super);
function D() {
_super.apply(this, arguments);
}
Object.defineProperty(D.prototype, "set1", {
set: function (p) {
},
enumerable: true,
configurable: true
});
return D;
})(C);
}
@@ -6,26 +6,15 @@ class C {
}
//// [computedPropertyNamesDeclarationEmit1_ES6.js]
var C = (function () {
function C() {
class C {
["" + ""]() {
}
C.prototype["" + ""] = function () {
};
Object.defineProperty(C.prototype, "" + "", {
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C.prototype, "" + "", {
set: function (x) {
},
enumerable: true,
configurable: true
});
return C;
})();
get ["" + ""]() {
return 0;
}
set ["" + ""](x) {
}
}
//// [computedPropertyNamesDeclarationEmit1_ES6.d.ts]
@@ -6,26 +6,15 @@ class C {
}
//// [computedPropertyNamesDeclarationEmit2_ES6.js]
var C = (function () {
function C() {
class C {
static ["" + ""]() {
}
C["" + ""] = function () {
};
Object.defineProperty(C, "" + "", {
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, "" + "", {
set: function (x) {
},
enumerable: true,
configurable: true
});
return C;
})();
static get ["" + ""]() {
return 0;
}
static set ["" + ""](x) {
}
}
//// [computedPropertyNamesDeclarationEmit2_ES6.d.ts]
@@ -10,10 +10,7 @@ class C {
//// [computedPropertyNamesOnOverloads_ES6.js]
var methodName = "method";
var accessorName = "accessor";
var C = (function () {
function C() {
class C {
[methodName](v) {
}
C.prototype[methodName] = function (v) {
};
return C;
})();
}
@@ -6,12 +6,9 @@ class C {
}
//// [computedPropertyNamesSourceMap1_ES6.js]
var C = (function () {
function C() {
}
C.prototype["hello"] = function () {
class C {
["hello"]() {
debugger;
};
return C;
})();
}
}
//# sourceMappingURL=computedPropertyNamesSourceMap1_ES6.js.map
@@ -1,2 +1,2 @@
//// [computedPropertyNamesSourceMap1_ES6.js.map]
{"version":3,"file":"computedPropertyNamesSourceMap1_ES6.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap1_ES6.ts"],"names":["C","C.constructor","C[\"hello\"]"],"mappings":"AAAA;IAAAA;IAIAC,CAACA;IAHGD,YAACA,OAAOA,CAACA,GAATA;QACIE,QAAQA,CAACA;IACbA,CAACA;IACLF,QAACA;AAADA,CAACA,AAJD,IAIC"}
{"version":3,"file":"computedPropertyNamesSourceMap1_ES6.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap1_ES6.ts"],"names":["C","C[\"hello\"]"],"mappings":"AAAA;IACIA,CAACA,OAAOA,CAACA;QACLC,QAAQA,CAACA;IACbA,CAACA;AACLD,CAACA;AAAA"}
@@ -8,96 +8,61 @@ sources: computedPropertyNamesSourceMap1_ES6.ts
emittedFile:tests/cases/conformance/es6/computedProperties/computedPropertyNamesSourceMap1_ES6.js
sourceFile:computedPropertyNamesSourceMap1_ES6.ts
-------------------------------------------------------------------
>>>var C = (function () {
>>>class C {
1 >
2 >^^^^^^^^^^^^^^^^^^^->
2 >^^^^^^^^^^^^^^^^^^->
1 >
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
---
>>> function C() {
1->^^^^
2 > ^^->
1->
1->Emitted(2, 5) Source(1, 1) + SourceIndex(0) name (C)
---
>>> }
>>> ["hello"]() {
1->^^^^
2 > ^
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
3 > ^^^^^^^
4 > ^
5 > ^^^^^->
1->class C {
> ["hello"]() {
> debugger;
> }
>
2 > }
1->Emitted(3, 5) Source(5, 1) + SourceIndex(0) name (C.constructor)
2 >Emitted(3, 6) Source(5, 2) + SourceIndex(0) name (C.constructor)
---
>>> C.prototype["hello"] = function () {
1->^^^^
2 > ^^^^^^^^^^^^
3 > ^^^^^^^
4 > ^
5 > ^^^
1->
>
2 > [
3 > "hello"
4 > ]
5 >
1->Emitted(4, 5) Source(2, 5) + SourceIndex(0) name (C)
2 >Emitted(4, 17) Source(2, 6) + SourceIndex(0) name (C)
3 >Emitted(4, 24) Source(2, 13) + SourceIndex(0) name (C)
4 >Emitted(4, 25) Source(2, 14) + SourceIndex(0) name (C)
5 >Emitted(4, 28) Source(2, 5) + SourceIndex(0) name (C)
3 > "hello"
4 > ]
1->Emitted(2, 5) Source(2, 5) + SourceIndex(0) name (C)
2 >Emitted(2, 6) Source(2, 6) + SourceIndex(0) name (C)
3 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) name (C)
4 >Emitted(2, 14) Source(2, 14) + SourceIndex(0) name (C)
---
>>> debugger;
1 >^^^^^^^^
1->^^^^^^^^
2 > ^^^^^^^^
3 > ^
1 >["hello"]() {
1->() {
>
2 > debugger
3 > ;
1 >Emitted(5, 9) Source(3, 9) + SourceIndex(0) name (C["hello"])
2 >Emitted(5, 17) Source(3, 17) + SourceIndex(0) name (C["hello"])
3 >Emitted(5, 18) Source(3, 18) + SourceIndex(0) name (C["hello"])
1->Emitted(3, 9) Source(3, 9) + SourceIndex(0) name (C["hello"])
2 >Emitted(3, 17) Source(3, 17) + SourceIndex(0) name (C["hello"])
3 >Emitted(3, 18) Source(3, 18) + SourceIndex(0) name (C["hello"])
---
>>> };
>>> }
1 >^^^^
2 > ^
3 > ^^^^^^^^^->
1 >
>
2 > }
1 >Emitted(6, 5) Source(4, 5) + SourceIndex(0) name (C["hello"])
2 >Emitted(6, 6) Source(4, 6) + SourceIndex(0) name (C["hello"])
1 >Emitted(4, 5) Source(4, 5) + SourceIndex(0) name (C["hello"])
2 >Emitted(4, 6) Source(4, 6) + SourceIndex(0) name (C["hello"])
---
>>> return C;
1->^^^^
2 > ^^^^^^^^
1->
>
2 > }
1->Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (C)
2 >Emitted(7, 13) Source(5, 2) + SourceIndex(0) name (C)
---
>>>})();
>>>}
1 >
2 >^
3 >
4 > ^^^^
5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >
>
2 >}
3 >
4 > class C {
> ["hello"]() {
> debugger;
> }
> }
1 >Emitted(8, 1) Source(5, 1) + SourceIndex(0) name (C)
2 >Emitted(8, 2) Source(5, 2) + SourceIndex(0) name (C)
3 >Emitted(8, 2) Source(1, 1) + SourceIndex(0)
4 >Emitted(8, 6) Source(5, 2) + SourceIndex(0)
1 >Emitted(5, 1) Source(5, 1) + SourceIndex(0) name (C)
2 >Emitted(5, 2) Source(5, 2) + SourceIndex(0) name (C)
---
>>>//# sourceMappingURL=computedPropertyNamesSourceMap1_ES6.js.map
>>>//# sourceMappingURL=computedPropertyNamesSourceMap1_ES6.js.map1->
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1->
1->Emitted(6, 1) Source(5, 2) + SourceIndex(0)
---
@@ -0,0 +1,24 @@
//// [computedPropertyNamesWithStaticProperty.ts]
class C {
static staticProp = 10;
get [C.staticProp]() {
return "hello";
}
set [C.staticProp](x: string) {
var y = x;
}
[C.staticProp]() { }
}
//// [computedPropertyNamesWithStaticProperty.js]
class C {
get [C.staticProp]() {
return "hello";
}
set [C.staticProp](x) {
var y = x;
}
[C.staticProp]() {
}
}
C.staticProp = 10;
@@ -0,0 +1,29 @@
=== tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts ===
class C {
>C : C
static staticProp = 10;
>staticProp : number
get [C.staticProp]() {
>C.staticProp : number
>C : typeof C
>staticProp : number
return "hello";
}
set [C.staticProp](x: string) {
>C.staticProp : number
>C : typeof C
>staticProp : number
>x : string
var y = x;
>y : string
>x : string
}
[C.staticProp]() { }
>C.staticProp : number
>C : typeof C
>staticProp : number
}
@@ -1,3 +1,5 @@
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
tests/cases/compiler/constDeclarations_access_2.ts(2,1): error TS1202: 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.
tests/cases/compiler/constDeclarations_access_2.ts(4,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
tests/cases/compiler/constDeclarations_access_2.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
tests/cases/compiler/constDeclarations_access_2.ts(6,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
@@ -18,9 +20,12 @@ tests/cases/compiler/constDeclarations_access_2.ts(22,3): error TS2449: The oper
tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
==== tests/cases/compiler/constDeclarations_access_2.ts (18 errors) ====
!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
==== tests/cases/compiler/constDeclarations_access_2.ts (19 errors) ====
///<reference path='constDeclarations_access_1.ts'/>
import m = require('constDeclarations_access_1');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1202: 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.
// Errors
m.x = 1;
~~~
@@ -49,41 +49,37 @@ m.x.toString();
//// [constDeclarations_access_1.js]
define(["require", "exports"], function (require, exports) {
exports.x = 0;
});
export const x = 0;
//// [constDeclarations_access_2.js]
define(["require", "exports", 'constDeclarations_access_1'], function (require, exports, m) {
// Errors
m.x = 1;
m.x += 2;
m.x -= 3;
m.x *= 4;
m.x /= 5;
m.x %= 6;
m.x <<= 7;
m.x >>= 8;
m.x >>>= 9;
m.x &= 10;
m.x |= 11;
m.x ^= 12;
m;
m.x++;
m.x--;
++m.x;
--m.x;
++((m.x));
m["x"] = 0;
// OK
var a = m.x + 1;
function f(v) {
}
f(m.x);
if (m.x) {
}
m.x;
(m.x);
-m.x;
+m.x;
m.x.toString();
});
// Errors
m.x = 1;
m.x += 2;
m.x -= 3;
m.x *= 4;
m.x /= 5;
m.x %= 6;
m.x <<= 7;
m.x >>= 8;
m.x >>>= 9;
m.x &= 10;
m.x |= 11;
m.x ^= 12;
m;
m.x++;
m.x--;
++m.x;
--m.x;
++((m.x));
m["x"] = 0;
// OK
var a = m.x + 1;
function f(v) {
}
f(m.x);
if (m.x) {
}
m.x;
(m.x);
-m.x;
+m.x;
m.x.toString();
@@ -242,30 +242,25 @@ var m;
}
})(m || (m = {}));
// methods
var C = (function () {
function C() {
class C {
constructor() {
const c = 0;
n = c;
}
C.prototype.method = function () {
method() {
const c = 0;
n = c;
};
Object.defineProperty(C.prototype, "v", {
get: function () {
const c = 0;
n = c;
return n;
},
set: function (value) {
const c = 0;
n = c;
},
enumerable: true,
configurable: true
});
return C;
})();
}
get v() {
const c = 0;
n = c;
return n;
}
set v(value) {
const c = 0;
n = c;
}
}
// object literals
var o = {
f() {
@@ -201,26 +201,21 @@ var m;
}
})(m || (m = {}));
// methods
var C = (function () {
function C() {
class C {
constructor() {
const c24 = 0;
}
C.prototype.method = function () {
method() {
const c25 = 0;
};
Object.defineProperty(C.prototype, "v", {
get: function () {
const c26 = 0;
return c26;
},
set: function (value) {
const c27 = value;
},
enumerable: true,
configurable: true
});
return C;
})();
}
get v() {
const c26 = 0;
return c26;
}
set v(value) {
const c27 = value;
}
}
// object literals
var o = {
f() {
@@ -0,0 +1,26 @@
//// [constEnumOnlyModuleMerging.ts]
module Outer {
export var x = 1;
}
module Outer {
export const enum A { X }
}
module B {
import O = Outer;
var x = O.A.X;
var y = O.x;
}
//// [constEnumOnlyModuleMerging.js]
var Outer;
(function (Outer) {
Outer.x = 1;
})(Outer || (Outer = {}));
var B;
(function (B) {
var O = Outer;
var x = 0 /* X */;
var y = O.x;
})(B || (B = {}));
@@ -0,0 +1,37 @@
=== tests/cases/compiler/constEnumOnlyModuleMerging.ts ===
module Outer {
>Outer : typeof Outer
export var x = 1;
>x : number
}
module Outer {
>Outer : typeof Outer
export const enum A { X }
>A : A
>X : A
}
module B {
>B : typeof B
import O = Outer;
>O : typeof O
>Outer : typeof O
var x = O.A.X;
>x : O.A
>O.A.X : O.A
>O.A : typeof O.A
>O : typeof O
>A : typeof O.A
>X : O.A
var y = O.x;
>y : number
>O.x : number
>O : typeof O
>x : number
}
@@ -28,38 +28,26 @@ class C2 extends C1<number, string, boolean> {
//// [destructuringParameterProperties4.js]
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var C1 = (function () {
function C1(k, [a, b, c]) {
class C1 {
constructor(k, [a, b, c]) {
this.k = k;
this.[a, b, c] = [a, b, c];
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
this.a = a || k;
}
}
C1.prototype.getA = function () {
getA() {
return this.a;
};
C1.prototype.getB = function () {
return this.b;
};
C1.prototype.getC = function () {
return this.c;
};
return C1;
})();
var C2 = (function (_super) {
__extends(C2, _super);
function C2() {
_super.apply(this, arguments);
}
C2.prototype.doSomethingWithSuperProperties = function () {
getB() {
return this.b;
}
getC() {
return this.c;
}
}
class C2 extends C1 {
doSomethingWithSuperProperties() {
return `${this.a} ${this.b} ${this.c}`;
};
return C2;
})(C1);
}
}
@@ -0,0 +1,21 @@
//// [emitClassDeclarationOverloadInES6.ts]
class C {
constructor(y: any)
constructor(x: number) {
}
}
class D {
constructor(y: any)
constructor(x: number, z="hello") {}
}
//// [emitClassDeclarationOverloadInES6.js]
class C {
constructor(x) {
}
}
class D {
constructor(x, z = "hello") {
}
}
@@ -0,0 +1,22 @@
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationOverloadInES6.ts ===
class C {
>C : C
constructor(y: any)
>y : any
constructor(x: number) {
>x : number
}
}
class D {
>D : D
constructor(y: any)
>y : any
constructor(x: number, z="hello") {}
>x : number
>z : string
}
@@ -0,0 +1,42 @@
//// [emitClassDeclarationWithConstructorInES6.ts]
class A {
y: number;
constructor(x: number) {
}
foo(a: any);
foo() { }
}
class B {
y: number;
x: string = "hello";
_bar: string;
constructor(x: number, z = "hello", ...args) {
this.y = 10;
}
baz(...args): string;
baz(z: string, v: number): string {
return this._bar;
}
}
//// [emitClassDeclarationWithConstructorInES6.js]
class A {
constructor(x) {
}
foo() {
}
}
class B {
constructor(x, z = "hello", ...args) {
this.x = "hello";
this.y = 10;
}
baz(z, v) {
return this._bar;
}
}
@@ -0,0 +1,59 @@
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithConstructorInES6.ts ===
class A {
>A : A
y: number;
>y : number
constructor(x: number) {
>x : number
}
foo(a: any);
>foo : (a: any) => any
>a : any
foo() { }
>foo : (a: any) => any
}
class B {
>B : B
y: number;
>y : number
x: string = "hello";
>x : string
_bar: string;
>_bar : string
constructor(x: number, z = "hello", ...args) {
>x : number
>z : string
>args : any[]
this.y = 10;
>this.y = 10 : number
>this.y : number
>this : B
>y : number
}
baz(...args): string;
>baz : (...args: any[]) => string
>args : any[]
baz(z: string, v: number): string {
>baz : (...args: any[]) => string
>z : string
>v : number
return this._bar;
>this._bar : string
>this : B
>_bar : string
}
}
@@ -0,0 +1,24 @@
//// [emitClassDeclarationWithExtensionAndTypeArgumentInES6.ts]
class B<T> {
constructor(a: T) { }
}
class C extends B<string> { }
class D extends B<number> {
constructor(a: any)
constructor(b: number) {
super(b);
}
}
//// [emitClassDeclarationWithExtensionAndTypeArgumentInES6.js]
class B {
constructor(a) {
}
}
class C extends B {
}
class D extends B {
constructor(b) {
super(b);
}
}
@@ -0,0 +1,29 @@
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionAndTypeArgumentInES6.ts ===
class B<T> {
>B : B<T>
>T : T
constructor(a: T) { }
>a : T
>T : T
}
class C extends B<string> { }
>C : C
>B : B<T>
class D extends B<number> {
>D : D
>B : B<T>
constructor(a: any)
>a : any
constructor(b: number) {
>b : number
super(b);
>super(b) : void
>super : typeof B
>b : number
}
}
@@ -0,0 +1,48 @@
//// [emitClassDeclarationWithExtensionInES6.ts]
class B {
baz(a: string, y = 10) { }
}
class C extends B {
foo() { }
baz(a: string, y:number) {
super.baz(a, y);
}
}
class D extends C {
constructor() {
super();
}
foo() {
super.foo();
}
baz() {
super.baz("hello", 10);
}
}
//// [emitClassDeclarationWithExtensionInES6.js]
class B {
baz(a, y = 10) {
}
}
class C extends B {
foo() {
}
baz(a, y) {
super.baz(a, y);
}
}
class D extends C {
constructor() {
super();
}
foo() {
super.foo();
}
baz() {
super.baz("hello", 10);
}
}
@@ -0,0 +1,61 @@
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionInES6.ts ===
class B {
>B : B
baz(a: string, y = 10) { }
>baz : (a: string, y?: number) => void
>a : string
>y : number
}
class C extends B {
>C : C
>B : B
foo() { }
>foo : () => void
baz(a: string, y:number) {
>baz : (a: string, y: number) => void
>a : string
>y : number
super.baz(a, y);
>super.baz(a, y) : void
>super.baz : (a: string, y?: number) => void
>super : B
>baz : (a: string, y?: number) => void
>a : string
>y : number
}
}
class D extends C {
>D : D
>C : C
constructor() {
super();
>super() : void
>super : typeof C
}
foo() {
>foo : () => void
super.foo();
>super.foo() : void
>super.foo : () => void
>super : C
>foo : () => void
}
baz() {
>baz : () => void
super.baz("hello", 10);
>super.baz("hello", 10) : void
>super.baz : (a: string, y: number) => void
>super : C
>baz : (a: string, y: number) => void
}
}
@@ -0,0 +1,57 @@
//// [emitClassDeclarationWithGetterSetterInES6.ts]
class C {
_name: string;
get name(): string {
return this._name;
}
static get name2(): string {
return "BYE";
}
static get ["computedname"]() {
return "";
}
get ["computedname"]() {
return "";
}
get ["computedname"]() {
return "";
}
set ["computedname"](x: any) {
}
set ["computedname"](y: string) {
}
set foo(a: string) { }
static set bar(b: number) { }
static set ["computedname"](b: string) { }
}
//// [emitClassDeclarationWithGetterSetterInES6.js]
class C {
get name() {
return this._name;
}
static get name2() {
return "BYE";
}
static get ["computedname"]() {
return "";
}
get ["computedname"]() {
return "";
}
get ["computedname"]() {
return "";
}
set ["computedname"](x) {
}
set ["computedname"](y) {
}
set foo(a) {
}
static set bar(b) {
}
static set ["computedname"](b) {
}
}
@@ -0,0 +1,48 @@
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithGetterSetterInES6.ts ===
class C {
>C : C
_name: string;
>_name : string
get name(): string {
>name : string
return this._name;
>this._name : string
>this : C
>_name : string
}
static get name2(): string {
>name2 : string
return "BYE";
}
static get ["computedname"]() {
return "";
}
get ["computedname"]() {
return "";
}
get ["computedname"]() {
return "";
}
set ["computedname"](x: any) {
>x : any
}
set ["computedname"](y: string) {
>y : string
}
set foo(a: string) { }
>foo : string
>a : string
static set bar(b: number) { }
>bar : number
>b : number
static set ["computedname"](b: string) { }
>b : string
}
@@ -0,0 +1,37 @@
//// [emitClassDeclarationWithLiteralPropertyNameInES6.ts]
class B {
"hello" = 10;
0b110 = "world";
0o23534 = "WORLD";
20 = "twenty";
"foo"() { }
0b1110() {}
11() { }
interface() { }
static "hi" = 10000;
static 22 = "twenty-two";
static 0b101 = "binary";
static 0o3235 = "octal";
}
//// [emitClassDeclarationWithLiteralPropertyNameInES6.js]
class B {
constructor() {
this["hello"] = 10;
this[0b110] = "world";
this[0o23534] = "WORLD";
this[20] = "twenty";
}
"foo"() {
}
0b1110() {
}
11() {
}
interface() {
}
}
B["hi"] = 10000;
B[22] = "twenty-two";
B[0b101] = "binary";
B[0o3235] = "octal";
@@ -0,0 +1,19 @@
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithLiteralPropertyNameInES6.ts ===
class B {
>B : B
"hello" = 10;
0b110 = "world";
0o23534 = "WORLD";
20 = "twenty";
"foo"() { }
0b1110() {}
11() { }
interface() { }
>interface : () => void
static "hi" = 10000;
static 22 = "twenty-two";
static 0b101 = "binary";
static 0o3235 = "octal";
}
@@ -0,0 +1,58 @@
//// [emitClassDeclarationWithMethodInES6.ts]
class D {
_bar: string;
foo() { }
["computedName"]() { }
["computedName"](a: string) { }
["computedName"](a: string): number { return 1; }
bar(): string {
return this._bar;
}
baz(a: any, x: string): string {
return "HELLO";
}
static ["computedname"]() { }
static ["computedname"](a: string) { }
static ["computedname"](a: string): boolean { return true; }
static staticMethod() {
var x = 1 + 2;
return x
}
static foo(a: string) { }
static bar(a: string): number { return 1; }
}
//// [emitClassDeclarationWithMethodInES6.js]
class D {
foo() {
}
["computedName"]() {
}
["computedName"](a) {
}
["computedName"](a) {
return 1;
}
bar() {
return this._bar;
}
baz(a, x) {
return "HELLO";
}
static ["computedname"]() {
}
static ["computedname"](a) {
}
static ["computedname"](a) {
return true;
}
static staticMethod() {
var x = 1 + 2;
return x;
}
static foo(a) {
}
static bar(a) {
return 1;
}
}
@@ -0,0 +1,57 @@
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithMethodInES6.ts ===
class D {
>D : D
_bar: string;
>_bar : string
foo() { }
>foo : () => void
["computedName"]() { }
["computedName"](a: string) { }
>a : string
["computedName"](a: string): number { return 1; }
>a : string
bar(): string {
>bar : () => string
return this._bar;
>this._bar : string
>this : D
>_bar : string
}
baz(a: any, x: string): string {
>baz : (a: any, x: string) => string
>a : any
>x : string
return "HELLO";
}
static ["computedname"]() { }
static ["computedname"](a: string) { }
>a : string
static ["computedname"](a: string): boolean { return true; }
>a : string
static staticMethod() {
>staticMethod : () => number
var x = 1 + 2;
>x : number
>1 + 2 : number
return x
>x : number
}
static foo(a: string) { }
>foo : (a: string) => void
>a : string
static bar(a: string): number { return 1; }
>bar : (a: string) => number
>a : string
}
@@ -0,0 +1,51 @@
//// [emitClassDeclarationWithPropertyAssignmentInES6.ts]
class C {
x: string = "Hello world";
}
class D {
x: string = "Hello world";
y: number;
constructor() {
this.y = 10;
}
}
class E extends D{
z: boolean = true;
}
class F extends D{
z: boolean = true;
j: string;
constructor() {
super();
this.j = "HI";
}
}
//// [emitClassDeclarationWithPropertyAssignmentInES6.js]
class C {
constructor() {
this.x = "Hello world";
}
}
class D {
constructor() {
this.x = "Hello world";
this.y = 10;
}
}
class E extends D {
constructor(...args) {
super(...args);
this.z = true;
}
}
class F extends D {
constructor() {
super();
this.z = true;
this.j = "HI";
}
}
@@ -0,0 +1,56 @@
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAssignmentInES6.ts ===
class C {
>C : C
x: string = "Hello world";
>x : string
}
class D {
>D : D
x: string = "Hello world";
>x : string
y: number;
>y : number
constructor() {
this.y = 10;
>this.y = 10 : number
>this.y : number
>this : D
>y : number
}
}
class E extends D{
>E : E
>D : D
z: boolean = true;
>z : boolean
}
class F extends D{
>F : F
>D : D
z: boolean = true;
>z : boolean
j: string;
>j : string
constructor() {
super();
>super() : void
>super : typeof D
this.j = "HI";
>this.j = "HI" : string
>this.j : string
>this : F
>j : string
}
}

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