mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into getOccsForModifiers
This commit is contained in:
@@ -32,6 +32,7 @@ build.json
|
||||
tests/webhost/*.d.ts
|
||||
tests/webhost/webtsc.js
|
||||
tests/*.js
|
||||
tests/*.js.map
|
||||
tests/*.d.ts
|
||||
*.config
|
||||
scripts/debug.bat
|
||||
|
||||
+4
-2
@@ -1,12 +1,14 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- '0.10'
|
||||
- '0.10'
|
||||
|
||||
sudo: false
|
||||
|
||||
before_script: npm install -g codeclimate-test-reporter
|
||||
|
||||
after_script:
|
||||
- cat coverage/lcov.info | codeclimate
|
||||
- cat coverage/lcov.info | codeclimate
|
||||
|
||||
addons:
|
||||
code_climate:
|
||||
|
||||
+227
-77
@@ -6,7 +6,6 @@
|
||||
/// <reference path="emitter.ts"/>
|
||||
|
||||
module ts {
|
||||
|
||||
var nextSymbolId = 1;
|
||||
var nextNodeId = 1;
|
||||
var nextMergeId = 1;
|
||||
@@ -147,6 +146,7 @@ module ts {
|
||||
var globalNumberType: ObjectType;
|
||||
var globalBooleanType: ObjectType;
|
||||
var globalRegExpType: ObjectType;
|
||||
var globalTemplateStringsArrayType: ObjectType;
|
||||
|
||||
var tupleTypes: Map<TupleType> = {};
|
||||
var unionTypes: Map<UnionType> = {};
|
||||
@@ -4474,7 +4474,7 @@ module ts {
|
||||
if (symbol.flags & SymbolFlags.Import) {
|
||||
// Mark the import as referenced so that we emit it in the final .js file.
|
||||
// exception: identifiers that appear in type queries, const enums, modules that contain only const enums
|
||||
getSymbolLinks(symbol).referenced = !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveImport(symbol));
|
||||
getSymbolLinks(symbol).referenced = getSymbolLinks(symbol).referenced || (!isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveImport(symbol)));
|
||||
}
|
||||
|
||||
checkCollisionWithCapturedSuperVariable(node, node);
|
||||
@@ -5206,45 +5206,103 @@ module ts {
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
function resolveUntypedCall(node: CallExpression): Signature {
|
||||
forEach(node.arguments, argument => {
|
||||
checkExpression(argument);
|
||||
});
|
||||
function resolveUntypedCall(node: CallLikeExpression): Signature {
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
checkExpression((<TaggedTemplateExpression>node).template);
|
||||
}
|
||||
else {
|
||||
forEach((<CallExpression>node).arguments, argument => {
|
||||
checkExpression(argument);
|
||||
});
|
||||
}
|
||||
return anySignature;
|
||||
}
|
||||
|
||||
function resolveErrorCall(node: CallExpression): Signature {
|
||||
function resolveErrorCall(node: CallLikeExpression): Signature {
|
||||
resolveUntypedCall(node);
|
||||
return unknownSignature;
|
||||
}
|
||||
|
||||
function signatureHasCorrectArity(node: CallExpression, signature: Signature): boolean {
|
||||
if (!node.arguments) {
|
||||
// This only happens when we have something of the form:
|
||||
// new C
|
||||
//
|
||||
return signature.minArgumentCount === 0;
|
||||
function hasCorrectArity(node: CallLikeExpression, args: Expression[], signature: Signature) {
|
||||
var adjustedArgCount: number;
|
||||
var typeArguments: NodeArray<TypeNode>;
|
||||
var callIsIncomplete: boolean;
|
||||
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
var tagExpression = <TaggedTemplateExpression>node;
|
||||
|
||||
// Even if the call is incomplete, we'll have a missing expression as our last argument,
|
||||
// so we can say the count is just the arg list length
|
||||
adjustedArgCount = args.length;
|
||||
typeArguments = undefined;
|
||||
|
||||
if (tagExpression.template.kind === SyntaxKind.TemplateExpression) {
|
||||
// If a tagged template expression lacks a tail literal, the call is incomplete.
|
||||
// Specifically, a template only can end in a TemplateTail or a Missing literal.
|
||||
var templateExpression = <TemplateExpression>tagExpression.template;
|
||||
var lastSpan = lastOrUndefined(templateExpression.templateSpans);
|
||||
Debug.assert(lastSpan !== undefined); // we should always have at least one span.
|
||||
callIsIncomplete = lastSpan.literal.kind === SyntaxKind.Missing || isUnterminatedTemplateEnd(lastSpan.literal);
|
||||
}
|
||||
else {
|
||||
// If the template didn't end in a backtick, or its beginning occurred right prior to EOF,
|
||||
// then this might actually turn out to be a TemplateHead in the future;
|
||||
// so we consider the call to be incomplete.
|
||||
var templateLiteral = <LiteralExpression>tagExpression.template;
|
||||
Debug.assert(templateLiteral.kind === SyntaxKind.NoSubstitutionTemplateLiteral);
|
||||
callIsIncomplete = isUnterminatedTemplateEnd(templateLiteral);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var callExpression = <CallExpression>node;
|
||||
if (!callExpression.arguments) {
|
||||
// This only happens when we have something of the form: 'new C'
|
||||
Debug.assert(callExpression.kind === SyntaxKind.NewExpression);
|
||||
|
||||
return signature.minArgumentCount === 0;
|
||||
}
|
||||
|
||||
// For IDE scenarios we may have an incomplete call, so a trailing comma is tantamount to adding another argument.
|
||||
adjustedArgCount = callExpression.arguments.hasTrailingComma ? args.length + 1 : args.length;
|
||||
|
||||
// If we are missing the close paren, the call is incomplete.
|
||||
callIsIncomplete = (<CallExpression>callExpression).arguments.end === callExpression.end;
|
||||
|
||||
typeArguments = callExpression.typeArguments;
|
||||
}
|
||||
|
||||
// For IDE scenarios, since we may have an incomplete call, we make two modifications
|
||||
// to arity checking.
|
||||
// 1. A trailing comma is tantamount to adding another argument
|
||||
// 2. If the call is incomplete (no closing paren) allow fewer arguments than expected
|
||||
var args = node.arguments;
|
||||
var numberOfArgs = args.hasTrailingComma ? args.length + 1 : args.length;
|
||||
var hasTooManyArguments = !signature.hasRestParameter && numberOfArgs > signature.parameters.length;
|
||||
var hasRightNumberOfTypeArguments = !node.typeArguments ||
|
||||
(signature.typeParameters && node.typeArguments.length === signature.typeParameters.length);
|
||||
Debug.assert(adjustedArgCount !== undefined, "'adjustedArgCount' undefined");
|
||||
Debug.assert(callIsIncomplete !== undefined, "'callIsIncomplete' undefined");
|
||||
|
||||
if (hasTooManyArguments || !hasRightNumberOfTypeArguments) {
|
||||
return false;
|
||||
return checkArity(adjustedArgCount, typeArguments, callIsIncomplete, signature);
|
||||
|
||||
/**
|
||||
* @param adjustedArgCount The "apparent" number of arguments that we will have in this call.
|
||||
* @param typeArguments Type arguments node of the call if it exists; undefined otherwise.
|
||||
* @param callIsIncomplete Whether or not a call is unfinished, and we should be "lenient" when we have too few arguments.
|
||||
* @param signature The signature whose arity we are comparing.
|
||||
*/
|
||||
function checkArity(adjustedArgCount: number,
|
||||
typeArguments: NodeArray<TypeNode>,
|
||||
callIsIncomplete: boolean,
|
||||
signature: Signature): boolean {
|
||||
// Too many arguments implies incorrect arity.
|
||||
if (!signature.hasRestParameter && adjustedArgCount > signature.parameters.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the user supplied type arguments, but the number of type arguments does not match
|
||||
// the declared number of type parameters, the call has an incorrect arity.
|
||||
var hasRightNumberOfTypeArgs = !typeArguments ||
|
||||
(signature.typeParameters && typeArguments.length === signature.typeParameters.length);
|
||||
if (!hasRightNumberOfTypeArgs) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If the call is incomplete, we should skip the lower bound check.
|
||||
var hasEnoughArguments = adjustedArgCount >= signature.minArgumentCount;
|
||||
return callIsIncomplete || hasEnoughArguments;
|
||||
}
|
||||
|
||||
// If we are missing the close paren, the call is incomplete, and we should skip
|
||||
// the lower bound check.
|
||||
var callIsIncomplete = args.end === node.end;
|
||||
var hasEnoughArguments = numberOfArgs >= signature.minArgumentCount;
|
||||
return callIsIncomplete || hasEnoughArguments;
|
||||
}
|
||||
|
||||
// If type has a single call signature and no other members, return that signature. Otherwise, return undefined.
|
||||
@@ -5280,15 +5338,23 @@ module ts {
|
||||
}
|
||||
if (!excludeArgument || excludeArgument[i] === undefined) {
|
||||
var parameterType = getTypeAtPosition(signature, i);
|
||||
|
||||
if (i === 0 && args[i].parent.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
inferTypes(context, globalTemplateStringsArrayType, parameterType);
|
||||
continue;
|
||||
}
|
||||
|
||||
inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType);
|
||||
}
|
||||
}
|
||||
|
||||
// Next, infer from those context sensitive arguments that are no longer excluded
|
||||
if (excludeArgument) {
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
if (args[i].kind === SyntaxKind.OmittedExpression) {
|
||||
continue;
|
||||
}
|
||||
// No need to special-case tagged templates; their excludeArgument value will be 'undefined'.
|
||||
if (excludeArgument[i] === false) {
|
||||
var parameterType = getTypeAtPosition(signature, i);
|
||||
inferTypes(context, checkExpressionWithContextualType(args[i], parameterType, mapper), parameterType);
|
||||
@@ -5328,31 +5394,72 @@ module ts {
|
||||
return typeArgumentsAreAssignable;
|
||||
}
|
||||
|
||||
function checkApplicableSignature(node: CallExpression, signature: Signature, relation: Map<Ternary>, excludeArgument: boolean[], reportErrors: boolean) {
|
||||
if (node.arguments) {
|
||||
for (var i = 0; i < node.arguments.length; i++) {
|
||||
var arg = node.arguments[i];
|
||||
if (arg.kind === SyntaxKind.OmittedExpression) {
|
||||
continue;
|
||||
}
|
||||
var paramType = getTypeAtPosition(signature, i);
|
||||
function checkApplicableSignature(node: CallLikeExpression, args: Node[], signature: Signature, relation: Map<Ternary>, excludeArgument: boolean[], reportErrors: boolean) {
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
var arg = args[i];
|
||||
var argType: Type;
|
||||
|
||||
if (arg.kind === SyntaxKind.OmittedExpression) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var paramType = getTypeAtPosition(signature, i);
|
||||
|
||||
if (i === 0 && node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
// A tagged template expression has something of a
|
||||
// "virtual" parameter with the "cooked" strings array type.
|
||||
argType = globalTemplateStringsArrayType;
|
||||
}
|
||||
else {
|
||||
// String literals get string literal types unless we're reporting errors
|
||||
var argType = arg.kind === SyntaxKind.StringLiteral && !reportErrors ?
|
||||
getStringLiteralType(<LiteralExpression>arg) :
|
||||
checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined);
|
||||
// Use argument expression as error location when reporting errors
|
||||
var isValidArgument = checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined,
|
||||
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1);
|
||||
if (!isValidArgument) {
|
||||
return false;
|
||||
}
|
||||
argType = arg.kind === SyntaxKind.StringLiteral && !reportErrors
|
||||
? getStringLiteralType(<LiteralExpression>arg)
|
||||
: checkExpressionWithContextualType(arg, paramType, excludeArgument && excludeArgument[i] ? identityMapper : undefined);
|
||||
}
|
||||
|
||||
// Use argument expression as error location when reporting errors
|
||||
var isValidArgument = checkTypeRelatedTo(argType, paramType, relation, reportErrors ? arg : undefined,
|
||||
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1);
|
||||
if (!isValidArgument) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function resolveCall(node: CallExpression, signatures: Signature[], candidatesOutArray: Signature[]): Signature {
|
||||
forEach(node.typeArguments, checkSourceElement);
|
||||
/**
|
||||
* Returns the effective arguments for an expression that works like a function invokation.
|
||||
*
|
||||
* If 'node' is a CallExpression or a NewExpression, then its argument list is returned.
|
||||
* If 'node' is a TaggedTemplateExpression, a new argument list is constructed from the substitution
|
||||
* expressions, where the first element of the list is the template for error reporting purposes.
|
||||
*/
|
||||
function getEffectiveCallArguments(node: CallLikeExpression): Expression[] {
|
||||
var args: Expression[];
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
var template = (<TaggedTemplateExpression>node).template;
|
||||
args = [template];
|
||||
|
||||
if (template.kind === SyntaxKind.TemplateExpression) {
|
||||
forEach((<TemplateExpression>template).templateSpans, span => {
|
||||
args.push(span.expression);
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
args = (<CallExpression>node).arguments || emptyArray;
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
function resolveCall(node: CallLikeExpression, signatures: Signature[], candidatesOutArray: Signature[]): Signature {
|
||||
var isTaggedTemplate = node.kind === SyntaxKind.TaggedTemplateExpression;
|
||||
|
||||
var typeArguments = isTaggedTemplate ? undefined : (<CallExpression>node).typeArguments;
|
||||
forEach(typeArguments, checkSourceElement);
|
||||
|
||||
var candidates = candidatesOutArray || [];
|
||||
// collectCandidates fills up the candidates array directly
|
||||
collectCandidates();
|
||||
@@ -5360,11 +5467,26 @@ module ts {
|
||||
error(node, Diagnostics.Supplied_parameters_do_not_match_any_signature_of_call_target);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
var args = node.arguments || emptyArray;
|
||||
|
||||
var args = getEffectiveCallArguments(node);
|
||||
|
||||
// The following applies to any value of 'excludeArgument[i]':
|
||||
// - true: the argument at 'i' is susceptible to a one-time permanent contextual typing.
|
||||
// - undefined: the argument at 'i' is *not* susceptible to permanent contextual typing.
|
||||
// - false: the argument at 'i' *was* and *has been* permanently contextually typed.
|
||||
//
|
||||
// The idea is that we will perform type argument inference & assignability checking once
|
||||
// without using the susceptible parameters that are functions, and once more for each of those
|
||||
// parameters, contextually typing each as we go along.
|
||||
//
|
||||
// For a tagged template, then the first argument be 'undefined' if necessary
|
||||
// because it represents a TemplateStringsArray.
|
||||
var excludeArgument: boolean[];
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
for (var i = isTaggedTemplate ? 1 : 0; i < args.length; i++) {
|
||||
if (isContextSensitiveExpression(args[i])) {
|
||||
if (!excludeArgument) excludeArgument = new Array(args.length);
|
||||
if (!excludeArgument) {
|
||||
excludeArgument = new Array(args.length);
|
||||
}
|
||||
excludeArgument[i] = true;
|
||||
}
|
||||
}
|
||||
@@ -5406,14 +5528,14 @@ module ts {
|
||||
// is just important for choosing the best signature. So in the case where there is only one
|
||||
// signature, the subtype pass is useless. So skipping it is an optimization.
|
||||
if (candidates.length > 1) {
|
||||
result = chooseOverload(candidates, subtypeRelation, excludeArgument);
|
||||
result = chooseOverload(candidates, subtypeRelation);
|
||||
}
|
||||
if (!result) {
|
||||
// Reinitialize these pointers for round two
|
||||
candidateForArgumentError = undefined;
|
||||
candidateForTypeArgumentError = undefined;
|
||||
resultOfFailedInference = undefined;
|
||||
result = chooseOverload(candidates, assignableRelation, excludeArgument);
|
||||
result = chooseOverload(candidates, assignableRelation);
|
||||
}
|
||||
if (result) {
|
||||
return result;
|
||||
@@ -5429,11 +5551,11 @@ module ts {
|
||||
// in arguments too early. If possible, we'd like to only type them once we know the correct
|
||||
// overload. However, this matters for the case where the call is correct. When the call is
|
||||
// an error, we don't need to exclude any arguments, although it would cause no harm to do so.
|
||||
checkApplicableSignature(node, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true);
|
||||
checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true);
|
||||
}
|
||||
else if (candidateForTypeArgumentError) {
|
||||
if (node.typeArguments) {
|
||||
checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, [], /*reportErrors*/ true)
|
||||
if (!isTaggedTemplate && (<CallExpression>node).typeArguments) {
|
||||
checkTypeArguments(candidateForTypeArgumentError, (<CallExpression>node).typeArguments, [], /*reportErrors*/ true)
|
||||
}
|
||||
else {
|
||||
Debug.assert(resultOfFailedInference.failedTypeParameterIndex >= 0);
|
||||
@@ -5444,7 +5566,7 @@ module ts {
|
||||
Diagnostics.The_type_argument_for_type_parameter_0_cannot_be_inferred_from_the_usage_Consider_specifying_the_type_arguments_explicitly,
|
||||
typeToString(failedTypeParameter));
|
||||
|
||||
reportNoCommonSupertypeError(inferenceCandidates, node.func, diagnosticChainHead);
|
||||
reportNoCommonSupertypeError(inferenceCandidates, (<CallExpression>node).func || (<TaggedTemplateExpression>node).tag, diagnosticChainHead);
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -5458,7 +5580,7 @@ module ts {
|
||||
// f({ |
|
||||
if (!fullTypeCheck) {
|
||||
for (var i = 0, n = candidates.length; i < n; i++) {
|
||||
if (signatureHasCorrectArity(node, candidates[i])) {
|
||||
if (hasCorrectArity(node, args, candidates[i])) {
|
||||
return candidates[i];
|
||||
}
|
||||
}
|
||||
@@ -5466,9 +5588,9 @@ module ts {
|
||||
|
||||
return resolveErrorCall(node);
|
||||
|
||||
function chooseOverload(candidates: Signature[], relation: Map<Ternary>, excludeArgument: boolean[]) {
|
||||
function chooseOverload(candidates: Signature[], relation: Map<Ternary>) {
|
||||
for (var i = 0; i < candidates.length; i++) {
|
||||
if (!signatureHasCorrectArity(node, candidates[i])) {
|
||||
if (!hasCorrectArity(node, args, candidates[i])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -5480,9 +5602,9 @@ module ts {
|
||||
if (candidate.typeParameters) {
|
||||
var typeArgumentTypes: Type[];
|
||||
var typeArgumentsAreValid: boolean;
|
||||
if (node.typeArguments) {
|
||||
if (typeArguments) {
|
||||
typeArgumentTypes = new Array<Type>(candidate.typeParameters.length);
|
||||
typeArgumentsAreValid = checkTypeArguments(candidate, node.typeArguments, typeArgumentTypes, /*reportErrors*/ false)
|
||||
typeArgumentsAreValid = checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false)
|
||||
}
|
||||
else {
|
||||
inferenceResult = inferTypeArguments(candidate, args, excludeArgument);
|
||||
@@ -5494,7 +5616,7 @@ module ts {
|
||||
}
|
||||
candidate = getSignatureInstantiation(candidate, typeArgumentTypes);
|
||||
}
|
||||
if (!checkApplicableSignature(node, candidate, relation, excludeArgument, /*reportErrors*/ false)) {
|
||||
if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) {
|
||||
break;
|
||||
}
|
||||
var index = excludeArgument ? indexOf(excludeArgument, true) : -1;
|
||||
@@ -5516,7 +5638,7 @@ module ts {
|
||||
}
|
||||
else {
|
||||
candidateForTypeArgumentError = originalCandidate;
|
||||
if (!node.typeArguments) {
|
||||
if (!typeArguments) {
|
||||
resultOfFailedInference = inferenceResult;
|
||||
}
|
||||
}
|
||||
@@ -5627,7 +5749,6 @@ module ts {
|
||||
|
||||
function resolveNewExpression(node: NewExpression, candidatesOutArray: Signature[]): Signature {
|
||||
var expressionType = checkExpression(node.func);
|
||||
|
||||
// TS 1.0 spec: 4.11
|
||||
// If ConstructExpr is of type Any, Args can be any argument
|
||||
// list and the result of the operation is of type Any.
|
||||
@@ -5675,9 +5796,32 @@ module ts {
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
|
||||
function resolveTaggedTemplateExpression(node: TaggedTemplateExpression, candidatesOutArray: Signature[]): Signature {
|
||||
var tagType = checkExpression(node.tag);
|
||||
var apparentType = getApparentType(tagType);
|
||||
|
||||
if (apparentType === unknownType) {
|
||||
// Another error has already been reported
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
|
||||
var callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call);
|
||||
|
||||
if (tagType === anyType || (!callSignatures.length && !(tagType.flags & TypeFlags.Union) && isTypeAssignableTo(tagType, globalFunctionType))) {
|
||||
return resolveUntypedCall(node);
|
||||
}
|
||||
|
||||
if (!callSignatures.length) {
|
||||
error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature);
|
||||
return resolveErrorCall(node);
|
||||
}
|
||||
|
||||
return resolveCall(node, callSignatures, candidatesOutArray);
|
||||
}
|
||||
|
||||
// candidatesOutArray is passed by signature help in the language service, and collectCandidates
|
||||
// must fill it up with the appropriate candidate signatures
|
||||
function getResolvedSignature(node: CallExpression, candidatesOutArray?: Signature[]): Signature {
|
||||
function getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature {
|
||||
var links = getNodeLinks(node);
|
||||
// If getResolvedSignature has already been called, we will have cached the resolvedSignature.
|
||||
// However, it is possible that either candidatesOutArray was not passed in the first time,
|
||||
@@ -5685,9 +5829,19 @@ module ts {
|
||||
// to correctly fill the candidatesOutArray.
|
||||
if (!links.resolvedSignature || candidatesOutArray) {
|
||||
links.resolvedSignature = anySignature;
|
||||
links.resolvedSignature = node.kind === SyntaxKind.CallExpression
|
||||
? resolveCallExpression(node, candidatesOutArray)
|
||||
: resolveNewExpression(node, candidatesOutArray);
|
||||
|
||||
if (node.kind === SyntaxKind.CallExpression) {
|
||||
links.resolvedSignature = resolveCallExpression(<CallExpression>node, candidatesOutArray);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.NewExpression) {
|
||||
links.resolvedSignature = resolveNewExpression(<NewExpression>node, candidatesOutArray);
|
||||
}
|
||||
else if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
links.resolvedSignature = resolveTaggedTemplateExpression(<TaggedTemplateExpression>node, candidatesOutArray);
|
||||
}
|
||||
else {
|
||||
Debug.fail("Branch in 'getResolvedSignature' should be unreachable.");
|
||||
}
|
||||
}
|
||||
return links.resolvedSignature;
|
||||
}
|
||||
@@ -5711,10 +5865,7 @@ module ts {
|
||||
}
|
||||
|
||||
function checkTaggedTemplateExpression(node: TaggedTemplateExpression): Type {
|
||||
// TODO (drosen): Make sure substitutions are assignable to the tag's arguments.
|
||||
checkExpression(node.tag);
|
||||
checkExpression(node.template);
|
||||
return anyType;
|
||||
return getReturnTypeOfSignature(getResolvedSignature(node));
|
||||
}
|
||||
|
||||
function checkTypeAssertion(node: TypeAssertion): Type {
|
||||
@@ -6683,7 +6834,6 @@ module ts {
|
||||
return;
|
||||
}
|
||||
|
||||
var symbol = getSymbolOfNode(signatureDeclarationNode);
|
||||
// TypeScript 1.0 spec (April 2014): 3.7.2.4
|
||||
// Every specialized call or construct signature in an object type must be assignable
|
||||
// to at least one non-specialized call or construct signature in the same object type
|
||||
@@ -8468,7 +8618,7 @@ module ts {
|
||||
// above them to find the lowest container
|
||||
case SyntaxKind.Identifier:
|
||||
// If the identifier is the RHS of a qualified name, then it's a type iff its parent is.
|
||||
if (node.parent.kind === SyntaxKind.QualifiedName) {
|
||||
if (node.parent.kind === SyntaxKind.QualifiedName && (<QualifiedName>node.parent).right === node) {
|
||||
node = node.parent;
|
||||
}
|
||||
// fall through
|
||||
@@ -8811,7 +8961,6 @@ module ts {
|
||||
// parent is not source file or it is not reference to internal module
|
||||
return false;
|
||||
}
|
||||
var symbol = getSymbolOfNode(node);
|
||||
return isImportResolvedToValue(getSymbolOfNode(node));
|
||||
}
|
||||
|
||||
@@ -8953,6 +9102,7 @@ module ts {
|
||||
globalNumberType = getGlobalType("Number");
|
||||
globalBooleanType = getGlobalType("Boolean");
|
||||
globalRegExpType = getGlobalType("RegExp");
|
||||
globalTemplateStringsArrayType = getGlobalType("TemplateStringsArray");
|
||||
}
|
||||
|
||||
initializeTypeChecker();
|
||||
|
||||
@@ -122,6 +122,17 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last element of an array if non-empty, undefined otherwise.
|
||||
*/
|
||||
export function lastOrUndefined<T>(array: T[]): T {
|
||||
if (array.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return array[array.length - 1];
|
||||
}
|
||||
|
||||
export function binarySearch(array: number[], value: number): number {
|
||||
var low = 0;
|
||||
var high = array.length - 1;
|
||||
|
||||
+22
-5
@@ -34,12 +34,16 @@ module ts {
|
||||
return file.filename + "(" + loc.line + "," + loc.character + ")";
|
||||
}
|
||||
|
||||
|
||||
export function getStartPosOfNode(node: Node): number {
|
||||
return node.pos;
|
||||
}
|
||||
|
||||
export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile): number {
|
||||
// With nodes that have no width (i.e. 'Missing' nodes), we actually *don't*
|
||||
// want to skip trivia because this will launch us forward to the next token.
|
||||
if (node.pos === node.end) {
|
||||
return node.pos;
|
||||
}
|
||||
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
|
||||
}
|
||||
|
||||
@@ -567,7 +571,6 @@ module ts {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
export function isDeclaration(node: Node): boolean {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.TypeParameter:
|
||||
@@ -747,7 +750,7 @@ module ts {
|
||||
nodeIsNestedInLabel(label: Identifier, requireIterationStatement: boolean, stopAtFunctionBoundary: boolean): ControlBlockContext;
|
||||
}
|
||||
|
||||
interface ReferencePathMatchResult {
|
||||
export interface ReferencePathMatchResult {
|
||||
fileReference?: FileReference
|
||||
diagnostic?: DiagnosticMessage
|
||||
isNoDefaultLib?: boolean
|
||||
@@ -796,6 +799,20 @@ module ts {
|
||||
return SyntaxKind.FirstTriviaToken <= token && token <= SyntaxKind.LastTriviaToken;
|
||||
}
|
||||
|
||||
export function isUnterminatedTemplateEnd(node: LiteralExpression) {
|
||||
Debug.assert(node.kind === SyntaxKind.NoSubstitutionTemplateLiteral || node.kind === SyntaxKind.TemplateTail);
|
||||
var sourceText = getSourceFileOfNode(node).text;
|
||||
|
||||
// If we're not at the EOF, we know we must be terminated.
|
||||
if (node.end !== sourceText.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we didn't end in a backtick, we must still be in the middle of a template.
|
||||
// If we did, make sure that it's not the *initial* backtick.
|
||||
return sourceText.charCodeAt(node.end - 1) !== CharacterCodes.backtick || node.text.length === 0;
|
||||
}
|
||||
|
||||
export function isModifier(token: SyntaxKind): boolean {
|
||||
switch (token) {
|
||||
case SyntaxKind.PublicKeyword:
|
||||
@@ -1145,6 +1162,7 @@ module ts {
|
||||
}
|
||||
|
||||
function internIdentifier(text: string): string {
|
||||
text = escapeIdentifier(text);
|
||||
return hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text);
|
||||
}
|
||||
|
||||
@@ -1155,8 +1173,7 @@ module ts {
|
||||
identifierCount++;
|
||||
if (isIdentifier) {
|
||||
var node = <Identifier>createNode(SyntaxKind.Identifier);
|
||||
var text = escapeIdentifier(scanner.getTokenValue());
|
||||
node.text = internIdentifier(text);
|
||||
node.text = internIdentifier(scanner.getTokenValue());
|
||||
nextToken();
|
||||
return finishNode(node);
|
||||
}
|
||||
|
||||
@@ -477,6 +477,8 @@ module ts {
|
||||
template: LiteralExpression | TemplateExpression;
|
||||
}
|
||||
|
||||
export type CallLikeExpression = CallExpression | NewExpression | TaggedTemplateExpression;
|
||||
|
||||
export interface TypeAssertion extends Expression {
|
||||
type: TypeNode;
|
||||
operand: Expression;
|
||||
|
||||
@@ -285,12 +285,10 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||
typeLines.push('=== ' + file.unitName + ' ===\r\n');
|
||||
for (var i = 0; i < codeLines.length; i++) {
|
||||
var currentCodeLine = codeLines[i];
|
||||
var lastLine = typeLines[typeLines.length];
|
||||
typeLines.push(currentCodeLine + '\r\n');
|
||||
if (typeMap[file.unitName]) {
|
||||
var typeInfo = typeMap[file.unitName][i];
|
||||
if (typeInfo) {
|
||||
var leadingSpaces = '';
|
||||
typeInfo.forEach(ty => {
|
||||
typeLines.push('>' + ty + '\r\n');
|
||||
});
|
||||
|
||||
@@ -2074,10 +2074,6 @@ module FourSlash {
|
||||
}
|
||||
}
|
||||
|
||||
private getEOF(): number {
|
||||
return this.languageServiceShimHost.getScriptSnapshot(this.activeFile.fileName).getLength();
|
||||
}
|
||||
|
||||
// Get the text of the entire line the caret is currently at
|
||||
private getCurrentLineContent() {
|
||||
// The current caret position (in line/col terms)
|
||||
@@ -2193,14 +2189,6 @@ module FourSlash {
|
||||
return result;
|
||||
}
|
||||
|
||||
private getCurrentLineNumberZeroBased() {
|
||||
return this.getCurrentLineNumberOneBased() - 1;
|
||||
}
|
||||
|
||||
private getCurrentLineNumberOneBased() {
|
||||
return this.languageServiceShimHost.positionToZeroBasedLineCol(this.activeFile.fileName, this.currentCaretPosition).line + 1;
|
||||
}
|
||||
|
||||
private getLineColStringAtPosition(position: number) {
|
||||
var pos = this.languageServiceShimHost.positionToZeroBasedLineCol(this.activeFile.fileName, position);
|
||||
return 'line ' + (pos.line + 1) + ', col ' + pos.character;
|
||||
|
||||
@@ -20,7 +20,7 @@ class FourslashRunner extends RunnerBase {
|
||||
});
|
||||
|
||||
this.tests.forEach((fn: string) => {
|
||||
fn = Harness.Path.switchToForwardSlashes(fn);
|
||||
fn = ts.normalizeSlashes(fn);
|
||||
var justName = fn.replace(/^.*[\\\/]/, '');
|
||||
|
||||
// Convert to relative path
|
||||
|
||||
+4
-11
@@ -117,15 +117,11 @@ module Harness.Path {
|
||||
}
|
||||
|
||||
export function filePath(fullPath: string) {
|
||||
fullPath = switchToForwardSlashes(fullPath);
|
||||
fullPath = ts.normalizeSlashes(fullPath);
|
||||
var components = fullPath.split("/");
|
||||
var path: string[] = components.slice(0, components.length - 1);
|
||||
return path.join("/") + "/";
|
||||
}
|
||||
|
||||
export function switchToForwardSlashes(path: string) {
|
||||
return path.replace(/\\/g, "/").replace(/\/\//g, '/');
|
||||
}
|
||||
}
|
||||
|
||||
module Harness {
|
||||
@@ -564,7 +560,7 @@ module Harness {
|
||||
// Register input files
|
||||
function register(file: { unitName: string; content: string; }) {
|
||||
if (file.content !== undefined) {
|
||||
var filename = Path.switchToForwardSlashes(file.unitName);
|
||||
var filename = ts.normalizeSlashes(file.unitName);
|
||||
filemap[getCanonicalFileName(filename)] = ts.createSourceFile(filename, file.content, scriptTarget, /*version:*/ "0");
|
||||
}
|
||||
};
|
||||
@@ -782,7 +778,7 @@ module Harness {
|
||||
var filemap: { [name: string]: ts.SourceFile; } = {};
|
||||
var register = (file: { unitName: string; content: string; }) => {
|
||||
if (file.content !== undefined) {
|
||||
var filename = Path.switchToForwardSlashes(file.unitName);
|
||||
var filename = ts.normalizeSlashes(file.unitName);
|
||||
filemap[getCanonicalFileName(filename)] = ts.createSourceFile(filename, file.content, options.target, /*version:*/ "0");
|
||||
}
|
||||
};
|
||||
@@ -1092,7 +1088,6 @@ module Harness {
|
||||
/** @param fileResults an array of strings for the fileName and an ITextWriter with its code */
|
||||
constructor(fileResults: GeneratedFile[], errors: HarnessDiagnostic[], public program: ts.Program,
|
||||
public currentDirectoryForProgram: string, private sourceMapData: ts.SourceMapData[]) {
|
||||
var lines: string[] = [];
|
||||
|
||||
fileResults.forEach(emittedFile => {
|
||||
if (isDTS(emittedFile.fileName)) {
|
||||
@@ -1246,7 +1241,6 @@ module Harness {
|
||||
|
||||
/** Support class for baseline files */
|
||||
export module Baseline {
|
||||
var firstRun = true;
|
||||
|
||||
export interface BaselineOptions {
|
||||
LineEndingSensitive?: boolean;
|
||||
@@ -1287,8 +1281,7 @@ module Harness {
|
||||
IO.createDirectory(dirName);
|
||||
fileCache[dirName] = true;
|
||||
}
|
||||
var parentDir = IO.directoryName(actualFilename); // .../tests/baselines/local
|
||||
var parentParentDir = IO.directoryName(IO.directoryName(actualFilename)) // .../tests/baselines
|
||||
|
||||
// Create folders if needed
|
||||
createDirectoryStructure(Harness.IO.directoryName(actualFilename));
|
||||
|
||||
|
||||
@@ -175,10 +175,10 @@ module Playback {
|
||||
}
|
||||
|
||||
function findResultByPath<T>(wrapper: { resolvePath(s: string): string }, logArray: { path: string; result?: T }[], expectedPath: string, defaultValue?: T): T {
|
||||
var normalizedName = Harness.Path.switchToForwardSlashes(expectedPath).toLowerCase();
|
||||
var normalizedName = ts.normalizeSlashes(expectedPath).toLowerCase();
|
||||
// Try to find the result through normal filename
|
||||
for (var i = 0; i < logArray.length; i++) {
|
||||
if (Harness.Path.switchToForwardSlashes(logArray[i].path).toLowerCase() === normalizedName) {
|
||||
if (ts.normalizeSlashes(logArray[i].path).toLowerCase() === normalizedName) {
|
||||
return logArray[i].result;
|
||||
}
|
||||
}
|
||||
@@ -203,7 +203,7 @@ module Playback {
|
||||
function pathsAreEquivalent(left: string, right: string, wrapper: { resolvePath(s: string): string }) {
|
||||
var key = left + '-~~-' + right;
|
||||
function areSame(a: string, b: string) {
|
||||
return Harness.Path.switchToForwardSlashes(a).toLowerCase() === Harness.Path.switchToForwardSlashes(b).toLowerCase();
|
||||
return ts.normalizeSlashes(a).toLowerCase() === ts.normalizeSlashes(b).toLowerCase();
|
||||
}
|
||||
function check() {
|
||||
if (Harness.Path.getFileName(left).toLowerCase() === Harness.Path.getFileName(right).toLowerCase()) {
|
||||
|
||||
@@ -23,7 +23,7 @@ module RWC {
|
||||
function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[], clean?: (s: string) => string) {
|
||||
// Collect, test, and sort the filenames
|
||||
function cleanName(fn: string) {
|
||||
var lastSlash = Harness.Path.switchToForwardSlashes(fn).lastIndexOf('/');
|
||||
var lastSlash = ts.normalizeSlashes(fn).lastIndexOf('/');
|
||||
return fn.substr(lastSlash + 1).toLowerCase();
|
||||
}
|
||||
outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName)));
|
||||
@@ -52,7 +52,7 @@ module RWC {
|
||||
var compilerResult: Harness.Compiler.CompilerResult;
|
||||
var compilerOptions: ts.CompilerOptions;
|
||||
var baselineOpts: Harness.Baseline.BaselineOptions = { Subfolder: 'rwc' };
|
||||
var baseName = /(.*)\/(.*).json/.exec(Harness.Path.switchToForwardSlashes(jsonPath))[2];
|
||||
var baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2];
|
||||
// Compile .d.ts files
|
||||
var declFileCompilationResult: {
|
||||
declInputFiles: { unitName: string; content: string }[];
|
||||
@@ -99,7 +99,7 @@ module RWC {
|
||||
}
|
||||
|
||||
ts.forEach(ioLog.filesRead, fileRead => {
|
||||
var resolvedPath = Harness.Path.switchToForwardSlashes(sys.resolvePath(fileRead.path));
|
||||
var resolvedPath = ts.normalizeSlashes(sys.resolvePath(fileRead.path));
|
||||
var inInputList = ts.forEach(inputFiles, inputFile=> inputFile.unitName === resolvedPath);
|
||||
if (!inInputList) {
|
||||
// Add the file to other files
|
||||
@@ -117,7 +117,7 @@ module RWC {
|
||||
});
|
||||
|
||||
function getHarnessCompilerInputUnit(fileName: string) {
|
||||
var resolvedPath = Harness.Path.switchToForwardSlashes(sys.resolvePath(fileName));
|
||||
var resolvedPath = ts.normalizeSlashes(sys.resolvePath(fileName));
|
||||
try {
|
||||
var content = sys.readFile(resolvedPath);
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -484,6 +484,10 @@ declare var Number: {
|
||||
POSITIVE_INFINITY: number;
|
||||
}
|
||||
|
||||
interface TemplateStringsArray extends Array<string> {
|
||||
raw: string[];
|
||||
}
|
||||
|
||||
interface Math {
|
||||
/** The mathematical constant e. This is Euler's number, the base of natural logarithms. */
|
||||
E: number;
|
||||
|
||||
@@ -16,20 +16,6 @@
|
||||
///<reference path='references.ts' />
|
||||
|
||||
module TypeScript {
|
||||
export function stripStartAndEndQuotes(str: string) {
|
||||
var firstCharCode = str && str.charCodeAt(0);
|
||||
if (str && str.length >= 2 && firstCharCode === str.charCodeAt(str.length - 1) && (firstCharCode === CharacterCodes.singleQuote || firstCharCode === CharacterCodes.doubleQuote)) {
|
||||
return str.substring(1, str.length - 1);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
var switchToForwardSlashesRegEx = /\\/g;
|
||||
export function switchToForwardSlashes(path: string) {
|
||||
return path.replace(switchToForwardSlashesRegEx, "/");
|
||||
}
|
||||
|
||||
function isFileOfExtension(fname: string, ext: string) {
|
||||
var invariantFname = fname.toLocaleUpperCase();
|
||||
var invariantExt = ext.toLocaleUpperCase();
|
||||
@@ -40,34 +26,4 @@ module TypeScript {
|
||||
export function isDTSFile(fname: string) {
|
||||
return isFileOfExtension(fname, ".d.ts");
|
||||
}
|
||||
|
||||
export function getPathComponents(path: string) {
|
||||
return path.split("/");
|
||||
}
|
||||
|
||||
var normalizePathRegEx = /^\\\\[^\\]/;
|
||||
export function normalizePath(path: string): string {
|
||||
// If it's a UNC style path (i.e. \\server\share), convert to a URI style (i.e. file://server/share)
|
||||
if (normalizePathRegEx.test(path)) {
|
||||
path = "file:" + path;
|
||||
}
|
||||
var parts = getPathComponents(switchToForwardSlashes(path));
|
||||
var normalizedParts: string[] = [];
|
||||
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
var part = parts[i];
|
||||
if (part === ".") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (normalizedParts.length > 0 && ArrayUtilities.last(normalizedParts) !== ".." && part === "..") {
|
||||
normalizedParts.pop();
|
||||
continue;
|
||||
}
|
||||
|
||||
normalizedParts.push(part);
|
||||
}
|
||||
|
||||
return normalizedParts.join("/");
|
||||
}
|
||||
}
|
||||
@@ -96,11 +96,6 @@ module TypeScript.Services.Formatting {
|
||||
}
|
||||
this.previousTokenParent = this.parent().clone(this.indentationNodeContextPool());
|
||||
position += width(token);
|
||||
|
||||
// Extract any trailing comments
|
||||
if (token.trailingTriviaWidth() !== 0) {
|
||||
this.processTrivia(token.trailingTrivia(), position);
|
||||
}
|
||||
}
|
||||
|
||||
private processTrivia(triviaList: ISyntaxTriviaList, fullStart: number) {
|
||||
@@ -110,7 +105,7 @@ module TypeScript.Services.Formatting {
|
||||
var trivia = triviaList.syntaxTriviaAt(i);
|
||||
// For a comment, format it like it is a token. For skipped text, eat it up as a token, but skip the formatting
|
||||
if (trivia.isComment() || trivia.isSkippedToken()) {
|
||||
var currentTokenSpan = new TokenSpan(trivia.kind(), position, trivia.fullWidth());
|
||||
var currentTokenSpan = new TokenSpan(trivia.kind, position, trivia.fullWidth());
|
||||
if (this.textSpan().containsTextSpan(currentTokenSpan)) {
|
||||
if (trivia.isComment() && this.previousTokenSpan) {
|
||||
// Note that formatPair calls TrimWhitespaceInLineRange in between the 2 tokens
|
||||
|
||||
@@ -109,7 +109,7 @@ module TypeScript.Services.Formatting {
|
||||
var block = <BlockSyntax>node.node();
|
||||
|
||||
// Now check if they are on the same line
|
||||
return this.snapshot.getLineNumberFromPosition(end(block.openBraceToken)) ===
|
||||
return this.snapshot.getLineNumberFromPosition(fullEnd(block.openBraceToken)) ===
|
||||
this.snapshot.getLineNumberFromPosition(start(block.closeBraceToken));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ module TypeScript.Services.Formatting {
|
||||
// Find the outer most parent that this semicolon terminates
|
||||
var current: ISyntaxElement = semicolonPositionedToken;
|
||||
while (current.parent !== null &&
|
||||
end(current.parent) === end(semicolonPositionedToken) &&
|
||||
fullEnd(current.parent) === fullEnd(semicolonPositionedToken) &&
|
||||
current.parent.kind !== SyntaxKind.List) {
|
||||
current = current.parent;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ module TypeScript.Services.Formatting {
|
||||
// Find the outer most parent that this closing brace terminates
|
||||
var current: ISyntaxElement = closeBracePositionedToken;
|
||||
while (current.parent !== null &&
|
||||
end(current.parent) === end(closeBracePositionedToken) &&
|
||||
fullEnd(current.parent) === fullEnd(closeBracePositionedToken) &&
|
||||
current.parent.kind !== SyntaxKind.List) {
|
||||
current = current.parent;
|
||||
}
|
||||
|
||||
@@ -90,8 +90,14 @@ module TypeScript.Services.Formatting {
|
||||
this.visitTokenInSpan(token);
|
||||
|
||||
// Only track new lines on tokens within the range. Make sure to check that the last trivia is a newline, and not just one of the trivia
|
||||
var trivia = token.trailingTrivia();
|
||||
this._lastTriviaWasNewLine = trivia.hasNewLine() && trivia.syntaxTriviaAt(trivia.count() - 1).kind() == SyntaxKind.NewLineTrivia;
|
||||
var _nextToken = nextToken(token);
|
||||
if (_nextToken && _nextToken.hasLeadingTrivia()) {
|
||||
var trivia = _nextToken.leadingTrivia();
|
||||
this._lastTriviaWasNewLine = trivia.hasNewLine();
|
||||
}
|
||||
else {
|
||||
this._lastTriviaWasNewLine = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Update the position
|
||||
@@ -353,7 +359,7 @@ module TypeScript.Services.Formatting {
|
||||
|
||||
private forceRecomputeIndentationOfParent(tokenStart: number, newLineAdded: boolean /*as opposed to removed*/): void {
|
||||
var parent = this._parent;
|
||||
if (parent.fullStart() === tokenStart) {
|
||||
if (start(parent.node()) === tokenStart) {
|
||||
// Temporarily pop the parent before recomputing
|
||||
this._parent = parent.parent();
|
||||
var indentation = this.getNodeIndentation(parent.node(), /* newLineInsertedByFormatting */ newLineAdded);
|
||||
|
||||
@@ -66,14 +66,29 @@ module TypeScript.Services.Formatting {
|
||||
// Process any leading trivia if any
|
||||
var triviaList = token.leadingTrivia();
|
||||
if (triviaList) {
|
||||
var seenNewLine = position === 0;
|
||||
|
||||
for (var i = 0, length = triviaList.count(); i < length; i++, position += trivia.fullWidth()) {
|
||||
var trivia = triviaList.syntaxTriviaAt(i);
|
||||
|
||||
// Skip all trivia up to the first newline we see. We consider this trivia to
|
||||
// 'belong' to the previous token.
|
||||
if (!seenNewLine) {
|
||||
if (trivia.kind !== SyntaxKind.NewLineTrivia) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
seenNewLine = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Skip this trivia if it is not in the span
|
||||
if (!this.textSpan().containsTextSpan(new TextSpan(position, trivia.fullWidth()))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (trivia.kind()) {
|
||||
switch (trivia.kind) {
|
||||
case SyntaxKind.MultiLineCommentTrivia:
|
||||
// We will only indent the first line of the multiline comment if we were planning to indent the next trivia. However,
|
||||
// subsequent lines will always be indented
|
||||
|
||||
@@ -1,110 +1,5 @@
|
||||
|
||||
module TypeScript.Indentation {
|
||||
export function columnForEndOfTokenAtPosition(syntaxTree: SyntaxTree, position: number, options: FormattingOptions): number {
|
||||
var token = findToken(syntaxTree.sourceUnit(), position);
|
||||
return columnForStartOfTokenAtPosition(syntaxTree, position, options) + width(token);
|
||||
}
|
||||
|
||||
export function columnForStartOfTokenAtPosition(syntaxTree: SyntaxTree, position: number, options: FormattingOptions): number {
|
||||
var token = findToken(syntaxTree.sourceUnit(), position);
|
||||
|
||||
// Walk backward from this token until we find the first token in the line. For each token
|
||||
// we see (that is not the first tokem in line), push the entirety of the text into the text
|
||||
// array. Then, for the first token, add its text (without its leading trivia) to the text
|
||||
// array. i.e. if we have:
|
||||
//
|
||||
// var foo = a => bar();
|
||||
//
|
||||
// And we want the column for the start of 'bar', then we'll add the underlinded portions to
|
||||
// the text array:
|
||||
//
|
||||
// var foo = a => bar();
|
||||
// _
|
||||
// __
|
||||
// __
|
||||
// ____
|
||||
// ____
|
||||
var firstTokenInLine = Syntax.firstTokenInLineContainingPosition(syntaxTree, token.fullStart());
|
||||
var leadingTextInReverse: string[] = [];
|
||||
|
||||
var current = token;
|
||||
while (current !== firstTokenInLine) {
|
||||
current = previousToken(current);
|
||||
|
||||
if (current === firstTokenInLine) {
|
||||
// We're at the first token in teh line.
|
||||
// We don't want the leading trivia for this token. That will be taken care of in
|
||||
// columnForFirstNonWhitespaceCharacterInLine. So just push the trailing trivia
|
||||
// and then the token text.
|
||||
leadingTextInReverse.push(current.trailingTrivia().fullText());
|
||||
leadingTextInReverse.push(current.text());
|
||||
}
|
||||
else {
|
||||
// We're at an intermediate token on the line. Just push all its text into the array.
|
||||
leadingTextInReverse.push(current.fullText());
|
||||
}
|
||||
}
|
||||
|
||||
// Now, add all trivia to the start of the line on the first token in the list.
|
||||
collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse);
|
||||
|
||||
return columnForLeadingTextInReverse(leadingTextInReverse, options);
|
||||
}
|
||||
|
||||
export function columnForStartOfFirstTokenInLineContainingPosition(syntaxTree: SyntaxTree, position: number, options: FormattingOptions): number {
|
||||
// Walk backward through the tokens until we find the first one on the line.
|
||||
var firstTokenInLine = Syntax.firstTokenInLineContainingPosition(syntaxTree, position);
|
||||
var leadingTextInReverse: string[] = [];
|
||||
|
||||
// Now, add all trivia to the start of the line on the first token in the list.
|
||||
collectLeadingTriviaTextToStartOfLine(firstTokenInLine, leadingTextInReverse);
|
||||
|
||||
return columnForLeadingTextInReverse(leadingTextInReverse, options);
|
||||
}
|
||||
|
||||
// Collect all the trivia that precedes this token. Stopping when we hit a newline trivia
|
||||
// or a multiline comment that spans multiple lines. This is meant to be called on the first
|
||||
// token in a line.
|
||||
function collectLeadingTriviaTextToStartOfLine(firstTokenInLine: ISyntaxToken,
|
||||
leadingTextInReverse: string[]) {
|
||||
var leadingTrivia = firstTokenInLine.leadingTrivia();
|
||||
|
||||
for (var i = leadingTrivia.count() - 1; i >= 0; i--) {
|
||||
var trivia = leadingTrivia.syntaxTriviaAt(i);
|
||||
if (trivia.kind() === SyntaxKind.NewLineTrivia) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (trivia.kind() === SyntaxKind.MultiLineCommentTrivia) {
|
||||
var lineSegments = Syntax.splitMultiLineCommentTriviaIntoMultipleLines(trivia);
|
||||
leadingTextInReverse.push(ArrayUtilities.last(lineSegments));
|
||||
|
||||
if (lineSegments.length > 0) {
|
||||
// This multiline comment actually spanned multiple lines. So we're done.
|
||||
break;
|
||||
}
|
||||
|
||||
// It was only on a single line, so keep on going.
|
||||
}
|
||||
|
||||
leadingTextInReverse.push(trivia.fullText());
|
||||
}
|
||||
}
|
||||
|
||||
function columnForLeadingTextInReverse(leadingTextInReverse: string[],
|
||||
options: FormattingOptions): number {
|
||||
var column = 0;
|
||||
|
||||
// walk backwards. This means we're actually walking forward from column 0 to the start of
|
||||
// the token.
|
||||
for (var i = leadingTextInReverse.length - 1; i >= 0; i--) {
|
||||
var text = leadingTextInReverse[i];
|
||||
column = columnForPositionInStringWorker(text, text.length, column, options);
|
||||
}
|
||||
|
||||
return column;
|
||||
}
|
||||
|
||||
// Returns the column that this input string ends at (assuming it starts at column 0).
|
||||
export function columnForPositionInString(input: string, position: number, options: FormattingOptions): number {
|
||||
return columnForPositionInStringWorker(input, position, 0, options);
|
||||
|
||||
+36
-45
@@ -144,7 +144,7 @@ module ts {
|
||||
while (pos < end) {
|
||||
var token = scanner.scan();
|
||||
var textPos = scanner.getTextPos();
|
||||
var node = nodes.push(createNode(token, pos, textPos, NodeFlags.Synthetic, this));
|
||||
nodes.push(createNode(token, pos, textPos, NodeFlags.Synthetic, this));
|
||||
pos = textPos;
|
||||
}
|
||||
return pos;
|
||||
@@ -662,8 +662,6 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
var incrementalParse: IncrementalParse = TypeScript.IncrementalParser.parse;
|
||||
|
||||
class SourceFileObject extends NodeObject implements SourceFile {
|
||||
public filename: string;
|
||||
public text: string;
|
||||
@@ -763,10 +761,6 @@ module ts {
|
||||
return this.namedDeclarations;
|
||||
}
|
||||
|
||||
private isDeclareFile(): boolean {
|
||||
return TypeScript.isDTSFile(this.filename);
|
||||
}
|
||||
|
||||
public update(scriptSnapshot: TypeScript.IScriptSnapshot, version: string, isOpen: boolean, textChangeRange: TypeScript.TextChangeRange): SourceFile {
|
||||
if (textChangeRange && Debug.shouldAssert(AssertionLevel.Normal)) {
|
||||
var oldText = this.scriptSnapshot;
|
||||
@@ -1535,7 +1529,7 @@ module ts {
|
||||
var filenames = host.getScriptFileNames();
|
||||
for (var i = 0, n = filenames.length; i < n; i++) {
|
||||
var filename = filenames[i];
|
||||
this.filenameToEntry[switchToForwardSlashes(filename)] = {
|
||||
this.filenameToEntry[normalizeSlashes(filename)] = {
|
||||
filename: filename,
|
||||
version: host.getScriptVersion(filename),
|
||||
isOpen: host.getScriptIsOpen(filename)
|
||||
@@ -1550,7 +1544,7 @@ module ts {
|
||||
}
|
||||
|
||||
public getEntry(filename: string): HostFileInformation {
|
||||
filename = switchToForwardSlashes(filename);
|
||||
filename = normalizeSlashes(filename);
|
||||
return lookUp(this.filenameToEntry, filename);
|
||||
}
|
||||
|
||||
@@ -2328,7 +2322,7 @@ module ts {
|
||||
function getSyntacticDiagnostics(filename: string) {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = switchToForwardSlashes(filename);
|
||||
filename = normalizeSlashes(filename);
|
||||
|
||||
return program.getDiagnostics(getSourceFile(filename).getSourceFile());
|
||||
}
|
||||
@@ -2340,7 +2334,7 @@ module ts {
|
||||
function getSemanticDiagnostics(filename: string) {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = switchToForwardSlashes(filename)
|
||||
filename = normalizeSlashes(filename)
|
||||
var compilerOptions = program.getCompilerOptions();
|
||||
var checker = getFullTypeCheckChecker();
|
||||
var targetSourceFile = getSourceFile(filename);
|
||||
@@ -2391,7 +2385,7 @@ module ts {
|
||||
|
||||
|
||||
if (isValid) {
|
||||
return displayName;
|
||||
return unescapeIdentifier(displayName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2421,7 +2415,7 @@ module ts {
|
||||
function getCompletionsAtPosition(filename: string, position: number, isMemberCompletion: boolean) {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = switchToForwardSlashes(filename);
|
||||
filename = normalizeSlashes(filename);
|
||||
|
||||
var syntacticStart = new Date().getTime();
|
||||
var sourceFile = getSourceFile(filename);
|
||||
@@ -2567,12 +2561,15 @@ module ts {
|
||||
var start = new Date().getTime();
|
||||
forEach(symbols, symbol => {
|
||||
var entry = createCompletionEntry(symbol, session.typeChecker, location);
|
||||
if (entry && !lookUp(session.symbols, entry.name)) {
|
||||
session.entries.push(entry);
|
||||
session.symbols[entry.name] = symbol;
|
||||
if (entry) {
|
||||
var id = escapeIdentifier(entry.name);
|
||||
if (!lookUp(session.symbols, id)) {
|
||||
session.entries.push(entry);
|
||||
session.symbols[id] = symbol;
|
||||
}
|
||||
}
|
||||
});
|
||||
host.log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - semanticStart));
|
||||
host.log("getCompletionsAtPosition: getCompletionEntriesFromSymbols: " + (new Date().getTime() - start));
|
||||
}
|
||||
|
||||
function isCompletionListBlocker(previousToken: Node): boolean {
|
||||
@@ -2580,7 +2577,7 @@ module ts {
|
||||
var result = isInStringOrRegularExpressionOrTemplateLiteral(previousToken) ||
|
||||
isIdentifierDefinitionLocation(previousToken) ||
|
||||
isRightOfIllegalDot(previousToken);
|
||||
host.log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - semanticStart));
|
||||
host.log("getCompletionsAtPosition: isCompletionListBlocker: " + (new Date().getTime() - start));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2766,7 +2763,7 @@ module ts {
|
||||
function getCompletionEntryDetails(filename: string, position: number, entryName: string): CompletionEntryDetails {
|
||||
// Note: No need to call synchronizeHostData, as we have captured all the data we need
|
||||
// in the getCompletionsAtPosition earlier
|
||||
filename = switchToForwardSlashes(filename);
|
||||
filename = normalizeSlashes(filename);
|
||||
|
||||
var sourceFile = getSourceFile(filename);
|
||||
|
||||
@@ -2777,7 +2774,7 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var symbol = lookUp(activeCompletionSession.symbols, entryName);
|
||||
var symbol = lookUp(activeCompletionSession.symbols, escapeIdentifier(entryName));
|
||||
if (symbol) {
|
||||
var location = getTouchingPropertyName(sourceFile, position);
|
||||
var completionEntry = createCompletionEntry(symbol, session.typeChecker, location);
|
||||
@@ -3266,7 +3263,7 @@ module ts {
|
||||
function getQuickInfoAtPosition(fileName: string, position: number): QuickInfo {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getSourceFile(fileName);
|
||||
var node = getTouchingPropertyName(sourceFile, position);
|
||||
if (!node) {
|
||||
@@ -3368,7 +3365,7 @@ module ts {
|
||||
|
||||
synchronizeHostData();
|
||||
|
||||
filename = switchToForwardSlashes(filename);
|
||||
filename = normalizeSlashes(filename);
|
||||
var sourceFile = getSourceFile(filename);
|
||||
|
||||
var node = getTouchingPropertyName(sourceFile, position);
|
||||
@@ -3432,7 +3429,7 @@ module ts {
|
||||
function getOccurrencesAtPosition(filename: string, position: number): ReferenceEntry[] {
|
||||
synchronizeHostData();
|
||||
|
||||
filename = switchToForwardSlashes(filename);
|
||||
filename = normalizeSlashes(filename);
|
||||
var sourceFile = getSourceFile(filename);
|
||||
|
||||
var node = getTouchingWord(sourceFile, position);
|
||||
@@ -3739,9 +3736,6 @@ module ts {
|
||||
|
||||
pushKeywordIf(keywords, switchStatement.getFirstToken(), SyntaxKind.SwitchKeyword);
|
||||
|
||||
// Types of break statements we can grab on to.
|
||||
var breakSearchType = BreakContinueSearchType.All;
|
||||
|
||||
// Go through each clause in the switch statement, collecting the 'case'/'default' keywords.
|
||||
forEach(switchStatement.clauses, clause => {
|
||||
pushKeywordIf(keywords, clause.getFirstToken(), SyntaxKind.CaseKeyword, SyntaxKind.DefaultKeyword);
|
||||
@@ -3953,7 +3947,7 @@ module ts {
|
||||
function findReferences(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): ReferenceEntry[] {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getSourceFile(fileName);
|
||||
|
||||
var node = getTouchingPropertyName(sourceFile, position);
|
||||
@@ -4674,12 +4668,11 @@ module ts {
|
||||
|
||||
function getEmitOutput(filename: string): EmitOutput {
|
||||
synchronizeHostData();
|
||||
filename = switchToForwardSlashes(filename);
|
||||
filename = normalizeSlashes(filename);
|
||||
var compilerOptions = program.getCompilerOptions();
|
||||
var targetSourceFile = program.getSourceFile(filename); // Current selected file to be output
|
||||
// If --out flag is not specified, shouldEmitToOwnFile is true. Otherwise shouldEmitToOwnFile is false.
|
||||
var shouldEmitToOwnFile = ts.shouldEmitToOwnFile(targetSourceFile, compilerOptions);
|
||||
var emitDeclaration = compilerOptions.declaration;
|
||||
var emitOutput: EmitOutput = {
|
||||
outputFiles: [],
|
||||
emitOutputStatus: undefined,
|
||||
@@ -4696,7 +4689,6 @@ module ts {
|
||||
// Initialize writer for CompilerHost.writeFile
|
||||
writer = getEmitOutputWriter;
|
||||
|
||||
var syntacticDiagnostics: Diagnostic[] = [];
|
||||
var containSyntacticErrors = false;
|
||||
|
||||
if (shouldEmitToOwnFile) {
|
||||
@@ -4850,7 +4842,7 @@ module ts {
|
||||
function getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getSourceFile(fileName);
|
||||
|
||||
return SignatureHelp.getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken);
|
||||
@@ -4881,7 +4873,7 @@ module ts {
|
||||
|
||||
var start = signatureInfoString.length;
|
||||
signatureInfoString += displayPartsToString(parameter.displayParts);
|
||||
var end = signatureInfoString.length - 1;
|
||||
var end = signatureInfoString.length;
|
||||
|
||||
// add the parameter to the list
|
||||
parameters.push({
|
||||
@@ -4920,12 +4912,12 @@ module ts {
|
||||
|
||||
/// Syntactic features
|
||||
function getSyntaxTree(filename: string): TypeScript.SyntaxTree {
|
||||
filename = switchToForwardSlashes(filename);
|
||||
filename = normalizeSlashes(filename);
|
||||
return syntaxTreeCache.getCurrentFileSyntaxTree(filename);
|
||||
}
|
||||
|
||||
function getCurrentSourceFile(filename: string): SourceFile {
|
||||
filename = switchToForwardSlashes(filename);
|
||||
filename = normalizeSlashes(filename);
|
||||
var currentSourceFile = syntaxTreeCache.getCurrentSourceFile(filename);
|
||||
return currentSourceFile;
|
||||
}
|
||||
@@ -4992,14 +4984,14 @@ module ts {
|
||||
}
|
||||
|
||||
function getNavigationBarItems(filename: string): NavigationBarItem[] {
|
||||
filename = switchToForwardSlashes(filename);
|
||||
filename = normalizeSlashes(filename);
|
||||
|
||||
return NavigationBar.getNavigationBarItems(getCurrentSourceFile(filename));
|
||||
}
|
||||
|
||||
function getSemanticClassifications(fileName: string, span: TypeScript.TextSpan): ClassifiedSpan[] {
|
||||
synchronizeHostData();
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var sourceFile = getSourceFile(fileName);
|
||||
|
||||
@@ -5070,7 +5062,7 @@ module ts {
|
||||
|
||||
function getSyntacticClassifications(fileName: string, span: TypeScript.TextSpan): ClassifiedSpan[] {
|
||||
// doesn't use compiler - no need to synchronize with host
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getCurrentSourceFile(fileName);
|
||||
|
||||
var result: ClassifiedSpan[] = [];
|
||||
@@ -5200,7 +5192,7 @@ module ts {
|
||||
|
||||
function getOutliningSpans(filename: string): OutliningSpan[] {
|
||||
// doesn't use compiler - no need to synchronize with host
|
||||
filename = switchToForwardSlashes(filename);
|
||||
filename = normalizeSlashes(filename);
|
||||
var sourceFile = getCurrentSourceFile(filename);
|
||||
return OutliningElementsCollector.collectElements(sourceFile);
|
||||
}
|
||||
@@ -5259,7 +5251,7 @@ module ts {
|
||||
}
|
||||
|
||||
function getIndentationAtPosition(filename: string, position: number, editorOptions: EditorOptions) {
|
||||
filename = switchToForwardSlashes(filename);
|
||||
filename = normalizeSlashes(filename);
|
||||
|
||||
var start = new Date().getTime();
|
||||
var sourceFile = getCurrentSourceFile(filename);
|
||||
@@ -5296,21 +5288,21 @@ module ts {
|
||||
}
|
||||
|
||||
function getFormattingEditsForRange(fileName: string, start: number, end: number, options: FormatCodeOptions): TextChange[] {
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var manager = getFormattingManager(fileName, options);
|
||||
return manager.formatSelection(start, end);
|
||||
}
|
||||
|
||||
function getFormattingEditsForDocument(fileName: string, options: FormatCodeOptions): TextChange[] {
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var manager = getFormattingManager(fileName, options);
|
||||
return manager.formatDocument();
|
||||
}
|
||||
|
||||
function getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions): TextChange[] {
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
|
||||
var manager = getFormattingManager(fileName, options);
|
||||
|
||||
@@ -5336,7 +5328,7 @@ module ts {
|
||||
// anything away.
|
||||
synchronizeHostData();
|
||||
|
||||
filename = TypeScript.switchToForwardSlashes(filename);
|
||||
filename = normalizeSlashes(filename);
|
||||
|
||||
var sourceFile = getSourceFile(filename);
|
||||
|
||||
@@ -5496,7 +5488,7 @@ module ts {
|
||||
function getRenameInfo(fileName: string, position: number): RenameInfo {
|
||||
synchronizeHostData();
|
||||
|
||||
fileName = switchToForwardSlashes(fileName);
|
||||
fileName = normalizeSlashes(fileName);
|
||||
var sourceFile = getSourceFile(fileName);
|
||||
|
||||
var node = getTouchingWord(sourceFile, position);
|
||||
@@ -5635,7 +5627,6 @@ module ts {
|
||||
|
||||
function getClassificationsForLine(text: string, lexState: EndOfLineState): ClassificationResult {
|
||||
var offset = 0;
|
||||
var lastTokenOrCommentEnd = 0;
|
||||
var token = SyntaxKind.Unknown;
|
||||
var lastNonTriviaToken = SyntaxKind.Unknown;
|
||||
|
||||
|
||||
@@ -858,7 +858,7 @@ module ts {
|
||||
|
||||
forEach(result.referencedFiles, refFile => {
|
||||
convertResult.referencedFiles.push({
|
||||
path: switchToForwardSlashes(normalizePath(refFile.filename)),
|
||||
path: normalizePath(refFile.filename),
|
||||
position: refFile.pos,
|
||||
length: refFile.end - refFile.pos
|
||||
});
|
||||
@@ -866,7 +866,7 @@ module ts {
|
||||
|
||||
forEach(result.importedFiles, importedFile => {
|
||||
convertResult.importedFiles.push({
|
||||
path: switchToForwardSlashes(importedFile.filename),
|
||||
path: normalizeSlashes(importedFile.filename),
|
||||
position: importedFile.pos,
|
||||
length: importedFile.end - importedFile.pos
|
||||
});
|
||||
|
||||
@@ -998,8 +998,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
{ name: 'moduleKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'name', type: 'INameSyntax', isOptional: true },
|
||||
{ name: 'stringLiteral', isToken: true, isOptional: true, tokenKinds: ['StringLiteral'] },
|
||||
{ name: 'name', type: 'INameSyntax' },
|
||||
{ name: 'openBraceToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'moduleElements', isList: true, elementType: 'IModuleElementSyntax' },
|
||||
{ name: 'closeBraceToken', isToken: true, excludeFromAST: true }
|
||||
@@ -1015,8 +1014,7 @@ var definitions = [
|
||||
{ name: 'functionKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
{ name: 'block', type: 'BlockSyntax', isOptional: true },
|
||||
{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
{ name: 'body', type: 'BlockSyntax | ISyntaxToken', isOptional: true }
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1096,8 +1094,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'parameter', type: 'ParameterSyntax' },
|
||||
{ name: 'equalsGreaterThanToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'block', type: 'BlockSyntax', isOptional: true },
|
||||
{ name: 'expression', type: 'IExpressionSyntax', isOptional: true }
|
||||
{ name: 'body', type: 'BlockSyntax | IExpressionSyntax' }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
},
|
||||
@@ -1108,8 +1105,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
{ name: 'equalsGreaterThanToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'block', type: 'BlockSyntax', isOptional: true },
|
||||
{ name: 'expression', type: 'IExpressionSyntax', isOptional: true }
|
||||
{ name: 'body', type: 'BlockSyntax | IExpressionSyntax' }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
},
|
||||
@@ -1490,8 +1486,7 @@ var definitions = [
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
{ name: 'constructorKeyword', isToken: true },
|
||||
{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
{ name: 'block', type: 'BlockSyntax', isOptional: true },
|
||||
{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
{ name: 'body', type: 'BlockSyntax | ISyntaxToken', isOptional: true }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
},
|
||||
@@ -1503,8 +1498,7 @@ var definitions = [
|
||||
{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
{ name: 'block', type: 'BlockSyntax', isOptional: true },
|
||||
{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
{ name: 'body', type: 'BlockSyntax | ISyntaxToken', isOptional: true }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
},
|
||||
@@ -1647,8 +1641,7 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'forKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'openParenToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'variableDeclaration', type: 'VariableDeclarationSyntax', isOptional: true },
|
||||
{ name: 'initializer', type: 'IExpressionSyntax', isOptional: true },
|
||||
{ name: 'initializer', type: 'VariableDeclarationSyntax | IExpressionSyntax', isOptional: true },
|
||||
{ name: 'firstSemicolonToken', isToken: true, tokenKinds: ['SemicolonToken'], excludeFromAST: true },
|
||||
{ name: 'condition', type: 'IExpressionSyntax', isOptional: true },
|
||||
{ name: 'secondSemicolonToken', isToken: true, tokenKinds: ['SemicolonToken'], excludeFromAST: true },
|
||||
@@ -1664,10 +1657,9 @@ var definitions = [
|
||||
children: [
|
||||
{ name: 'forKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'openParenToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'variableDeclaration', type: 'VariableDeclarationSyntax', isOptional: true },
|
||||
{ name: 'left', type: 'IExpressionSyntax', isOptional: true },
|
||||
{ name: 'left', type: 'VariableDeclarationSyntax | IExpressionSyntax' },
|
||||
{ name: 'inKeyword', isToken: true, excludeFromAST: true },
|
||||
{ name: 'expression', type: 'IExpressionSyntax' },
|
||||
{ name: 'right', type: 'IExpressionSyntax' },
|
||||
{ name: 'closeParenToken', isToken: true, excludeFromAST: true },
|
||||
{ name: 'statement', type: 'IStatementSyntax' }
|
||||
]
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -15,12 +15,13 @@ module TypeScript {
|
||||
// only be used by the incremental parser if it is parsed in the same strict context as before.
|
||||
// last masks off the part of the int
|
||||
//
|
||||
// The width of the node is stored in the remainder of the int. This allows us up to 512MB
|
||||
// for a node by using all 29 bits. However, in the common case, we'll use less than 29 bits
|
||||
// The width of the node is stored in the remainder of the int. This allows us up to 256MB
|
||||
// for a node by using all 28 bits. However, in the common case, we'll use less than 28 bits
|
||||
// for the width. Thus, the info will be stored in a single int in chakra.
|
||||
NodeDataComputed = 0x00000001, // 0000 0000 0000 0000 0000 0000 0000 0001
|
||||
NodeIncrementallyUnusableMask = 0x00000002, // 0000 0000 0000 0000 0000 0000 0000 0010
|
||||
NodeParsedInStrictModeMask = 0x00000004, // 0000 0000 0000 0000 0000 0000 0000 0100
|
||||
NodeFullWidthShift = 3, // 1111 1111 1111 1111 1111 1111 1111 1000
|
||||
NodeParsedInDisallowInMask = 0x00000008, // 0000 0000 0000 0000 0000 0000 0000 1000
|
||||
NodeFullWidthShift = 4, // 1111 1111 1111 1111 1111 1111 1111 0000
|
||||
}
|
||||
}
|
||||
@@ -529,6 +529,8 @@ module TypeScript.IncrementalParser {
|
||||
}
|
||||
|
||||
function consumeToken(currentToken: ISyntaxToken): void {
|
||||
// Debug.assert(currentToken.fullWidth() > 0 || currentToken.kind === SyntaxKind.EndOfFileToken);
|
||||
|
||||
// This token may have come from the old source unit, or from the new text. Handle
|
||||
// both accordingly.
|
||||
|
||||
|
||||
+623
-819
File diff suppressed because it is too large
Load Diff
@@ -305,9 +305,6 @@ module TypeScript.PrettyPrinter {
|
||||
this.ensureSpace();
|
||||
this.appendElement(node.name);
|
||||
this.ensureSpace();
|
||||
this.appendToken(node.stringLiteral);
|
||||
this.ensureSpace();
|
||||
|
||||
this.appendToken(node.openBraceToken);
|
||||
this.ensureNewLine();
|
||||
|
||||
@@ -319,13 +316,13 @@ module TypeScript.PrettyPrinter {
|
||||
this.appendToken(node.closeBraceToken);
|
||||
}
|
||||
|
||||
private appendBlockOrSemicolon(block: BlockSyntax, semicolonToken: ISyntaxToken) {
|
||||
if (block) {
|
||||
private appendBlockOrSemicolon(body: BlockSyntax | ISyntaxToken) {
|
||||
if (body.kind === SyntaxKind.Block) {
|
||||
this.ensureSpace();
|
||||
visitNodeOrToken(this, block);
|
||||
visitNodeOrToken(this, body);
|
||||
}
|
||||
else {
|
||||
this.appendToken(semicolonToken);
|
||||
this.appendToken(<ISyntaxToken>body);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -336,7 +333,7 @@ module TypeScript.PrettyPrinter {
|
||||
this.ensureSpace();
|
||||
this.appendToken(node.identifier);
|
||||
this.appendNode(node.callSignature);
|
||||
this.appendBlockOrSemicolon(node.block, node.semicolonToken);
|
||||
this.appendBlockOrSemicolon(node.body);
|
||||
}
|
||||
|
||||
public visitVariableStatement(node: VariableStatementSyntax): void {
|
||||
@@ -390,8 +387,7 @@ module TypeScript.PrettyPrinter {
|
||||
this.ensureSpace();
|
||||
this.appendToken(node.equalsGreaterThanToken);
|
||||
this.ensureSpace();
|
||||
this.appendNode(node.block);
|
||||
this.appendElement(node.expression);
|
||||
visitNodeOrToken(this, node.body);
|
||||
}
|
||||
|
||||
public visitParenthesizedArrowFunctionExpression(node: ParenthesizedArrowFunctionExpressionSyntax): void {
|
||||
@@ -399,8 +395,7 @@ module TypeScript.PrettyPrinter {
|
||||
this.ensureSpace();
|
||||
this.appendToken(node.equalsGreaterThanToken);
|
||||
this.ensureSpace();
|
||||
this.appendNode(node.block);
|
||||
this.appendElement(node.expression);
|
||||
visitNodeOrToken(this, node.body);
|
||||
}
|
||||
|
||||
public visitQualifiedName(node: QualifiedNameSyntax): void {
|
||||
@@ -671,7 +666,7 @@ module TypeScript.PrettyPrinter {
|
||||
public visitConstructorDeclaration(node: ConstructorDeclarationSyntax): void {
|
||||
this.appendToken(node.constructorKeyword);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
this.appendBlockOrSemicolon(node.block, node.semicolonToken);
|
||||
this.appendBlockOrSemicolon(node.body);
|
||||
}
|
||||
|
||||
public visitIndexMemberDeclaration(node: IndexMemberDeclarationSyntax): void {
|
||||
@@ -686,7 +681,7 @@ module TypeScript.PrettyPrinter {
|
||||
this.ensureSpace();
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
this.appendBlockOrSemicolon(node.block, node.semicolonToken);
|
||||
this.appendBlockOrSemicolon(node.body);
|
||||
}
|
||||
|
||||
public visitGetAccessor(node: GetAccessorSyntax): void {
|
||||
@@ -825,8 +820,7 @@ module TypeScript.PrettyPrinter {
|
||||
this.appendToken(node.forKeyword);
|
||||
this.ensureSpace();
|
||||
this.appendToken(node.openParenToken);
|
||||
this.appendNode(node.variableDeclaration);
|
||||
this.appendElement(node.initializer);
|
||||
visitNodeOrToken(this, node.initializer);
|
||||
this.appendToken(node.firstSemicolonToken);
|
||||
|
||||
if (node.condition) {
|
||||
@@ -849,12 +843,11 @@ module TypeScript.PrettyPrinter {
|
||||
this.appendToken(node.forKeyword);
|
||||
this.ensureSpace();
|
||||
this.appendToken(node.openParenToken);
|
||||
this.appendNode(node.variableDeclaration);
|
||||
this.appendElement(node.left);
|
||||
this.ensureSpace();
|
||||
this.appendToken(node.inKeyword);
|
||||
this.ensureSpace();
|
||||
this.appendElement(node.expression);
|
||||
this.appendElement(node.right);
|
||||
this.appendToken(node.closeParenToken);
|
||||
this.appendBlockOrStatement(node.statement);
|
||||
}
|
||||
|
||||
+49
-105
@@ -60,8 +60,7 @@ module TypeScript.Scanner {
|
||||
// This gives us 23bit for width (or 8MB of width which should be enough for any codebase).
|
||||
|
||||
enum ScannerConstants {
|
||||
LargeTokenFullWidthShift = 6,
|
||||
LargeTokenLeadingTriviaShift = 3,
|
||||
LargeTokenFullWidthShift = 3,
|
||||
|
||||
WhitespaceTrivia = 0x01, // 00000001
|
||||
NewlineTrivia = 0x02, // 00000010
|
||||
@@ -72,8 +71,8 @@ module TypeScript.Scanner {
|
||||
IsVariableWidthMask = 0x80, // 10000000
|
||||
}
|
||||
|
||||
function largeTokenPackData(fullWidth: number, leadingTriviaInfo: number, trailingTriviaInfo: number) {
|
||||
return (fullWidth << ScannerConstants.LargeTokenFullWidthShift) | (leadingTriviaInfo << ScannerConstants.LargeTokenLeadingTriviaShift) | trailingTriviaInfo;
|
||||
function largeTokenPackData(fullWidth: number, leadingTriviaInfo: number) {
|
||||
return (fullWidth << ScannerConstants.LargeTokenFullWidthShift) | leadingTriviaInfo;
|
||||
}
|
||||
|
||||
function largeTokenUnpackFullWidth(packedFullWidthAndInfo: number): number {
|
||||
@@ -81,10 +80,6 @@ module TypeScript.Scanner {
|
||||
}
|
||||
|
||||
function largeTokenUnpackLeadingTriviaInfo(packedFullWidthAndInfo: number): number {
|
||||
return (packedFullWidthAndInfo >> ScannerConstants.LargeTokenLeadingTriviaShift) & ScannerConstants.TriviaMask;
|
||||
}
|
||||
|
||||
function largeTokenUnpackTrailingTriviaInfo(packedFullWidthAndInfo: number): number {
|
||||
return packedFullWidthAndInfo & ScannerConstants.TriviaMask;
|
||||
}
|
||||
|
||||
@@ -92,20 +87,20 @@ module TypeScript.Scanner {
|
||||
return largeTokenUnpackLeadingTriviaInfo(packed) !== 0;
|
||||
}
|
||||
|
||||
function largeTokenUnpackHasTrailingTrivia(packed: number): boolean {
|
||||
return largeTokenUnpackTrailingTriviaInfo(packed) !== 0;
|
||||
}
|
||||
|
||||
function hasComment(info: number) {
|
||||
return (info & ScannerConstants.CommentTrivia) !== 0;
|
||||
}
|
||||
|
||||
function largeTokenUnpackHasLeadingComment(packed: number): boolean {
|
||||
return hasComment(largeTokenUnpackLeadingTriviaInfo(packed));
|
||||
function hasNewLine(info: number) {
|
||||
return (info & ScannerConstants.NewlineTrivia) !== 0;
|
||||
}
|
||||
|
||||
function largeTokenUnpackHasTrailingComment(packed: number): boolean {
|
||||
return hasComment(largeTokenUnpackTrailingTriviaInfo(packed));
|
||||
function largeTokenUnpackHasLeadingNewLine(packed: number): boolean {
|
||||
return hasNewLine(largeTokenUnpackLeadingTriviaInfo(packed));
|
||||
}
|
||||
|
||||
function largeTokenUnpackHasLeadingComment(packed: number): boolean {
|
||||
return hasComment(largeTokenUnpackLeadingTriviaInfo(packed));
|
||||
}
|
||||
|
||||
var isKeywordStartCharacter: number[] = ArrayUtilities.createArray<number>(CharacterCodes.maxAsciiCharacter, 0);
|
||||
@@ -156,7 +151,7 @@ module TypeScript.Scanner {
|
||||
}
|
||||
}
|
||||
|
||||
var lastTokenInfo = { leadingTriviaWidth: -1, width: -1 };
|
||||
var lastTokenInfo = { leadingTriviaWidth: -1 };
|
||||
var lastTokenInfoTokenID: number = -1;
|
||||
|
||||
var triviaScanner = createScannerInternal(ts.ScriptTarget.Latest, SimpleText.fromString(""), () => { });
|
||||
@@ -180,15 +175,7 @@ module TypeScript.Scanner {
|
||||
return Syntax.emptyTriviaList;
|
||||
}
|
||||
|
||||
return triviaScanner.scanTrivia(token, text, /*isTrailing:*/ false);
|
||||
}
|
||||
|
||||
function trailingTrivia(token: IScannerToken, text: ISimpleText): ISyntaxTriviaList {
|
||||
if (!token.hasTrailingTrivia()) {
|
||||
return Syntax.emptyTriviaList;
|
||||
}
|
||||
|
||||
return triviaScanner.scanTrivia(token, text, /*isTrailing:*/ true);
|
||||
return triviaScanner.scanTrivia(token, text);
|
||||
}
|
||||
|
||||
function leadingTriviaWidth(token: IScannerToken, text: ISimpleText): number {
|
||||
@@ -200,15 +187,6 @@ module TypeScript.Scanner {
|
||||
return lastTokenInfo.leadingTriviaWidth;
|
||||
}
|
||||
|
||||
function trailingTriviaWidth(token: IScannerToken, text: ISimpleText): number {
|
||||
if (!token.hasTrailingTrivia()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
fillSizeInfo(token, text);
|
||||
return token.fullWidth() - lastTokenInfo.leadingTriviaWidth - lastTokenInfo.width;
|
||||
}
|
||||
|
||||
function tokenIsIncrementallyUnusable(token: IScannerToken): boolean {
|
||||
// No scanner tokens make their *containing node* incrementally unusable.
|
||||
// Note: several scanner tokens may themselves be unusable. i.e. if the parser asks
|
||||
@@ -231,24 +209,21 @@ module TypeScript.Scanner {
|
||||
}
|
||||
|
||||
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
|
||||
public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) }
|
||||
|
||||
public isIncrementallyUnusable(): boolean { return false; }
|
||||
public isKeywordConvertedToIdentifier(): boolean { return false; }
|
||||
public hasSkippedToken(): boolean { return false; }
|
||||
public fullText(): string { return SyntaxFacts.getText(this.kind); }
|
||||
public text(): string { return this.fullText(); }
|
||||
public leadingTrivia(): ISyntaxTriviaList { return Syntax.emptyTriviaList; }
|
||||
public trailingTrivia(): ISyntaxTriviaList { return Syntax.emptyTriviaList; }
|
||||
public leadingTriviaWidth(): number { return 0; }
|
||||
public trailingTriviaWidth(): number { return 0; }
|
||||
|
||||
public fullWidth(): number { return fixedWidthTokenLength(this.kind); }
|
||||
public fullStart(): number { return this._fullStart; }
|
||||
public hasLeadingTrivia(): boolean { return false; }
|
||||
public hasTrailingTrivia(): boolean { return false; }
|
||||
public hasLeadingNewLine(): boolean { return false; }
|
||||
public hasLeadingSkippedToken(): boolean { return false; }
|
||||
public hasLeadingComment(): boolean { return false; }
|
||||
public hasTrailingComment(): boolean { return false; }
|
||||
|
||||
public clone(): ISyntaxToken { return new FixedWidthTokenWithNoTrivia(this._fullStart, this.kind); }
|
||||
}
|
||||
FixedWidthTokenWithNoTrivia.prototype.childCount = 0;
|
||||
@@ -271,7 +246,6 @@ module TypeScript.Scanner {
|
||||
}
|
||||
|
||||
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
|
||||
public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) }
|
||||
|
||||
private syntaxTreeText(text: ISimpleText) {
|
||||
var result = text || syntaxTree(this).text;
|
||||
@@ -281,7 +255,6 @@ module TypeScript.Scanner {
|
||||
|
||||
public isIncrementallyUnusable(): boolean { return tokenIsIncrementallyUnusable(this); }
|
||||
public isKeywordConvertedToIdentifier(): boolean { return false; }
|
||||
public hasSkippedToken(): boolean { return false; }
|
||||
|
||||
public fullText(text?: ISimpleText): string {
|
||||
return fullText(this, this.syntaxTreeText(text));
|
||||
@@ -293,22 +266,16 @@ module TypeScript.Scanner {
|
||||
}
|
||||
|
||||
public leadingTrivia(text?: ISimpleText): ISyntaxTriviaList { return leadingTrivia(this, this.syntaxTreeText(text)); }
|
||||
public trailingTrivia(text?: ISimpleText): ISyntaxTriviaList { return trailingTrivia(this, this.syntaxTreeText(text)); }
|
||||
|
||||
public leadingTriviaWidth(text?: ISimpleText): number {
|
||||
return leadingTriviaWidth(this, this.syntaxTreeText(text));
|
||||
}
|
||||
|
||||
public trailingTriviaWidth(text?: ISimpleText): number {
|
||||
return trailingTriviaWidth(this, this.syntaxTreeText(text));
|
||||
}
|
||||
public leadingTriviaWidth(text?: ISimpleText): number { return leadingTriviaWidth(this, this.syntaxTreeText(text)); }
|
||||
|
||||
public fullWidth(): number { return largeTokenUnpackFullWidth(this._packedFullWidthAndInfo); }
|
||||
public fullStart(): number { return this._fullStart; }
|
||||
|
||||
public hasLeadingTrivia(): boolean { return largeTokenUnpackHasLeadingTrivia(this._packedFullWidthAndInfo); }
|
||||
public hasTrailingTrivia(): boolean { return largeTokenUnpackHasTrailingTrivia(this._packedFullWidthAndInfo); }
|
||||
public hasLeadingNewLine(): boolean { return largeTokenUnpackHasLeadingNewLine(this._packedFullWidthAndInfo); }
|
||||
public hasLeadingComment(): boolean { return largeTokenUnpackHasLeadingComment(this._packedFullWidthAndInfo); }
|
||||
public hasTrailingComment(): boolean { return largeTokenUnpackHasTrailingComment(this._packedFullWidthAndInfo); }
|
||||
public hasLeadingSkippedToken(): boolean { return false; }
|
||||
|
||||
public clone(): ISyntaxToken { return new LargeScannerToken(this._fullStart, this.kind, this._packedFullWidthAndInfo, this.cachedText); }
|
||||
}
|
||||
LargeScannerToken.prototype.childCount = 0;
|
||||
@@ -319,12 +286,11 @@ module TypeScript.Scanner {
|
||||
|
||||
interface TokenInfo {
|
||||
leadingTriviaWidth: number;
|
||||
width: number;
|
||||
}
|
||||
|
||||
interface IScannerInternal extends IScanner {
|
||||
fillTokenInfo(token: IScannerToken, text: ISimpleText, tokenInfo: TokenInfo): void;
|
||||
scanTrivia(token: IScannerToken, text: ISimpleText, isTrailing: boolean): ISyntaxTriviaList;
|
||||
scanTrivia(token: IScannerToken, text: ISimpleText): ISyntaxTriviaList;
|
||||
}
|
||||
|
||||
export interface IScanner {
|
||||
@@ -367,15 +333,13 @@ module TypeScript.Scanner {
|
||||
|
||||
function scan(allowContextualToken: boolean): ISyntaxToken {
|
||||
var fullStart = index;
|
||||
var leadingTriviaInfo = scanTriviaInfo(/*isTrailing: */ false);
|
||||
var leadingTriviaInfo = scanTriviaInfo();
|
||||
|
||||
var start = index;
|
||||
var kindAndIsVariableWidth = scanSyntaxKind(allowContextualToken);
|
||||
|
||||
var end = index;
|
||||
var trailingTriviaInfo = scanTriviaInfo(/*isTrailing: */true);
|
||||
|
||||
var fullWidth = index - fullStart;
|
||||
var fullEnd = index;
|
||||
var fullWidth = fullEnd - fullStart;
|
||||
|
||||
// If we have no trivia, and we are a fixed width token kind, and our size isn't too
|
||||
// large, and we're a real fixed width token (and not something like "\u0076ar").
|
||||
@@ -383,28 +347,21 @@ module TypeScript.Scanner {
|
||||
var isFixedWidth = kind >= SyntaxKind.FirstFixedWidth && kind <= SyntaxKind.LastFixedWidth &&
|
||||
((kindAndIsVariableWidth & ScannerConstants.IsVariableWidthMask) === 0);
|
||||
|
||||
if (isFixedWidth &&
|
||||
leadingTriviaInfo === 0 && trailingTriviaInfo === 0) {
|
||||
|
||||
if (isFixedWidth && leadingTriviaInfo === 0) {
|
||||
return new FixedWidthTokenWithNoTrivia(fullStart, kind);
|
||||
}
|
||||
else {
|
||||
var packedFullWidthAndInfo = largeTokenPackData(fullWidth, leadingTriviaInfo, trailingTriviaInfo);
|
||||
var cachedText = isFixedWidth ? undefined : text.substr(start, end - start);
|
||||
var packedFullWidthAndInfo = largeTokenPackData(fullWidth, leadingTriviaInfo);
|
||||
var cachedText = isFixedWidth ? undefined : text.substr(start, fullEnd - start);
|
||||
return new LargeScannerToken(fullStart, kind, packedFullWidthAndInfo, cachedText);
|
||||
}
|
||||
}
|
||||
|
||||
function scanTrivia(parent: IScannerToken, text: ISimpleText, isTrailing: boolean): ISyntaxTriviaList {
|
||||
function scanTrivia(parent: IScannerToken, text: ISimpleText): ISyntaxTriviaList {
|
||||
var tokenFullStart = parent.fullStart();
|
||||
var tokenStart = tokenFullStart + leadingTriviaWidth(parent, text)
|
||||
|
||||
if (isTrailing) {
|
||||
reset(text, tokenStart + parent.text().length, tokenFullStart + parent.fullWidth());
|
||||
}
|
||||
else {
|
||||
reset(text, tokenFullStart, tokenStart);
|
||||
}
|
||||
reset(text, tokenFullStart, tokenStart);
|
||||
// Debug.assert(length > 0);
|
||||
|
||||
// Keep this exactly in sync with scanTriviaInfo
|
||||
@@ -461,15 +418,7 @@ module TypeScript.Scanner {
|
||||
case CharacterCodes.paragraphSeparator:
|
||||
case CharacterCodes.lineSeparator:
|
||||
trivia.push(scanLineTerminatorSequenceTrivia(ch));
|
||||
|
||||
// If we're consuming leading trivia, then we will continue consuming more
|
||||
// trivia (including newlines) up to the first token we see. If we're
|
||||
// consuming trailing trivia, then we break after the first newline we see.
|
||||
if (!isTrailing) {
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
continue;
|
||||
|
||||
default:
|
||||
throw Errors.invalidOperation();
|
||||
@@ -486,7 +435,7 @@ module TypeScript.Scanner {
|
||||
|
||||
// Returns 0 if there was no trivia, or 1 if there was trivia. Returned as an int instead
|
||||
// of a boolean because we'll need a numerical value later on to store in our tokens.
|
||||
function scanTriviaInfo(isTrailing: boolean): number {
|
||||
function scanTriviaInfo(): number {
|
||||
// Keep this exactly in sync with scanTrivia
|
||||
var result = 0;
|
||||
var _end = end;
|
||||
@@ -516,14 +465,6 @@ module TypeScript.Scanner {
|
||||
|
||||
// we have trivia
|
||||
result |= ScannerConstants.NewlineTrivia;
|
||||
|
||||
// If we're consuming leading trivia, then we will continue consuming more
|
||||
// trivia (including newlines) up to the first token we see. If we're
|
||||
// consuming trailing trivia, then we break after the first newline we see.
|
||||
if (isTrailing) {
|
||||
return result;
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
case CharacterCodes.slash:
|
||||
@@ -672,26 +613,31 @@ module TypeScript.Scanner {
|
||||
return createTrivia(SyntaxKind.MultiLineCommentTrivia, absoluteStartIndex);
|
||||
}
|
||||
|
||||
function skipMultiLineCommentTrivia(): number {
|
||||
function skipMultiLineCommentTrivia(): void {
|
||||
// The '2' is for the "/*" we consumed.
|
||||
var _index = index + 2;
|
||||
var _end = end;
|
||||
|
||||
index += 2;
|
||||
|
||||
while (true) {
|
||||
if (index === end) {
|
||||
if (_index === _end) {
|
||||
reportDiagnostic(end, 0, DiagnosticCode._0_expected, ["*/"]);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((index + 1) < end &&
|
||||
str.charCodeAt(index) === CharacterCodes.asterisk &&
|
||||
str.charCodeAt(index + 1) === CharacterCodes.slash) {
|
||||
if ((_index + 1) < _end &&
|
||||
str.charCodeAt(_index) === CharacterCodes.asterisk &&
|
||||
str.charCodeAt(_index + 1) === CharacterCodes.slash) {
|
||||
|
||||
index += 2;
|
||||
return;
|
||||
_index += 2;
|
||||
break;
|
||||
}
|
||||
|
||||
index++;
|
||||
_index++;
|
||||
}
|
||||
|
||||
index = _index;
|
||||
}
|
||||
|
||||
function scanLineTerminatorSequenceTrivia(ch: number): ISyntaxTrivia {
|
||||
@@ -1461,14 +1407,10 @@ module TypeScript.Scanner {
|
||||
var fullEnd = fullStart + token.fullWidth();
|
||||
reset(text, fullStart, fullEnd);
|
||||
|
||||
scanTriviaInfo(/*isTrailing: */ false);
|
||||
scanTriviaInfo();
|
||||
|
||||
var start = index;
|
||||
scanSyntaxKind(isContextualToken(token));
|
||||
var end = index;
|
||||
|
||||
tokenInfo.leadingTriviaWidth = start - fullStart;
|
||||
tokenInfo.width = end - start;
|
||||
}
|
||||
|
||||
reset(text, 0, text.length());
|
||||
@@ -1622,6 +1564,8 @@ module TypeScript.Scanner {
|
||||
}
|
||||
|
||||
function consumeToken(token: ISyntaxToken): void {
|
||||
// Debug.assert(token.fullWidth() > 0 || token.kind === SyntaxKind.EndOfFileToken);
|
||||
|
||||
// Debug.assert(currentToken() === token);
|
||||
_absolutePosition += token.fullWidth();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ module TypeScript.Syntax {
|
||||
if (isToken(child)) {
|
||||
var token = <ISyntaxToken>child;
|
||||
// If a token is skipped, return true. Or if it is a missing token. The only empty token that is not missing is EOF
|
||||
if (token.hasSkippedToken() || (width(token) === 0 && token.kind !== SyntaxKind.EndOfFileToken)) {
|
||||
if (token.hasLeadingSkippedToken() || (fullWidth(token) === 0 && token.kind !== SyntaxKind.EndOfFileToken)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ module TypeScript.Syntax {
|
||||
}
|
||||
|
||||
export function isUnterminatedMultilineCommentTrivia(trivia: ISyntaxTrivia): boolean {
|
||||
if (trivia && trivia.kind() === SyntaxKind.MultiLineCommentTrivia) {
|
||||
if (trivia && trivia.kind === SyntaxKind.MultiLineCommentTrivia) {
|
||||
var text = trivia.fullText();
|
||||
return text.length < 4 || text.substring(text.length - 2) !== "*/";
|
||||
}
|
||||
@@ -42,79 +42,7 @@ module TypeScript.Syntax {
|
||||
return true;
|
||||
}
|
||||
else if (position === end) {
|
||||
return trivia.kind() === SyntaxKind.SingleLineCommentTrivia || isUnterminatedMultilineCommentTrivia(trivia);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isEntirelyInsideComment(sourceUnit: SourceUnitSyntax, position: number): boolean {
|
||||
var positionedToken = findToken(sourceUnit, position);
|
||||
var fullStart = positionedToken.fullStart();
|
||||
var triviaList: ISyntaxTriviaList = undefined;
|
||||
var lastTriviaBeforeToken: ISyntaxTrivia = undefined;
|
||||
|
||||
if (positionedToken.kind === SyntaxKind.EndOfFileToken) {
|
||||
// Check if the trivia is leading on the EndOfFile token
|
||||
if (positionedToken.hasLeadingTrivia()) {
|
||||
triviaList = positionedToken.leadingTrivia();
|
||||
}
|
||||
// Or trailing on the previous token
|
||||
else {
|
||||
positionedToken = previousToken(positionedToken);
|
||||
if (positionedToken) {
|
||||
if (positionedToken && positionedToken.hasTrailingTrivia()) {
|
||||
triviaList = positionedToken.trailingTrivia();
|
||||
fullStart = end(positionedToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (position <= (fullStart + positionedToken.leadingTriviaWidth())) {
|
||||
triviaList = positionedToken.leadingTrivia();
|
||||
}
|
||||
else if (position >= (fullStart + width(positionedToken))) {
|
||||
triviaList = positionedToken.trailingTrivia();
|
||||
fullStart = end(positionedToken);
|
||||
}
|
||||
}
|
||||
|
||||
if (triviaList) {
|
||||
// Try to find the trivia matching the position
|
||||
for (var i = 0, n = triviaList.count(); i < n; i++) {
|
||||
var trivia = triviaList.syntaxTriviaAt(i);
|
||||
if (position <= fullStart) {
|
||||
// Moved passed the trivia we need
|
||||
break;
|
||||
}
|
||||
else if (position <= fullStart + trivia.fullWidth() && trivia.isComment()) {
|
||||
// Found the comment trivia we were looking for
|
||||
lastTriviaBeforeToken = trivia;
|
||||
break;
|
||||
}
|
||||
|
||||
fullStart += trivia.fullWidth();
|
||||
}
|
||||
}
|
||||
|
||||
return lastTriviaBeforeToken && isEntirelyInsideCommentTrivia(lastTriviaBeforeToken, fullStart, position);
|
||||
}
|
||||
|
||||
export function isEntirelyInStringOrRegularExpressionLiteral(sourceUnit: SourceUnitSyntax, position: number): boolean {
|
||||
var positionedToken = findToken(sourceUnit, position);
|
||||
|
||||
if (positionedToken) {
|
||||
if (positionedToken.kind === SyntaxKind.EndOfFileToken) {
|
||||
// EndOfFile token, enusre it did not follow an unterminated string literal
|
||||
positionedToken = previousToken(positionedToken);
|
||||
return positionedToken && positionedToken.trailingTriviaWidth() === 0 && isUnterminatedStringLiteral(positionedToken);
|
||||
}
|
||||
else if (position > start(positionedToken)) {
|
||||
// Ensure position falls enterily within the literal if it is terminated, or the line if it is not
|
||||
return (position < end(positionedToken) && (positionedToken.kind === TypeScript.SyntaxKind.StringLiteral || positionedToken.kind === TypeScript.SyntaxKind.RegularExpressionLiteral)) ||
|
||||
(position <= end(positionedToken) && isUnterminatedStringLiteral(positionedToken));
|
||||
return trivia.kind === SyntaxKind.SingleLineCommentTrivia || isUnterminatedMultilineCommentTrivia(trivia);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,32 +131,10 @@ module TypeScript.Syntax {
|
||||
// Debug.assert(position < positionedToken.fullEnd() || positionedToken.token().tokenKind === SyntaxKind.EndOfFileToken);
|
||||
|
||||
// if position is after the end of the token, then this token is the token on the left.
|
||||
if (width(positionedToken) > 0 && position >= end(positionedToken)) {
|
||||
if (width(positionedToken) > 0 && position >= fullEnd(positionedToken)) {
|
||||
return positionedToken;
|
||||
}
|
||||
|
||||
return previousToken(positionedToken);
|
||||
}
|
||||
|
||||
export function firstTokenInLineContainingPosition(syntaxTree: SyntaxTree, position: number): ISyntaxToken {
|
||||
var current = findToken(syntaxTree.sourceUnit(), position);
|
||||
while (true) {
|
||||
if (isFirstTokenInLine(current, syntaxTree.lineMap())) {
|
||||
break;
|
||||
}
|
||||
|
||||
current = previousToken(current);
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
function isFirstTokenInLine(token: ISyntaxToken, lineMap: LineMap): boolean {
|
||||
var _previousToken = previousToken(token);
|
||||
if (_previousToken === undefined) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return lineMap.getLineNumberFromPosition(end(_previousToken)) !== lineMap.getLineNumberFromPosition(start(token));
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,15 @@ module TypeScript {
|
||||
return (info & SyntaxConstants.NodeParsedInStrictModeMask) !== 0;
|
||||
}
|
||||
|
||||
export function parsedInDisallowInMode(node: ISyntaxNode): boolean {
|
||||
var info = node.__data;
|
||||
if (info === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (info & SyntaxConstants.NodeParsedInDisallowInMask) !== 0;
|
||||
}
|
||||
|
||||
export function previousToken(token: ISyntaxToken): ISyntaxToken {
|
||||
var start = token.fullStart();
|
||||
if (start === 0) {
|
||||
@@ -70,48 +79,6 @@ module TypeScript {
|
||||
throw Errors.invalidOperation();
|
||||
}
|
||||
|
||||
export function findSkippedTokenInPositionedToken(positionedToken: ISyntaxToken, position: number): ISyntaxToken {
|
||||
var positionInLeadingTriviaList = (position < start(positionedToken));
|
||||
return findSkippedTokenInTriviaList(positionedToken, position, /*lookInLeadingTriviaList*/ positionInLeadingTriviaList);
|
||||
}
|
||||
|
||||
export function findSkippedTokenInLeadingTriviaList(positionedToken: ISyntaxToken, position: number): ISyntaxToken {
|
||||
return findSkippedTokenInTriviaList(positionedToken, position, /*lookInLeadingTriviaList*/ true);
|
||||
}
|
||||
|
||||
export function findSkippedTokenInTrailingTriviaList(positionedToken: ISyntaxToken, position: number): ISyntaxToken {
|
||||
return findSkippedTokenInTriviaList(positionedToken, position, /*lookInLeadingTriviaList*/ false);
|
||||
}
|
||||
|
||||
function findSkippedTokenInTriviaList(positionedToken: ISyntaxToken, position: number, lookInLeadingTriviaList: boolean): ISyntaxToken {
|
||||
var triviaList: TypeScript.ISyntaxTriviaList = undefined;
|
||||
var fullStart: number;
|
||||
|
||||
if (lookInLeadingTriviaList) {
|
||||
triviaList = positionedToken.leadingTrivia();
|
||||
fullStart = positionedToken.fullStart();
|
||||
}
|
||||
else {
|
||||
triviaList = positionedToken.trailingTrivia();
|
||||
fullStart = end(positionedToken);
|
||||
}
|
||||
|
||||
if (triviaList && triviaList.hasSkippedToken()) {
|
||||
for (var i = 0, n = triviaList.count(); i < n; i++) {
|
||||
var trivia = triviaList.syntaxTriviaAt(i);
|
||||
var triviaWidth = trivia.fullWidth();
|
||||
|
||||
if (trivia.isSkippedToken() && position >= fullStart && position <= fullStart + triviaWidth) {
|
||||
return trivia.skippedToken();
|
||||
}
|
||||
|
||||
fullStart += triviaWidth;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function findTokenWorker(element: ISyntaxElement, elementPosition: number, position: number): ISyntaxToken {
|
||||
if (isList(element)) {
|
||||
return findTokenInList(<ISyntaxNodeOrToken[]>element, elementPosition, position);
|
||||
@@ -246,11 +213,6 @@ module TypeScript {
|
||||
return token ? token.leadingTriviaWidth(text) : 0;
|
||||
}
|
||||
|
||||
export function trailingTriviaWidth(element: ISyntaxElement, text?: ISimpleText): number {
|
||||
var token = lastToken(element);
|
||||
return token ? token.trailingTriviaWidth(text) : 0;
|
||||
}
|
||||
|
||||
export function firstToken(element: ISyntaxElement): ISyntaxToken {
|
||||
if (element) {
|
||||
var kind = element.kind;
|
||||
@@ -387,16 +349,11 @@ module TypeScript {
|
||||
return token ? token.fullStart() + token.leadingTriviaWidth(text) : -1;
|
||||
}
|
||||
|
||||
export function end(element: ISyntaxElement, text?: ISimpleText): number {
|
||||
var token = isToken(element) ? <ISyntaxToken>element : lastToken(element);
|
||||
return token ? fullEnd(token) - token.trailingTriviaWidth(text) : -1;
|
||||
}
|
||||
|
||||
export function width(element: ISyntaxElement, text?: ISimpleText): number {
|
||||
if (isToken(element)) {
|
||||
return (<ISyntaxToken>element).text().length;
|
||||
}
|
||||
return fullWidth(element) - leadingTriviaWidth(element, text) - trailingTriviaWidth(element, text);
|
||||
return fullWidth(element) - leadingTriviaWidth(element, text);
|
||||
}
|
||||
|
||||
export function fullEnd(element: ISyntaxElement): number {
|
||||
@@ -413,7 +370,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
var lineMap = text.lineMap();
|
||||
return lineMap.getLineNumberFromPosition(end(token1, text)) !== lineMap.getLineNumberFromPosition(start(token2, text));
|
||||
return lineMap.getLineNumberFromPosition(fullEnd(token1)) !== lineMap.getLineNumberFromPosition(start(token2, text));
|
||||
}
|
||||
|
||||
export interface ISyntaxElement {
|
||||
|
||||
@@ -144,8 +144,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
<any>{ name: 'moduleKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'name', type: 'INameSyntax', isOptional: true },
|
||||
<any>{ name: 'stringLiteral', isToken: true, isOptional: true, tokenKinds: ['StringLiteral'] },
|
||||
<any>{ name: 'name', type: 'INameSyntax' },
|
||||
<any>{ name: 'openBraceToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'moduleElements', isList: true, elementType: 'IModuleElementSyntax' },
|
||||
<any>{ name: 'closeBraceToken', isToken: true, excludeFromAST: true }
|
||||
@@ -161,8 +160,7 @@ var definitions:ITypeDefinition[] = [
|
||||
<any>{ name: 'functionKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'identifier', isToken: true, tokenKinds: ['IdentifierName'] },
|
||||
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
<any>{ name: 'block', type: 'BlockSyntax', isOptional: true },
|
||||
<any>{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
<any>{ name: 'body', type: 'BlockSyntax | ISyntaxToken', isOptional: true }
|
||||
]
|
||||
},
|
||||
<any>{
|
||||
@@ -242,8 +240,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'parameter', type: 'ParameterSyntax' },
|
||||
<any>{ name: 'equalsGreaterThanToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'block', type: 'BlockSyntax', isOptional: true },
|
||||
<any>{ name: 'expression', type: 'IExpressionSyntax', isOptional: true }
|
||||
<any>{ name: 'body', type: 'BlockSyntax | IExpressionSyntax' }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
},
|
||||
@@ -254,8 +251,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
<any>{ name: 'equalsGreaterThanToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'block', type: 'BlockSyntax', isOptional: true },
|
||||
<any>{ name: 'expression', type: 'IExpressionSyntax', isOptional: true }
|
||||
<any>{ name: 'body', type: 'BlockSyntax | IExpressionSyntax' }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
},
|
||||
@@ -639,8 +635,7 @@ var definitions:ITypeDefinition[] = [
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
<any>{ name: 'constructorKeyword', isToken: true },
|
||||
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
<any>{ name: 'block', type: 'BlockSyntax', isOptional: true },
|
||||
<any>{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
<any>{ name: 'body', type: 'BlockSyntax | ISyntaxToken', isOptional: true }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
},
|
||||
@@ -652,8 +647,7 @@ var definitions:ITypeDefinition[] = [
|
||||
<any>{ name: 'modifiers', isList: true, elementType: 'ISyntaxToken' },
|
||||
<any>{ name: 'propertyName', type: 'IPropertyNameSyntax' },
|
||||
<any>{ name: 'callSignature', type: 'CallSignatureSyntax' },
|
||||
<any>{ name: 'block', type: 'BlockSyntax', isOptional: true },
|
||||
<any>{ name: 'semicolonToken', isToken: true, isOptional: true, excludeFromAST: true }
|
||||
<any>{ name: 'body', type: 'BlockSyntax | ISyntaxToken', isOptional: true }
|
||||
],
|
||||
isTypeScriptSpecific: true
|
||||
},
|
||||
@@ -796,8 +790,7 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'forKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'openParenToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'variableDeclaration', type: 'VariableDeclarationSyntax', isOptional: true },
|
||||
<any>{ name: 'initializer', type: 'IExpressionSyntax', isOptional: true },
|
||||
<any>{ name: 'initializer', type: 'VariableDeclarationSyntax | IExpressionSyntax', isOptional: true },
|
||||
<any>{ name: 'firstSemicolonToken', isToken: true, tokenKinds: ['SemicolonToken'], excludeFromAST: true },
|
||||
<any>{ name: 'condition', type: 'IExpressionSyntax', isOptional: true },
|
||||
<any>{ name: 'secondSemicolonToken', isToken: true, tokenKinds: ['SemicolonToken'], excludeFromAST: true },
|
||||
@@ -813,10 +806,9 @@ var definitions:ITypeDefinition[] = [
|
||||
children: [
|
||||
<any>{ name: 'forKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'openParenToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'variableDeclaration', type: 'VariableDeclarationSyntax', isOptional: true },
|
||||
<any>{ name: 'left', type: 'IExpressionSyntax', isOptional: true },
|
||||
<any>{ name: 'left', type: 'VariableDeclarationSyntax | IExpressionSyntax' },
|
||||
<any>{ name: 'inKeyword', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'expression', type: 'IExpressionSyntax' },
|
||||
<any>{ name: 'right', type: 'IExpressionSyntax' },
|
||||
<any>{ name: 'closeParenToken', isToken: true, excludeFromAST: true },
|
||||
<any>{ name: 'statement', type: 'IStatementSyntax' }
|
||||
]
|
||||
|
||||
@@ -94,21 +94,19 @@ module TypeScript {
|
||||
functionKeyword: ISyntaxToken;
|
||||
identifier: ISyntaxToken;
|
||||
callSignature: CallSignatureSyntax;
|
||||
block: BlockSyntax;
|
||||
semicolonToken: ISyntaxToken;
|
||||
body: BlockSyntax | ISyntaxToken;
|
||||
}
|
||||
export interface FunctionDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken): FunctionDeclarationSyntax }
|
||||
export interface FunctionDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, body: BlockSyntax | ISyntaxToken): FunctionDeclarationSyntax }
|
||||
|
||||
export interface ModuleDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
moduleKeyword: ISyntaxToken;
|
||||
name: INameSyntax;
|
||||
stringLiteral: ISyntaxToken;
|
||||
openBraceToken: ISyntaxToken;
|
||||
moduleElements: IModuleElementSyntax[];
|
||||
closeBraceToken: ISyntaxToken;
|
||||
}
|
||||
export interface ModuleDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], moduleKeyword: ISyntaxToken, name: INameSyntax, stringLiteral: ISyntaxToken, openBraceToken: ISyntaxToken, moduleElements: IModuleElementSyntax[], closeBraceToken: ISyntaxToken): ModuleDeclarationSyntax }
|
||||
export interface ModuleDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], moduleKeyword: ISyntaxToken, name: INameSyntax, openBraceToken: ISyntaxToken, moduleElements: IModuleElementSyntax[], closeBraceToken: ISyntaxToken): ModuleDeclarationSyntax }
|
||||
|
||||
export interface ClassDeclarationSyntax extends ISyntaxNode, IModuleElementSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
@@ -154,10 +152,9 @@ module TypeScript {
|
||||
modifiers: ISyntaxToken[];
|
||||
propertyName: IPropertyNameSyntax;
|
||||
callSignature: CallSignatureSyntax;
|
||||
block: BlockSyntax;
|
||||
semicolonToken: ISyntaxToken;
|
||||
body: BlockSyntax | ISyntaxToken;
|
||||
}
|
||||
export interface MemberFunctionDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken): MemberFunctionDeclarationSyntax }
|
||||
export interface MemberFunctionDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, body: BlockSyntax | ISyntaxToken): MemberFunctionDeclarationSyntax }
|
||||
|
||||
export interface MemberVariableDeclarationSyntax extends ISyntaxNode, IMemberDeclarationSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
@@ -170,10 +167,9 @@ module TypeScript {
|
||||
modifiers: ISyntaxToken[];
|
||||
constructorKeyword: ISyntaxToken;
|
||||
callSignature: CallSignatureSyntax;
|
||||
block: BlockSyntax;
|
||||
semicolonToken: ISyntaxToken;
|
||||
body: BlockSyntax | ISyntaxToken;
|
||||
}
|
||||
export interface ConstructorDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], constructorKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken): ConstructorDeclarationSyntax }
|
||||
export interface ConstructorDeclarationConstructor { new (data: number, modifiers: ISyntaxToken[], constructorKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, body: BlockSyntax | ISyntaxToken): ConstructorDeclarationSyntax }
|
||||
|
||||
export interface IndexMemberDeclarationSyntax extends ISyntaxNode, IClassElementSyntax {
|
||||
modifiers: ISyntaxToken[];
|
||||
@@ -300,8 +296,7 @@ module TypeScript {
|
||||
export interface ForStatementSyntax extends ISyntaxNode, IStatementSyntax {
|
||||
forKeyword: ISyntaxToken;
|
||||
openParenToken: ISyntaxToken;
|
||||
variableDeclaration: VariableDeclarationSyntax;
|
||||
initializer: IExpressionSyntax;
|
||||
initializer: VariableDeclarationSyntax | IExpressionSyntax;
|
||||
firstSemicolonToken: ISyntaxToken;
|
||||
condition: IExpressionSyntax;
|
||||
secondSemicolonToken: ISyntaxToken;
|
||||
@@ -309,19 +304,18 @@ module TypeScript {
|
||||
closeParenToken: ISyntaxToken;
|
||||
statement: IStatementSyntax;
|
||||
}
|
||||
export interface ForStatementConstructor { new (data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, initializer: IExpressionSyntax, firstSemicolonToken: ISyntaxToken, condition: IExpressionSyntax, secondSemicolonToken: ISyntaxToken, incrementor: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): ForStatementSyntax }
|
||||
export interface ForStatementConstructor { new (data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, initializer: VariableDeclarationSyntax | IExpressionSyntax, firstSemicolonToken: ISyntaxToken, condition: IExpressionSyntax, secondSemicolonToken: ISyntaxToken, incrementor: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): ForStatementSyntax }
|
||||
|
||||
export interface ForInStatementSyntax extends ISyntaxNode, IStatementSyntax {
|
||||
forKeyword: ISyntaxToken;
|
||||
openParenToken: ISyntaxToken;
|
||||
variableDeclaration: VariableDeclarationSyntax;
|
||||
left: IExpressionSyntax;
|
||||
left: VariableDeclarationSyntax | IExpressionSyntax;
|
||||
inKeyword: ISyntaxToken;
|
||||
expression: IExpressionSyntax;
|
||||
right: IExpressionSyntax;
|
||||
closeParenToken: ISyntaxToken;
|
||||
statement: IStatementSyntax;
|
||||
}
|
||||
export interface ForInStatementConstructor { new (data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, left: IExpressionSyntax, inKeyword: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): ForInStatementSyntax }
|
||||
export interface ForInStatementConstructor { new (data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, left: VariableDeclarationSyntax | IExpressionSyntax, inKeyword: ISyntaxToken, right: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax): ForInStatementSyntax }
|
||||
|
||||
export interface EmptyStatementSyntax extends ISyntaxNode, IStatementSyntax {
|
||||
semicolonToken: ISyntaxToken;
|
||||
@@ -475,18 +469,16 @@ module TypeScript {
|
||||
export interface ParenthesizedArrowFunctionExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
|
||||
callSignature: CallSignatureSyntax;
|
||||
equalsGreaterThanToken: ISyntaxToken;
|
||||
block: BlockSyntax;
|
||||
expression: IExpressionSyntax;
|
||||
body: BlockSyntax | IExpressionSyntax;
|
||||
}
|
||||
export interface ParenthesizedArrowFunctionExpressionConstructor { new (data: number, callSignature: CallSignatureSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax): ParenthesizedArrowFunctionExpressionSyntax }
|
||||
export interface ParenthesizedArrowFunctionExpressionConstructor { new (data: number, callSignature: CallSignatureSyntax, equalsGreaterThanToken: ISyntaxToken, body: BlockSyntax | IExpressionSyntax): ParenthesizedArrowFunctionExpressionSyntax }
|
||||
|
||||
export interface SimpleArrowFunctionExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
|
||||
parameter: ParameterSyntax;
|
||||
equalsGreaterThanToken: ISyntaxToken;
|
||||
block: BlockSyntax;
|
||||
expression: IExpressionSyntax;
|
||||
body: BlockSyntax | IExpressionSyntax;
|
||||
}
|
||||
export interface SimpleArrowFunctionExpressionConstructor { new (data: number, parameter: ParameterSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax): SimpleArrowFunctionExpressionSyntax }
|
||||
export interface SimpleArrowFunctionExpressionConstructor { new (data: number, parameter: ParameterSyntax, equalsGreaterThanToken: ISyntaxToken, body: BlockSyntax | IExpressionSyntax): SimpleArrowFunctionExpressionSyntax }
|
||||
|
||||
export interface CastExpressionSyntax extends ISyntaxNode, IUnaryExpressionSyntax {
|
||||
lessThanToken: ISyntaxToken;
|
||||
|
||||
@@ -19,11 +19,11 @@ module TypeScript {
|
||||
|
||||
module TypeScript {
|
||||
export function separatorCount(list: ISeparatedSyntaxList<ISyntaxNodeOrToken>) {
|
||||
return list.length >> 1;
|
||||
return list === undefined ? 0 : list.length >> 1;
|
||||
}
|
||||
|
||||
export function nonSeparatorCount(list: ISeparatedSyntaxList<ISyntaxNodeOrToken>) {
|
||||
return (list.length + 1) >> 1;
|
||||
return list === undefined ? 0 : (list.length + 1) >> 1;
|
||||
}
|
||||
|
||||
export function separatorAt(list: ISeparatedSyntaxList<ISyntaxNodeOrToken>, index: number): ISyntaxToken {
|
||||
@@ -48,16 +48,20 @@ module TypeScript.Syntax {
|
||||
addArrayPrototypeValue("kind", SyntaxKind.List);
|
||||
|
||||
export function list<T extends ISyntaxNodeOrToken>(nodes: T[]): T[] {
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
nodes[i].parent = nodes;
|
||||
if (nodes !== undefined) {
|
||||
for (var i = 0, n = nodes.length; i < n; i++) {
|
||||
nodes[i].parent = nodes;
|
||||
}
|
||||
}
|
||||
|
||||
return nodes;
|
||||
}
|
||||
|
||||
export function separatedList<T extends ISyntaxNodeOrToken>(nodesAndTokens: ISyntaxNodeOrToken[]): ISeparatedSyntaxList<T> {
|
||||
for (var i = 0, n = nodesAndTokens.length; i < n; i++) {
|
||||
nodesAndTokens[i].parent = nodesAndTokens;
|
||||
if (nodesAndTokens !== undefined) {
|
||||
for (var i = 0, n = nodesAndTokens.length; i < n; i++) {
|
||||
nodesAndTokens[i].parent = nodesAndTokens;
|
||||
}
|
||||
}
|
||||
|
||||
return <ISeparatedSyntaxList<T>>nodesAndTokens;
|
||||
|
||||
@@ -238,62 +238,56 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var FunctionDeclarationSyntax: FunctionDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) {
|
||||
export var FunctionDeclarationSyntax: FunctionDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], functionKeyword: ISyntaxToken, identifier: ISyntaxToken, callSignature: CallSignatureSyntax, body: BlockSyntax | ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.functionKeyword = functionKeyword,
|
||||
this.identifier = identifier,
|
||||
this.callSignature = callSignature,
|
||||
this.block = block,
|
||||
this.semicolonToken = semicolonToken,
|
||||
this.body = body,
|
||||
modifiers.parent = this,
|
||||
functionKeyword.parent = this,
|
||||
identifier.parent = this,
|
||||
callSignature.parent = this,
|
||||
block && (block.parent = this),
|
||||
semicolonToken && (semicolonToken.parent = this);
|
||||
body && (body.parent = this);
|
||||
};
|
||||
FunctionDeclarationSyntax.prototype.kind = SyntaxKind.FunctionDeclaration;
|
||||
FunctionDeclarationSyntax.prototype.childCount = 6;
|
||||
FunctionDeclarationSyntax.prototype.childCount = 5;
|
||||
FunctionDeclarationSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.modifiers;
|
||||
case 1: return this.functionKeyword;
|
||||
case 2: return this.identifier;
|
||||
case 3: return this.callSignature;
|
||||
case 4: return this.block;
|
||||
case 5: return this.semicolonToken;
|
||||
case 4: return this.body;
|
||||
}
|
||||
}
|
||||
|
||||
export var ModuleDeclarationSyntax: ModuleDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], moduleKeyword: ISyntaxToken, name: INameSyntax, stringLiteral: ISyntaxToken, openBraceToken: ISyntaxToken, moduleElements: IModuleElementSyntax[], closeBraceToken: ISyntaxToken) {
|
||||
export var ModuleDeclarationSyntax: ModuleDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], moduleKeyword: ISyntaxToken, name: INameSyntax, openBraceToken: ISyntaxToken, moduleElements: IModuleElementSyntax[], closeBraceToken: ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.moduleKeyword = moduleKeyword,
|
||||
this.name = name,
|
||||
this.stringLiteral = stringLiteral,
|
||||
this.openBraceToken = openBraceToken,
|
||||
this.moduleElements = moduleElements,
|
||||
this.closeBraceToken = closeBraceToken,
|
||||
modifiers.parent = this,
|
||||
moduleKeyword.parent = this,
|
||||
name && (name.parent = this),
|
||||
stringLiteral && (stringLiteral.parent = this),
|
||||
name.parent = this,
|
||||
openBraceToken.parent = this,
|
||||
moduleElements.parent = this,
|
||||
closeBraceToken.parent = this;
|
||||
};
|
||||
ModuleDeclarationSyntax.prototype.kind = SyntaxKind.ModuleDeclaration;
|
||||
ModuleDeclarationSyntax.prototype.childCount = 7;
|
||||
ModuleDeclarationSyntax.prototype.childCount = 6;
|
||||
ModuleDeclarationSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.modifiers;
|
||||
case 1: return this.moduleKeyword;
|
||||
case 2: return this.name;
|
||||
case 3: return this.stringLiteral;
|
||||
case 4: return this.openBraceToken;
|
||||
case 5: return this.moduleElements;
|
||||
case 6: return this.closeBraceToken;
|
||||
case 3: return this.openBraceToken;
|
||||
case 4: return this.moduleElements;
|
||||
case 5: return this.closeBraceToken;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,28 +403,25 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var MemberFunctionDeclarationSyntax: MemberFunctionDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) {
|
||||
export var MemberFunctionDeclarationSyntax: MemberFunctionDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], propertyName: IPropertyNameSyntax, callSignature: CallSignatureSyntax, body: BlockSyntax | ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.propertyName = propertyName,
|
||||
this.callSignature = callSignature,
|
||||
this.block = block,
|
||||
this.semicolonToken = semicolonToken,
|
||||
this.body = body,
|
||||
modifiers.parent = this,
|
||||
propertyName.parent = this,
|
||||
callSignature.parent = this,
|
||||
block && (block.parent = this),
|
||||
semicolonToken && (semicolonToken.parent = this);
|
||||
body && (body.parent = this);
|
||||
};
|
||||
MemberFunctionDeclarationSyntax.prototype.kind = SyntaxKind.MemberFunctionDeclaration;
|
||||
MemberFunctionDeclarationSyntax.prototype.childCount = 5;
|
||||
MemberFunctionDeclarationSyntax.prototype.childCount = 4;
|
||||
MemberFunctionDeclarationSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.modifiers;
|
||||
case 1: return this.propertyName;
|
||||
case 2: return this.callSignature;
|
||||
case 3: return this.block;
|
||||
case 4: return this.semicolonToken;
|
||||
case 3: return this.body;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,28 +444,25 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ConstructorDeclarationSyntax: ConstructorDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], constructorKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, block: BlockSyntax, semicolonToken: ISyntaxToken) {
|
||||
export var ConstructorDeclarationSyntax: ConstructorDeclarationConstructor = <any>function(data: number, modifiers: ISyntaxToken[], constructorKeyword: ISyntaxToken, callSignature: CallSignatureSyntax, body: BlockSyntax | ISyntaxToken) {
|
||||
if (data) { this.__data = data; }
|
||||
this.modifiers = modifiers,
|
||||
this.constructorKeyword = constructorKeyword,
|
||||
this.callSignature = callSignature,
|
||||
this.block = block,
|
||||
this.semicolonToken = semicolonToken,
|
||||
this.body = body,
|
||||
modifiers.parent = this,
|
||||
constructorKeyword.parent = this,
|
||||
callSignature.parent = this,
|
||||
block && (block.parent = this),
|
||||
semicolonToken && (semicolonToken.parent = this);
|
||||
body && (body.parent = this);
|
||||
};
|
||||
ConstructorDeclarationSyntax.prototype.kind = SyntaxKind.ConstructorDeclaration;
|
||||
ConstructorDeclarationSyntax.prototype.childCount = 5;
|
||||
ConstructorDeclarationSyntax.prototype.childCount = 4;
|
||||
ConstructorDeclarationSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.modifiers;
|
||||
case 1: return this.constructorKeyword;
|
||||
case 2: return this.callSignature;
|
||||
case 3: return this.block;
|
||||
case 4: return this.semicolonToken;
|
||||
case 3: return this.body;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -812,11 +800,10 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ForStatementSyntax: ForStatementConstructor = <any>function(data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, initializer: IExpressionSyntax, firstSemicolonToken: ISyntaxToken, condition: IExpressionSyntax, secondSemicolonToken: ISyntaxToken, incrementor: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
|
||||
export var ForStatementSyntax: ForStatementConstructor = <any>function(data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, initializer: VariableDeclarationSyntax | IExpressionSyntax, firstSemicolonToken: ISyntaxToken, condition: IExpressionSyntax, secondSemicolonToken: ISyntaxToken, incrementor: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.forKeyword = forKeyword,
|
||||
this.openParenToken = openParenToken,
|
||||
this.variableDeclaration = variableDeclaration,
|
||||
this.initializer = initializer,
|
||||
this.firstSemicolonToken = firstSemicolonToken,
|
||||
this.condition = condition,
|
||||
@@ -826,7 +813,6 @@ module TypeScript {
|
||||
this.statement = statement,
|
||||
forKeyword.parent = this,
|
||||
openParenToken.parent = this,
|
||||
variableDeclaration && (variableDeclaration.parent = this),
|
||||
initializer && (initializer.parent = this),
|
||||
firstSemicolonToken.parent = this,
|
||||
condition && (condition.parent = this),
|
||||
@@ -836,53 +822,49 @@ module TypeScript {
|
||||
statement.parent = this;
|
||||
};
|
||||
ForStatementSyntax.prototype.kind = SyntaxKind.ForStatement;
|
||||
ForStatementSyntax.prototype.childCount = 10;
|
||||
ForStatementSyntax.prototype.childCount = 9;
|
||||
ForStatementSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.forKeyword;
|
||||
case 1: return this.openParenToken;
|
||||
case 2: return this.variableDeclaration;
|
||||
case 3: return this.initializer;
|
||||
case 4: return this.firstSemicolonToken;
|
||||
case 5: return this.condition;
|
||||
case 6: return this.secondSemicolonToken;
|
||||
case 7: return this.incrementor;
|
||||
case 8: return this.closeParenToken;
|
||||
case 9: return this.statement;
|
||||
case 2: return this.initializer;
|
||||
case 3: return this.firstSemicolonToken;
|
||||
case 4: return this.condition;
|
||||
case 5: return this.secondSemicolonToken;
|
||||
case 6: return this.incrementor;
|
||||
case 7: return this.closeParenToken;
|
||||
case 8: return this.statement;
|
||||
}
|
||||
}
|
||||
|
||||
export var ForInStatementSyntax: ForInStatementConstructor = <any>function(data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, variableDeclaration: VariableDeclarationSyntax, left: IExpressionSyntax, inKeyword: ISyntaxToken, expression: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
|
||||
export var ForInStatementSyntax: ForInStatementConstructor = <any>function(data: number, forKeyword: ISyntaxToken, openParenToken: ISyntaxToken, left: VariableDeclarationSyntax | IExpressionSyntax, inKeyword: ISyntaxToken, right: IExpressionSyntax, closeParenToken: ISyntaxToken, statement: IStatementSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.forKeyword = forKeyword,
|
||||
this.openParenToken = openParenToken,
|
||||
this.variableDeclaration = variableDeclaration,
|
||||
this.left = left,
|
||||
this.inKeyword = inKeyword,
|
||||
this.expression = expression,
|
||||
this.right = right,
|
||||
this.closeParenToken = closeParenToken,
|
||||
this.statement = statement,
|
||||
forKeyword.parent = this,
|
||||
openParenToken.parent = this,
|
||||
variableDeclaration && (variableDeclaration.parent = this),
|
||||
left && (left.parent = this),
|
||||
left.parent = this,
|
||||
inKeyword.parent = this,
|
||||
expression.parent = this,
|
||||
right.parent = this,
|
||||
closeParenToken.parent = this,
|
||||
statement.parent = this;
|
||||
};
|
||||
ForInStatementSyntax.prototype.kind = SyntaxKind.ForInStatement;
|
||||
ForInStatementSyntax.prototype.childCount = 8;
|
||||
ForInStatementSyntax.prototype.childCount = 7;
|
||||
ForInStatementSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.forKeyword;
|
||||
case 1: return this.openParenToken;
|
||||
case 2: return this.variableDeclaration;
|
||||
case 3: return this.left;
|
||||
case 4: return this.inKeyword;
|
||||
case 5: return this.expression;
|
||||
case 6: return this.closeParenToken;
|
||||
case 7: return this.statement;
|
||||
case 2: return this.left;
|
||||
case 3: return this.inKeyword;
|
||||
case 4: return this.right;
|
||||
case 5: return this.closeParenToken;
|
||||
case 6: return this.statement;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1291,47 +1273,41 @@ module TypeScript {
|
||||
}
|
||||
}
|
||||
|
||||
export var ParenthesizedArrowFunctionExpressionSyntax: ParenthesizedArrowFunctionExpressionConstructor = <any>function(data: number, callSignature: CallSignatureSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax) {
|
||||
export var ParenthesizedArrowFunctionExpressionSyntax: ParenthesizedArrowFunctionExpressionConstructor = <any>function(data: number, callSignature: CallSignatureSyntax, equalsGreaterThanToken: ISyntaxToken, body: BlockSyntax | IExpressionSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.callSignature = callSignature,
|
||||
this.equalsGreaterThanToken = equalsGreaterThanToken,
|
||||
this.block = block,
|
||||
this.expression = expression,
|
||||
this.body = body,
|
||||
callSignature.parent = this,
|
||||
equalsGreaterThanToken.parent = this,
|
||||
block && (block.parent = this),
|
||||
expression && (expression.parent = this);
|
||||
body.parent = this;
|
||||
};
|
||||
ParenthesizedArrowFunctionExpressionSyntax.prototype.kind = SyntaxKind.ParenthesizedArrowFunctionExpression;
|
||||
ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = 4;
|
||||
ParenthesizedArrowFunctionExpressionSyntax.prototype.childCount = 3;
|
||||
ParenthesizedArrowFunctionExpressionSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.callSignature;
|
||||
case 1: return this.equalsGreaterThanToken;
|
||||
case 2: return this.block;
|
||||
case 3: return this.expression;
|
||||
case 2: return this.body;
|
||||
}
|
||||
}
|
||||
|
||||
export var SimpleArrowFunctionExpressionSyntax: SimpleArrowFunctionExpressionConstructor = <any>function(data: number, parameter: ParameterSyntax, equalsGreaterThanToken: ISyntaxToken, block: BlockSyntax, expression: IExpressionSyntax) {
|
||||
export var SimpleArrowFunctionExpressionSyntax: SimpleArrowFunctionExpressionConstructor = <any>function(data: number, parameter: ParameterSyntax, equalsGreaterThanToken: ISyntaxToken, body: BlockSyntax | IExpressionSyntax) {
|
||||
if (data) { this.__data = data; }
|
||||
this.parameter = parameter,
|
||||
this.equalsGreaterThanToken = equalsGreaterThanToken,
|
||||
this.block = block,
|
||||
this.expression = expression,
|
||||
this.body = body,
|
||||
parameter.parent = this,
|
||||
equalsGreaterThanToken.parent = this,
|
||||
block && (block.parent = this),
|
||||
expression && (expression.parent = this);
|
||||
body.parent = this;
|
||||
};
|
||||
SimpleArrowFunctionExpressionSyntax.prototype.kind = SyntaxKind.SimpleArrowFunctionExpression;
|
||||
SimpleArrowFunctionExpressionSyntax.prototype.childCount = 4;
|
||||
SimpleArrowFunctionExpressionSyntax.prototype.childCount = 3;
|
||||
SimpleArrowFunctionExpressionSyntax.prototype.childAt = function(index: number): ISyntaxElement {
|
||||
switch (index) {
|
||||
case 0: return this.parameter;
|
||||
case 1: return this.equalsGreaterThanToken;
|
||||
case 2: return this.block;
|
||||
case 3: return this.expression;
|
||||
case 2: return this.body;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,17 +16,12 @@ module TypeScript {
|
||||
fullText(text?: ISimpleText): string;
|
||||
|
||||
hasLeadingTrivia(): boolean;
|
||||
hasTrailingTrivia(): boolean;
|
||||
hasLeadingNewLine(): boolean;
|
||||
hasLeadingComment(): boolean;
|
||||
hasTrailingComment(): boolean;
|
||||
|
||||
hasSkippedToken(): boolean;
|
||||
hasLeadingSkippedToken(): boolean;
|
||||
|
||||
leadingTrivia(text?: ISimpleText): ISyntaxTriviaList;
|
||||
trailingTrivia(text?: ISimpleText): ISyntaxTriviaList;
|
||||
|
||||
leadingTriviaWidth(text?: ISimpleText): number;
|
||||
trailingTriviaWidth(text?: ISimpleText): number;
|
||||
|
||||
// True if this was a keyword that the parser converted to an identifier. i.e. if you have
|
||||
// x.public
|
||||
@@ -284,7 +279,7 @@ module TypeScript {
|
||||
|
||||
module TypeScript.Syntax {
|
||||
export function realizeToken(token: ISyntaxToken, text: ISimpleText): ISyntaxToken {
|
||||
return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), token.trailingTrivia(text));
|
||||
return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text());
|
||||
}
|
||||
|
||||
export function convertKeywordToIdentifier(token: ISyntaxToken): ISyntaxToken {
|
||||
@@ -292,11 +287,7 @@ module TypeScript.Syntax {
|
||||
}
|
||||
|
||||
export function withLeadingTrivia(token: ISyntaxToken, leadingTrivia: ISyntaxTriviaList, text: ISimpleText): ISyntaxToken {
|
||||
return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), leadingTrivia, token.text(), token.trailingTrivia(text));
|
||||
}
|
||||
|
||||
export function withTrailingTrivia(token: ISyntaxToken, trailingTrivia: ISyntaxTriviaList, text: ISimpleText): ISyntaxToken {
|
||||
return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), token.leadingTrivia(text), token.text(), trailingTrivia);
|
||||
return new RealizedToken(token.fullStart(), token.kind, token.isKeywordConvertedToIdentifier(), leadingTrivia, token.text());
|
||||
}
|
||||
|
||||
export function emptyToken(kind: SyntaxKind): ISyntaxToken {
|
||||
@@ -317,7 +308,6 @@ module TypeScript.Syntax {
|
||||
}
|
||||
|
||||
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
|
||||
public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) }
|
||||
|
||||
public clone(): ISyntaxToken {
|
||||
return new EmptyToken(this.kind);
|
||||
@@ -405,16 +395,12 @@ module TypeScript.Syntax {
|
||||
public fullText(): string { return ""; }
|
||||
|
||||
public hasLeadingTrivia() { return false; }
|
||||
public hasTrailingTrivia() { return false; }
|
||||
public hasLeadingNewLine() { return false; }
|
||||
public hasLeadingComment() { return false; }
|
||||
public hasTrailingComment() { return false; }
|
||||
public hasSkippedToken() { return false; }
|
||||
public hasLeadingSkippedToken() { return false; }
|
||||
|
||||
public leadingTriviaWidth() { return 0; }
|
||||
public trailingTriviaWidth() { return 0; }
|
||||
|
||||
public leadingTrivia(): ISyntaxTriviaList { return Syntax.emptyTriviaList; }
|
||||
public trailingTrivia(): ISyntaxTriviaList { return Syntax.emptyTriviaList; }
|
||||
}
|
||||
EmptyToken.prototype.childCount = 0;
|
||||
|
||||
@@ -425,7 +411,6 @@ module TypeScript.Syntax {
|
||||
private _isKeywordConvertedToIdentifier: boolean;
|
||||
private _leadingTrivia: ISyntaxTriviaList;
|
||||
private _text: string;
|
||||
private _trailingTrivia: ISyntaxTriviaList;
|
||||
|
||||
public parent: ISyntaxElement;
|
||||
public childCount: number;
|
||||
@@ -434,22 +419,16 @@ module TypeScript.Syntax {
|
||||
public kind: SyntaxKind,
|
||||
isKeywordConvertedToIdentifier: boolean,
|
||||
leadingTrivia: ISyntaxTriviaList,
|
||||
text: string,
|
||||
trailingTrivia: ISyntaxTriviaList) {
|
||||
text: string) {
|
||||
this._fullStart = fullStart;
|
||||
this._isKeywordConvertedToIdentifier = isKeywordConvertedToIdentifier;
|
||||
this._text = text;
|
||||
|
||||
this._leadingTrivia = leadingTrivia.clone();
|
||||
this._trailingTrivia = trailingTrivia.clone();
|
||||
|
||||
if (!this._leadingTrivia.isShared()) {
|
||||
this._leadingTrivia.parent = this;
|
||||
}
|
||||
|
||||
if (!this._trailingTrivia.isShared()) {
|
||||
this._trailingTrivia.parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
public setFullStart(fullStart: number): void {
|
||||
@@ -457,10 +436,9 @@ module TypeScript.Syntax {
|
||||
}
|
||||
|
||||
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
|
||||
public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) }
|
||||
|
||||
public clone(): ISyntaxToken {
|
||||
return new RealizedToken(this._fullStart, this.kind, this._isKeywordConvertedToIdentifier, this._leadingTrivia, this._text, this._trailingTrivia);
|
||||
return new RealizedToken(this._fullStart, this.kind, this._isKeywordConvertedToIdentifier, this._leadingTrivia, this._text);
|
||||
}
|
||||
|
||||
// Realized tokens are created from the parser. They are *never* incrementally reusable.
|
||||
@@ -471,23 +449,18 @@ module TypeScript.Syntax {
|
||||
}
|
||||
|
||||
public fullStart(): number { return this._fullStart; }
|
||||
public fullWidth(): number { return this._leadingTrivia.fullWidth() + this._text.length + this._trailingTrivia.fullWidth(); }
|
||||
public fullWidth(): number { return this._leadingTrivia.fullWidth() + this._text.length; }
|
||||
|
||||
public text(): string { return this._text; }
|
||||
public fullText(): string { return this._leadingTrivia.fullText() + this.text() + this._trailingTrivia.fullText(); }
|
||||
public fullText(): string { return this._leadingTrivia.fullText() + this.text(); }
|
||||
|
||||
public hasLeadingTrivia(): boolean { return this._leadingTrivia.count() > 0; }
|
||||
public hasTrailingTrivia(): boolean { return this._trailingTrivia.count() > 0; }
|
||||
public hasLeadingNewLine(): boolean { return this._leadingTrivia.hasNewLine(); }
|
||||
public hasLeadingComment(): boolean { return this._leadingTrivia.hasComment(); }
|
||||
public hasTrailingComment(): boolean { return this._trailingTrivia.hasComment(); }
|
||||
|
||||
public leadingTriviaWidth(): number { return this._leadingTrivia.fullWidth(); }
|
||||
public trailingTriviaWidth(): number { return this._trailingTrivia.fullWidth(); }
|
||||
|
||||
public hasSkippedToken(): boolean { return this._leadingTrivia.hasSkippedToken() || this._trailingTrivia.hasSkippedToken(); }
|
||||
public hasLeadingSkippedToken(): boolean { return this._leadingTrivia.hasSkippedToken(); }
|
||||
|
||||
public leadingTrivia(): ISyntaxTriviaList { return this._leadingTrivia; }
|
||||
public trailingTrivia(): ISyntaxTriviaList { return this._trailingTrivia; }
|
||||
public leadingTriviaWidth(): number { return this._leadingTrivia.fullWidth(); }
|
||||
}
|
||||
RealizedToken.prototype.childCount = 0;
|
||||
|
||||
@@ -506,7 +479,6 @@ module TypeScript.Syntax {
|
||||
}
|
||||
|
||||
public childAt(index: number): ISyntaxElement { throw Errors.invalidOperation() }
|
||||
public accept(visitor: ISyntaxVisitor): any { return visitor.visitToken(this) }
|
||||
|
||||
public fullStart(): number {
|
||||
return this.underlyingToken.fullStart();
|
||||
@@ -530,25 +502,10 @@ module TypeScript.Syntax {
|
||||
return this.underlyingToken.fullText(this.syntaxTreeText(text));
|
||||
}
|
||||
|
||||
public hasLeadingTrivia(): boolean {
|
||||
return this.underlyingToken.hasLeadingTrivia();
|
||||
}
|
||||
|
||||
public hasTrailingTrivia(): boolean {
|
||||
return this.underlyingToken.hasTrailingTrivia();
|
||||
}
|
||||
|
||||
public hasLeadingComment(): boolean {
|
||||
return this.underlyingToken.hasLeadingComment();
|
||||
}
|
||||
|
||||
public hasTrailingComment(): boolean {
|
||||
return this.underlyingToken.hasTrailingComment();
|
||||
}
|
||||
|
||||
public hasSkippedToken(): boolean {
|
||||
return this.underlyingToken.hasSkippedToken();
|
||||
}
|
||||
public hasLeadingTrivia(): boolean { return this.underlyingToken.hasLeadingTrivia(); }
|
||||
public hasLeadingNewLine(): boolean { return this.underlyingToken.hasLeadingNewLine(); }
|
||||
public hasLeadingComment(): boolean { return this.underlyingToken.hasLeadingComment(); }
|
||||
public hasLeadingSkippedToken(): boolean { return this.underlyingToken.hasLeadingSkippedToken(); }
|
||||
|
||||
public leadingTrivia(text?: ISimpleText): ISyntaxTriviaList {
|
||||
var result = this.underlyingToken.leadingTrivia(this.syntaxTreeText(text));
|
||||
@@ -556,20 +513,10 @@ module TypeScript.Syntax {
|
||||
return result;
|
||||
}
|
||||
|
||||
public trailingTrivia(text?: ISimpleText): ISyntaxTriviaList {
|
||||
var result = this.underlyingToken.trailingTrivia(this.syntaxTreeText(text));
|
||||
result.parent = this;
|
||||
return result;
|
||||
}
|
||||
|
||||
public leadingTriviaWidth(text?: ISimpleText): number {
|
||||
return this.underlyingToken.leadingTriviaWidth(this.syntaxTreeText(text));
|
||||
}
|
||||
|
||||
public trailingTriviaWidth(text?: ISimpleText): number {
|
||||
return this.underlyingToken.trailingTriviaWidth(this.syntaxTreeText(text));
|
||||
}
|
||||
|
||||
public isKeywordConvertedToIdentifier(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -814,7 +814,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
private checkForDisallowedImportDeclaration(node: ModuleDeclarationSyntax): boolean {
|
||||
if (!node.stringLiteral) {
|
||||
if (node.name.kind !== SyntaxKind.StringLiteral) {
|
||||
for (var i = 0, n = node.moduleElements.length; i < n; i++) {
|
||||
var child = node.moduleElements[i];
|
||||
if (child.kind === SyntaxKind.ImportDeclaration) {
|
||||
@@ -849,21 +849,21 @@ module TypeScript {
|
||||
|
||||
public visitModuleDeclaration(node: ModuleDeclarationSyntax): void {
|
||||
if (this.checkForDisallowedDeclareModifier(node.modifiers) ||
|
||||
this.checkForRequiredDeclareModifier(node, node.stringLiteral ? node.stringLiteral : firstToken(node.name), node.modifiers) ||
|
||||
this.checkForRequiredDeclareModifier(node, firstToken(node.name), node.modifiers) ||
|
||||
this.checkModuleElementModifiers(node.modifiers) ||
|
||||
this.checkForDisallowedImportDeclaration(node)) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.stringLiteral) {
|
||||
if (node.name.kind === SyntaxKind.StringLiteral) {
|
||||
if (!this.inAmbientDeclaration && !SyntaxUtilities.containsToken(node.modifiers, SyntaxKind.DeclareKeyword)) {
|
||||
this.pushDiagnostic(node.stringLiteral, DiagnosticCode.Only_ambient_modules_can_use_quoted_names);
|
||||
this.pushDiagnostic(node.name, DiagnosticCode.Only_ambient_modules_can_use_quoted_names);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!node.stringLiteral && this.checkForDisallowedExportAssignment(node)) {
|
||||
if (node.name.kind !== SyntaxKind.StringLiteral && this.checkForDisallowedExportAssignment(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1158,7 +1158,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
private checkForInLeftHandSideExpression(node: ForInStatementSyntax): boolean {
|
||||
if (node.left && !SyntaxUtilities.isLeftHandSizeExpression(node.left)) {
|
||||
if (node.left.kind !== SyntaxKind.VariableDeclaration && !SyntaxUtilities.isLeftHandSizeExpression(node.left)) {
|
||||
this.pushDiagnostic(node.left, DiagnosticCode.Invalid_left_hand_side_in_for_in_statement);
|
||||
return true;
|
||||
}
|
||||
@@ -1170,8 +1170,8 @@ module TypeScript {
|
||||
// The parser accepts a Variable Declaration in a ForInStatement, but the grammar only
|
||||
// allows a very restricted form. Specifically, there must be only a single Variable
|
||||
// Declarator in the Declaration.
|
||||
if (node.variableDeclaration && node.variableDeclaration.variableDeclarators.length > 1) {
|
||||
this.pushDiagnostic(node.variableDeclaration, DiagnosticCode.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement);
|
||||
if (node.left.kind === SyntaxKind.VariableDeclaration && (<VariableDeclarationSyntax>node.left).variableDeclarators.length > 1) {
|
||||
this.pushDiagnostic(node.left, DiagnosticCode.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
module TypeScript {
|
||||
export interface ISyntaxTrivia {
|
||||
parent?: ISyntaxTriviaList;
|
||||
kind(): SyntaxKind;
|
||||
parent: ISyntaxTriviaList;
|
||||
kind: SyntaxKind;
|
||||
|
||||
isWhitespace(): boolean;
|
||||
isComment(): boolean;
|
||||
@@ -25,11 +25,9 @@ module TypeScript {
|
||||
|
||||
module TypeScript.Syntax {
|
||||
class AbstractTrivia implements ISyntaxTrivia {
|
||||
constructor(private _kind: SyntaxKind) {
|
||||
}
|
||||
public parent: ISyntaxTriviaList;
|
||||
|
||||
public kind(): SyntaxKind {
|
||||
return this._kind;
|
||||
constructor(public kind: SyntaxKind) {
|
||||
}
|
||||
|
||||
public clone(): ISyntaxTrivia {
|
||||
@@ -53,19 +51,19 @@ module TypeScript.Syntax {
|
||||
}
|
||||
|
||||
public isWhitespace(): boolean {
|
||||
return this.kind() === SyntaxKind.WhitespaceTrivia;
|
||||
return this.kind === SyntaxKind.WhitespaceTrivia;
|
||||
}
|
||||
|
||||
public isComment(): boolean {
|
||||
return this.kind() === SyntaxKind.SingleLineCommentTrivia || this.kind() === SyntaxKind.MultiLineCommentTrivia;
|
||||
return this.kind === SyntaxKind.SingleLineCommentTrivia || this.kind === SyntaxKind.MultiLineCommentTrivia;
|
||||
}
|
||||
|
||||
public isNewLine(): boolean {
|
||||
return this.kind() === SyntaxKind.NewLineTrivia;
|
||||
return this.kind === SyntaxKind.NewLineTrivia;
|
||||
}
|
||||
|
||||
public isSkippedToken(): boolean {
|
||||
return this.kind() === SyntaxKind.SkippedTokenTrivia;
|
||||
return this.kind === SyntaxKind.SkippedTokenTrivia;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +101,7 @@ module TypeScript.Syntax {
|
||||
}
|
||||
|
||||
public clone(): ISyntaxTrivia {
|
||||
return new DeferredTrivia(this.kind(), this._text, this._fullStart, this._fullWidth);
|
||||
return new DeferredTrivia(this.kind, this._text, this._fullStart, this._fullWidth);
|
||||
}
|
||||
|
||||
public fullStart(): number {
|
||||
@@ -129,7 +127,6 @@ module TypeScript.Syntax {
|
||||
|
||||
export function skippedTokenTrivia(token: ISyntaxToken, text: ISimpleText): ISyntaxTrivia {
|
||||
Debug.assert(!token.hasLeadingTrivia());
|
||||
Debug.assert(!token.hasTrailingTrivia());
|
||||
Debug.assert(token.fullWidth() > 0);
|
||||
return new SkippedTokenTrivia(token, token.fullText(text));
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ module TypeScript.Syntax {
|
||||
export var emptyTriviaList: ISyntaxTriviaList = new EmptyTriviaList();
|
||||
|
||||
function isComment(trivia: ISyntaxTrivia): boolean {
|
||||
return trivia.kind() === SyntaxKind.MultiLineCommentTrivia || trivia.kind() === SyntaxKind.SingleLineCommentTrivia;
|
||||
return trivia.kind === SyntaxKind.MultiLineCommentTrivia || trivia.kind === SyntaxKind.SingleLineCommentTrivia;
|
||||
}
|
||||
|
||||
class SingletonSyntaxTriviaList implements ISyntaxTriviaList {
|
||||
@@ -120,11 +120,11 @@ module TypeScript.Syntax {
|
||||
}
|
||||
|
||||
public hasNewLine(): boolean {
|
||||
return this.item.kind() === SyntaxKind.NewLineTrivia;
|
||||
return this.item.kind === SyntaxKind.NewLineTrivia;
|
||||
}
|
||||
|
||||
public hasSkippedToken(): boolean {
|
||||
return this.item.kind() === SyntaxKind.SkippedTokenTrivia;
|
||||
return this.item.kind === SyntaxKind.SkippedTokenTrivia;
|
||||
}
|
||||
|
||||
public toArray(): ISyntaxTrivia[] {
|
||||
@@ -193,7 +193,7 @@ module TypeScript.Syntax {
|
||||
|
||||
public hasNewLine(): boolean {
|
||||
for (var i = 0; i < this.trivia.length; i++) {
|
||||
if (this.trivia[i].kind() === SyntaxKind.NewLineTrivia) {
|
||||
if (this.trivia[i].kind === SyntaxKind.NewLineTrivia) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -203,7 +203,7 @@ module TypeScript.Syntax {
|
||||
|
||||
public hasSkippedToken(): boolean {
|
||||
for (var i = 0; i < this.trivia.length; i++) {
|
||||
if (this.trivia[i].kind() === SyntaxKind.SkippedTokenTrivia) {
|
||||
if (this.trivia[i].kind === SyntaxKind.SkippedTokenTrivia) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ module TypeScript {
|
||||
}
|
||||
|
||||
var lineMap = text.lineMap();
|
||||
var tokenLine = lineMap.getLineNumberFromPosition(end(token, text));
|
||||
var tokenLine = lineMap.getLineNumberFromPosition(fullEnd(token));
|
||||
var nextTokenLine = lineMap.getLineNumberFromPosition(start(_nextToken, text));
|
||||
|
||||
return tokenLine !== nextTokenLine;
|
||||
|
||||
@@ -99,15 +99,13 @@ module TypeScript {
|
||||
this.visitToken(node.functionKeyword);
|
||||
this.visitToken(node.identifier);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
visitNodeOrToken(this, node.block);
|
||||
this.visitOptionalToken(node.semicolonToken);
|
||||
visitNodeOrToken(this, node.body);
|
||||
}
|
||||
|
||||
public visitModuleDeclaration(node: ModuleDeclarationSyntax): void {
|
||||
this.visitList(node.modifiers);
|
||||
this.visitToken(node.moduleKeyword);
|
||||
visitNodeOrToken(this, node.name);
|
||||
this.visitOptionalToken(node.stringLiteral);
|
||||
this.visitToken(node.openBraceToken);
|
||||
this.visitList(node.moduleElements);
|
||||
this.visitToken(node.closeBraceToken);
|
||||
@@ -153,8 +151,7 @@ module TypeScript {
|
||||
this.visitList(node.modifiers);
|
||||
visitNodeOrToken(this, node.propertyName);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
visitNodeOrToken(this, node.block);
|
||||
this.visitOptionalToken(node.semicolonToken);
|
||||
visitNodeOrToken(this, node.body);
|
||||
}
|
||||
|
||||
public visitMemberVariableDeclaration(node: MemberVariableDeclarationSyntax): void {
|
||||
@@ -167,8 +164,7 @@ module TypeScript {
|
||||
this.visitList(node.modifiers);
|
||||
this.visitToken(node.constructorKeyword);
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
visitNodeOrToken(this, node.block);
|
||||
this.visitOptionalToken(node.semicolonToken);
|
||||
visitNodeOrToken(this, node.body);
|
||||
}
|
||||
|
||||
public visitIndexMemberDeclaration(node: IndexMemberDeclarationSyntax): void {
|
||||
@@ -280,7 +276,6 @@ module TypeScript {
|
||||
public visitForStatement(node: ForStatementSyntax): void {
|
||||
this.visitToken(node.forKeyword);
|
||||
this.visitToken(node.openParenToken);
|
||||
visitNodeOrToken(this, node.variableDeclaration);
|
||||
visitNodeOrToken(this, node.initializer);
|
||||
this.visitToken(node.firstSemicolonToken);
|
||||
visitNodeOrToken(this, node.condition);
|
||||
@@ -293,10 +288,9 @@ module TypeScript {
|
||||
public visitForInStatement(node: ForInStatementSyntax): void {
|
||||
this.visitToken(node.forKeyword);
|
||||
this.visitToken(node.openParenToken);
|
||||
visitNodeOrToken(this, node.variableDeclaration);
|
||||
visitNodeOrToken(this, node.left);
|
||||
this.visitToken(node.inKeyword);
|
||||
visitNodeOrToken(this, node.expression);
|
||||
visitNodeOrToken(this, node.right);
|
||||
this.visitToken(node.closeParenToken);
|
||||
visitNodeOrToken(this, node.statement);
|
||||
}
|
||||
@@ -432,15 +426,13 @@ module TypeScript {
|
||||
public visitParenthesizedArrowFunctionExpression(node: ParenthesizedArrowFunctionExpressionSyntax): void {
|
||||
visitNodeOrToken(this, node.callSignature);
|
||||
this.visitToken(node.equalsGreaterThanToken);
|
||||
visitNodeOrToken(this, node.block);
|
||||
visitNodeOrToken(this, node.expression);
|
||||
visitNodeOrToken(this, node.body);
|
||||
}
|
||||
|
||||
public visitSimpleArrowFunctionExpression(node: SimpleArrowFunctionExpressionSyntax): void {
|
||||
visitNodeOrToken(this, node.parameter);
|
||||
this.visitToken(node.equalsGreaterThanToken);
|
||||
visitNodeOrToken(this, node.block);
|
||||
visitNodeOrToken(this, node.expression);
|
||||
visitNodeOrToken(this, node.body);
|
||||
}
|
||||
|
||||
public visitCastExpression(node: CastExpressionSyntax): void {
|
||||
|
||||
@@ -69,10 +69,8 @@ module TypeScript {
|
||||
token1.fullStart() === token2.fullStart() &&
|
||||
TypeScript.fullEnd(token1) === TypeScript.fullEnd(token2) &&
|
||||
TypeScript.start(token1, text1) === TypeScript.start(token2, text2) &&
|
||||
TypeScript.end(token1, text1) === TypeScript.end(token2, text2) &&
|
||||
token1.text() === token2.text() &&
|
||||
triviaListStructuralEquals(token1.leadingTrivia(text1), token2.leadingTrivia(text2)) &&
|
||||
triviaListStructuralEquals(token1.trailingTrivia(text1), token2.trailingTrivia(text2));
|
||||
triviaListStructuralEquals(token1.leadingTrivia(text1), token2.leadingTrivia(text2));
|
||||
}
|
||||
|
||||
export function triviaListStructuralEquals(triviaList1: TypeScript.ISyntaxTriviaList, triviaList2: TypeScript.ISyntaxTriviaList): boolean {
|
||||
@@ -150,10 +148,6 @@ module TypeScript {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TypeScript.end(element1) !== TypeScript.end(element2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TypeScript.fullEnd(element1) !== TypeScript.fullEnd(element2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -220,19 +220,13 @@ module ts {
|
||||
}
|
||||
|
||||
function nodeHasTokens(n: Node): boolean {
|
||||
if (n.kind === SyntaxKind.ExpressionStatement) {
|
||||
return nodeHasTokens((<ExpressionStatement>n).expression);
|
||||
}
|
||||
|
||||
if (n.kind === SyntaxKind.EndOfFileToken ||
|
||||
n.kind === SyntaxKind.OmittedExpression ||
|
||||
n.kind === SyntaxKind.Missing ||
|
||||
n.kind === SyntaxKind.Unknown) {
|
||||
if (n.kind === SyntaxKind.Unknown) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// SyntaxList is already realized so getChildCount should be fast and non-expensive
|
||||
return n.kind !== SyntaxKind.SyntaxList || n.getChildCount() !== 0;
|
||||
// If we have a token or node that has a non-zero width, it must have tokens.
|
||||
// Note, that getWidth() does not take trivia into account.
|
||||
return n.getWidth() !== 0;
|
||||
}
|
||||
|
||||
export function getTypeArgumentOrTypeParameterList(node: Node): NodeArray<Node> {
|
||||
@@ -259,10 +253,6 @@ module ts {
|
||||
return n.kind === SyntaxKind.StringLiteral || n.kind === SyntaxKind.NumericLiteral || isWord(n);
|
||||
}
|
||||
|
||||
export var switchToForwardSlashesRegEx = /\\/g;
|
||||
export function switchToForwardSlashes(path: string) {
|
||||
return path.replace(switchToForwardSlashesRegEx, "/");
|
||||
}
|
||||
export function isComment(n: Node): boolean {
|
||||
return n.kind === SyntaxKind.SingleLineCommentTrivia || n.kind === SyntaxKind.MultiLineCommentTrivia;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ var VisualizationModel = (function (_super) {
|
||||
})(Backbone.Model);
|
||||
exports.VisualizationModel = VisualizationModel;
|
||||
//// [aliasUsageInIndexerOfClass_main.js]
|
||||
var moduleA = require("aliasUsageInIndexerOfClass_moduleA");
|
||||
var N = (function () {
|
||||
function N() {
|
||||
this.x = moduleA;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
class Foo<T extends Foo.Bar> {
|
||||
>Foo : Foo<T>
|
||||
>T : T
|
||||
>Foo : Foo<T>
|
||||
>Foo : unknown
|
||||
>Bar : Foo.Bar
|
||||
|
||||
constructor() {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
//// [tests/cases/compiler/elidingImportNames.ts] ////
|
||||
|
||||
//// [elidingImportNames_test.ts]
|
||||
|
||||
import a = require('elidingImportNames_main'); // alias used in typeof
|
||||
var b = a;
|
||||
var x: typeof a;
|
||||
import a2 = require('elidingImportNames_main1'); // alias not used in typeof
|
||||
var b2 = a2;
|
||||
|
||||
|
||||
//// [elidingImportNames_main.ts]
|
||||
export var main = 10;
|
||||
|
||||
//// [elidingImportNames_main1.ts]
|
||||
export var main = 10;
|
||||
|
||||
//// [elidingImportNames_main.js]
|
||||
exports.main = 10;
|
||||
//// [elidingImportNames_main1.js]
|
||||
exports.main = 10;
|
||||
//// [elidingImportNames_test.js]
|
||||
var a = require('elidingImportNames_main'); // alias used in typeof
|
||||
var b = a;
|
||||
var x;
|
||||
var a2 = require('elidingImportNames_main1'); // alias not used in typeof
|
||||
var b2 = a2;
|
||||
@@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/elidingImportNames_test.ts ===
|
||||
|
||||
import a = require('elidingImportNames_main'); // alias used in typeof
|
||||
>a : typeof a
|
||||
|
||||
var b = a;
|
||||
>b : typeof a
|
||||
>a : typeof a
|
||||
|
||||
var x: typeof a;
|
||||
>x : typeof a
|
||||
>a : typeof a
|
||||
|
||||
import a2 = require('elidingImportNames_main1'); // alias not used in typeof
|
||||
>a2 : typeof a2
|
||||
|
||||
var b2 = a2;
|
||||
>b2 : typeof a2
|
||||
>a2 : typeof a2
|
||||
|
||||
|
||||
=== tests/cases/compiler/elidingImportNames_main.ts ===
|
||||
export var main = 10;
|
||||
>main : number
|
||||
|
||||
=== tests/cases/compiler/elidingImportNames_main1.ts ===
|
||||
export var main = 10;
|
||||
>main : number
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
//// [escapedReservedCompilerNamedIdentifier.ts]
|
||||
// double underscores
|
||||
var __proto__ = 10;
|
||||
var o = {
|
||||
"__proto__": 0
|
||||
};
|
||||
var b = o["__proto__"];
|
||||
var o1 = {
|
||||
__proto__: 0
|
||||
};
|
||||
var b1 = o1["__proto__"];
|
||||
// Triple underscores
|
||||
var ___proto__ = 10;
|
||||
var o2 = {
|
||||
"___proto__": 0
|
||||
};
|
||||
var b2 = o2["___proto__"];
|
||||
var o3 = {
|
||||
___proto__: 0
|
||||
};
|
||||
var b3 = o3["___proto__"];
|
||||
// One underscore
|
||||
var _proto__ = 10;
|
||||
var o4 = {
|
||||
"_proto__": 0
|
||||
};
|
||||
var b4 = o4["_proto__"];
|
||||
var o5 = {
|
||||
_proto__: 0
|
||||
};
|
||||
var b5 = o5["_proto__"];
|
||||
|
||||
//// [escapedReservedCompilerNamedIdentifier.js]
|
||||
// double underscores
|
||||
var __proto__ = 10;
|
||||
var o = {
|
||||
"__proto__": 0
|
||||
};
|
||||
var b = o["__proto__"];
|
||||
var o1 = {
|
||||
__proto__: 0
|
||||
};
|
||||
var b1 = o1["__proto__"];
|
||||
// Triple underscores
|
||||
var ___proto__ = 10;
|
||||
var o2 = {
|
||||
"___proto__": 0
|
||||
};
|
||||
var b2 = o2["___proto__"];
|
||||
var o3 = {
|
||||
___proto__: 0
|
||||
};
|
||||
var b3 = o3["___proto__"];
|
||||
// One underscore
|
||||
var _proto__ = 10;
|
||||
var o4 = {
|
||||
"_proto__": 0
|
||||
};
|
||||
var b4 = o4["_proto__"];
|
||||
var o5 = {
|
||||
_proto__: 0
|
||||
};
|
||||
var b5 = o5["_proto__"];
|
||||
|
||||
|
||||
//// [escapedReservedCompilerNamedIdentifier.d.ts]
|
||||
declare var __proto__: number;
|
||||
declare var o: {
|
||||
"__proto__": number;
|
||||
};
|
||||
declare var b: number;
|
||||
declare var o1: {
|
||||
__proto__: number;
|
||||
};
|
||||
declare var b1: number;
|
||||
declare var ___proto__: number;
|
||||
declare var o2: {
|
||||
"___proto__": number;
|
||||
};
|
||||
declare var b2: number;
|
||||
declare var o3: {
|
||||
___proto__: number;
|
||||
};
|
||||
declare var b3: number;
|
||||
declare var _proto__: number;
|
||||
declare var o4: {
|
||||
"_proto__": number;
|
||||
};
|
||||
declare var b4: number;
|
||||
declare var o5: {
|
||||
_proto__: number;
|
||||
};
|
||||
declare var b5: number;
|
||||
@@ -0,0 +1,85 @@
|
||||
=== tests/cases/compiler/escapedReservedCompilerNamedIdentifier.ts ===
|
||||
// double underscores
|
||||
var __proto__ = 10;
|
||||
>__proto__ : number
|
||||
|
||||
var o = {
|
||||
>o : { "__proto__": number; }
|
||||
>{ "__proto__": 0} : { "__proto__": number; }
|
||||
|
||||
"__proto__": 0
|
||||
};
|
||||
var b = o["__proto__"];
|
||||
>b : number
|
||||
>o["__proto__"] : number
|
||||
>o : { "__proto__": number; }
|
||||
|
||||
var o1 = {
|
||||
>o1 : { __proto__: number; }
|
||||
>{ __proto__: 0} : { __proto__: number; }
|
||||
|
||||
__proto__: 0
|
||||
>__proto__ : number
|
||||
|
||||
};
|
||||
var b1 = o1["__proto__"];
|
||||
>b1 : number
|
||||
>o1["__proto__"] : number
|
||||
>o1 : { __proto__: number; }
|
||||
|
||||
// Triple underscores
|
||||
var ___proto__ = 10;
|
||||
>___proto__ : number
|
||||
|
||||
var o2 = {
|
||||
>o2 : { "___proto__": number; }
|
||||
>{ "___proto__": 0} : { "___proto__": number; }
|
||||
|
||||
"___proto__": 0
|
||||
};
|
||||
var b2 = o2["___proto__"];
|
||||
>b2 : number
|
||||
>o2["___proto__"] : number
|
||||
>o2 : { "___proto__": number; }
|
||||
|
||||
var o3 = {
|
||||
>o3 : { ___proto__: number; }
|
||||
>{ ___proto__: 0} : { ___proto__: number; }
|
||||
|
||||
___proto__: 0
|
||||
>___proto__ : number
|
||||
|
||||
};
|
||||
var b3 = o3["___proto__"];
|
||||
>b3 : number
|
||||
>o3["___proto__"] : number
|
||||
>o3 : { ___proto__: number; }
|
||||
|
||||
// One underscore
|
||||
var _proto__ = 10;
|
||||
>_proto__ : number
|
||||
|
||||
var o4 = {
|
||||
>o4 : { "_proto__": number; }
|
||||
>{ "_proto__": 0} : { "_proto__": number; }
|
||||
|
||||
"_proto__": 0
|
||||
};
|
||||
var b4 = o4["_proto__"];
|
||||
>b4 : number
|
||||
>o4["_proto__"] : number
|
||||
>o4 : { "_proto__": number; }
|
||||
|
||||
var o5 = {
|
||||
>o5 : { _proto__: number; }
|
||||
>{ _proto__: 0} : { _proto__: number; }
|
||||
|
||||
_proto__: 0
|
||||
>_proto__ : number
|
||||
|
||||
};
|
||||
var b5 = o5["_proto__"];
|
||||
>b5 : number
|
||||
>o5["_proto__"] : number
|
||||
>o5 : { _proto__: number; }
|
||||
|
||||
@@ -5,7 +5,7 @@ import Foo = require('exportAssignClassAndModule_0');
|
||||
|
||||
var z: Foo.Bar;
|
||||
>z : Foo.Bar
|
||||
>Foo : Foo
|
||||
>Foo : unknown
|
||||
>Bar : Foo.Bar
|
||||
|
||||
var zz: Foo;
|
||||
@@ -23,7 +23,7 @@ class Foo {
|
||||
|
||||
x: Foo.Bar;
|
||||
>x : Foo.Bar
|
||||
>Foo : Foo
|
||||
>Foo : unknown
|
||||
>Bar : Foo.Bar
|
||||
}
|
||||
module Foo {
|
||||
|
||||
@@ -11,7 +11,7 @@ interface server {
|
||||
>server : server
|
||||
|
||||
(): server.Server;
|
||||
>server : server
|
||||
>server : unknown
|
||||
>Server : server.Server
|
||||
|
||||
startTime: Date;
|
||||
|
||||
@@ -61,12 +61,12 @@ import clolias = clodule;
|
||||
|
||||
var p: clolias.Point;
|
||||
>p : alias.Point
|
||||
>clolias : clodule
|
||||
>clolias : unknown
|
||||
>Point : clolias.Point
|
||||
|
||||
var p: clodule.Point;
|
||||
>p : alias.Point
|
||||
>clodule : clodule
|
||||
>clodule : unknown
|
||||
>Point : clolias.Point
|
||||
|
||||
var p: { x: number; y: number; };
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
error TS2318: Cannot find global type 'Boolean'.
|
||||
error TS2318: Cannot find global type 'IArguments'.
|
||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
tests/cases/compiler/noDefaultLib.ts(4,11): error TS2317: Global type 'Array' must have 1 type parameter(s).
|
||||
|
||||
|
||||
!!! error TS2318: Cannot find global type 'Boolean'.
|
||||
!!! error TS2318: Cannot find global type 'IArguments'.
|
||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
==== tests/cases/compiler/noDefaultLib.ts (1 errors) ====
|
||||
/// <reference no-default-lib="true"/>
|
||||
var x;
|
||||
|
||||
@@ -6,6 +6,7 @@ error TS2318: Cannot find global type 'Number'.
|
||||
error TS2318: Cannot find global type 'Object'.
|
||||
error TS2318: Cannot find global type 'RegExp'.
|
||||
error TS2318: Cannot find global type 'String'.
|
||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
|
||||
|
||||
!!! error TS2318: Cannot find global type 'Array'.
|
||||
@@ -16,6 +17,7 @@ error TS2318: Cannot find global type 'String'.
|
||||
!!! error TS2318: Cannot find global type 'Object'.
|
||||
!!! error TS2318: Cannot find global type 'RegExp'.
|
||||
!!! error TS2318: Cannot find global type 'String'.
|
||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts (0 errors) ====
|
||||
/// <style requireSemi="on" />
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ interface Foo<T> {
|
||||
}
|
||||
var Foo: new () => Foo.A<Foo<string>>;
|
||||
>Foo : new () => Foo.A<Foo<string>>
|
||||
>Foo : Foo<T>
|
||||
>Foo : unknown
|
||||
>A : Foo.A<T>
|
||||
>Foo : Foo<T>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ error TS2318: Cannot find global type 'Number'.
|
||||
error TS2318: Cannot find global type 'Object'.
|
||||
error TS2318: Cannot find global type 'RegExp'.
|
||||
error TS2318: Cannot find global type 'String'.
|
||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
test.ts(3,8): error TS2304: Cannot find name 'Array'.
|
||||
|
||||
|
||||
@@ -17,6 +18,7 @@ test.ts(3,8): error TS2304: Cannot find name 'Array'.
|
||||
!!! error TS2318: Cannot find global type 'Object'.
|
||||
!!! error TS2318: Cannot find global type 'RegExp'.
|
||||
!!! error TS2318: Cannot find global type 'String'.
|
||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
==== test.ts (1 errors) ====
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ error TS2318: Cannot find global type 'Number'.
|
||||
error TS2318: Cannot find global type 'Object'.
|
||||
error TS2318: Cannot find global type 'RegExp'.
|
||||
error TS2318: Cannot find global type 'String'.
|
||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
test.ts(3,8): error TS2304: Cannot find name 'Array'.
|
||||
|
||||
|
||||
@@ -17,6 +18,7 @@ test.ts(3,8): error TS2304: Cannot find name 'Array'.
|
||||
!!! error TS2318: Cannot find global type 'Object'.
|
||||
!!! error TS2318: Cannot find global type 'RegExp'.
|
||||
!!! error TS2318: Cannot find global type 'String'.
|
||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
==== test.ts (1 errors) ====
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ WorkspacePrototype['__proto__'] = EntityPrototype;
|
||||
>EntityPrototype : any
|
||||
|
||||
var o = {
|
||||
>o : {}
|
||||
>{ "__proto__": 0} : {}
|
||||
>o : { "__proto__": number; }
|
||||
>{ "__proto__": 0} : { "__proto__": number; }
|
||||
|
||||
"__proto__": 0
|
||||
};
|
||||
|
||||
@@ -0,0 +1,190 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(5,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(9,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(13,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(16,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(20,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(23,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(27,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(28,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(29,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(33,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(34,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(35,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(39,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(40,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(41,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(45,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(46,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(47,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(51,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(52,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(53,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(57,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(58,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(64,11): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,11): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(81,11): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(86,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(90,11): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(64,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts(77,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInference.ts (30 errors) ====
|
||||
|
||||
|
||||
// Generic tag with one parameter
|
||||
function noParams<T>(n: T) { }
|
||||
noParams ``;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// Generic tag with parameter which does not use type parameter
|
||||
function noGenericParams<T>(n: string[]) { }
|
||||
noGenericParams ``;
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// Generic tag with multiple type parameters and only one used in parameter type annotation
|
||||
function someGenerics1a<T, U>(n: T, m: number) { }
|
||||
someGenerics1a `${3}`;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
function someGenerics1b<T, U>(n: string[], m: U) { }
|
||||
someGenerics1b `${3}`;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// Generic tag with argument of function type whose parameter is of type parameter type
|
||||
function someGenerics2a<T>(strs: string[], n: (x: T) => void) { }
|
||||
someGenerics2a `${(n: string) => n}`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
function someGenerics2b<T, U>(strs: string[], n: (x: T, y: U) => void) { }
|
||||
someGenerics2b `${ (n: string, x: number) => n }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter
|
||||
function someGenerics3<T>(strs: string[], producer: () => T) { }
|
||||
someGenerics3 `${() => ''}`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
someGenerics3 `${() => undefined}`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
someGenerics3 `${() => 3}`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type
|
||||
function someGenerics4<T, U>(strs: string[], n: T, f: (x: U) => void) { }
|
||||
someGenerics4 `${4}${ () => null }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
someGenerics4 `${''}${ () => 3 }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
someGenerics4 `${ null }${ null }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type
|
||||
function someGenerics5<U, T>(strs: string[], n: T, f: (x: U) => void) { }
|
||||
someGenerics5 `${ 4 } ${ () => null }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
someGenerics5 `${ '' }${ () => 3 }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
someGenerics5 `${null}${null}`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// Generic tag with multiple arguments of function types that each have parameters of the same generic type
|
||||
function someGenerics6<A>(strs: string[], a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { }
|
||||
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
someGenerics6 `${ (n: number) => n }${ (n: number) => n }${ (n: number) => n }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// Generic tag with multiple arguments of function types that each have parameters of different generic type
|
||||
function someGenerics7<A, B, C>(strs: string[], a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { }
|
||||
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
someGenerics7 `${(n: number) => n}${ (n: string) => n}${ (n: number) => n}`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// Generic tag with argument of generic function type
|
||||
function someGenerics8<T>(strs: string[], n: T): T { return n; }
|
||||
var x = someGenerics8 `${ someGenerics7 }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
x `${null}${null}${null}`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// Generic tag with multiple parameters of generic type passed arguments with no best common type
|
||||
function someGenerics9<T>(strs: string[], a: T, b: T, c: T): T {
|
||||
return null;
|
||||
}
|
||||
var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'.
|
||||
var a9a: {};
|
||||
|
||||
// Generic tag with multiple parameters of generic type passed arguments with multiple best common types
|
||||
interface A91 {
|
||||
x: number;
|
||||
y?: string;
|
||||
}
|
||||
interface A92 {
|
||||
x: number;
|
||||
z?: Date;
|
||||
}
|
||||
|
||||
var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
!!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
|
||||
var a9e: {};
|
||||
|
||||
// Generic tag with multiple parameters of generic type passed arguments with a single best common type
|
||||
var a9d = someGenerics9 `${ { x: 3 }}${ { x: 6 }}${ { x: 6 } }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var a9d: { x: number; };
|
||||
|
||||
// Generic tag with multiple parameters of generic type where one argument is of type 'any'
|
||||
var anyVar: any;
|
||||
var a = someGenerics9 `${ 7 }${ anyVar }${ 4 }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var a: any;
|
||||
|
||||
// Generic tag with multiple parameters of generic type where one argument is [] and the other is not 'any'
|
||||
var arr = someGenerics9 `${ [] }${ null }${ undefined }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var arr: any[];
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(63,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts(76,11): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsTypeArgumentInferenceES6.ts (2 errors) ====
|
||||
|
||||
// Generic tag with one parameter
|
||||
function noParams<T>(n: T) { }
|
||||
noParams ``;
|
||||
|
||||
// Generic tag with parameter which does not use type parameter
|
||||
function noGenericParams<T>(n: string[]) { }
|
||||
noGenericParams ``;
|
||||
|
||||
// Generic tag with multiple type parameters and only one used in parameter type annotation
|
||||
function someGenerics1a<T, U>(n: T, m: number) { }
|
||||
someGenerics1a `${3}`;
|
||||
|
||||
function someGenerics1b<T, U>(n: string[], m: U) { }
|
||||
someGenerics1b `${3}`;
|
||||
|
||||
// Generic tag with argument of function type whose parameter is of type parameter type
|
||||
function someGenerics2a<T>(strs: string[], n: (x: T) => void) { }
|
||||
someGenerics2a `${(n: string) => n}`;
|
||||
|
||||
function someGenerics2b<T, U>(strs: string[], n: (x: T, y: U) => void) { }
|
||||
someGenerics2b `${ (n: string, x: number) => n }`;
|
||||
|
||||
// Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter
|
||||
function someGenerics3<T>(strs: string[], producer: () => T) { }
|
||||
someGenerics3 `${() => ''}`;
|
||||
someGenerics3 `${() => undefined}`;
|
||||
someGenerics3 `${() => 3}`;
|
||||
|
||||
// 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type
|
||||
function someGenerics4<T, U>(strs: string[], n: T, f: (x: U) => void) { }
|
||||
someGenerics4 `${4}${ () => null }`;
|
||||
someGenerics4 `${''}${ () => 3 }`;
|
||||
someGenerics4 `${ null }${ null }`;
|
||||
|
||||
// 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type
|
||||
function someGenerics5<U, T>(strs: string[], n: T, f: (x: U) => void) { }
|
||||
someGenerics5 `${ 4 } ${ () => null }`;
|
||||
someGenerics5 `${ '' }${ () => 3 }`;
|
||||
someGenerics5 `${null}${null}`;
|
||||
|
||||
// Generic tag with multiple arguments of function types that each have parameters of the same generic type
|
||||
function someGenerics6<A>(strs: string[], a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { }
|
||||
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
|
||||
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
|
||||
someGenerics6 `${ (n: number) => n }${ (n: number) => n }${ (n: number) => n }`;
|
||||
|
||||
// Generic tag with multiple arguments of function types that each have parameters of different generic type
|
||||
function someGenerics7<A, B, C>(strs: string[], a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { }
|
||||
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
|
||||
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
|
||||
someGenerics7 `${(n: number) => n}${ (n: string) => n}${ (n: number) => n}`;
|
||||
|
||||
// Generic tag with argument of generic function type
|
||||
function someGenerics8<T>(strs: string[], n: T): T { return n; }
|
||||
var x = someGenerics8 `${ someGenerics7 }`;
|
||||
x `${null}${null}${null}`;
|
||||
|
||||
// Generic tag with multiple parameters of generic type passed arguments with no best common type
|
||||
function someGenerics9<T>(strs: string[], a: T, b: T, c: T): T {
|
||||
return null;
|
||||
}
|
||||
var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'number'.
|
||||
var a9a: {};
|
||||
|
||||
// Generic tag with multiple parameters of generic type passed arguments with multiple best common types
|
||||
interface A91 {
|
||||
x: number;
|
||||
y?: string;
|
||||
}
|
||||
interface A92 {
|
||||
x: number;
|
||||
z?: Date;
|
||||
}
|
||||
|
||||
var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
!!! error TS2453: Type argument candidate '{ x: number; z: Date; }' is not a valid type argument because it is not a supertype of candidate '{ x: number; y: string; }'.
|
||||
var a9e: {};
|
||||
|
||||
// Generic tag with multiple parameters of generic type passed arguments with a single best common type
|
||||
var a9d = someGenerics9 `${ { x: 3 }}${ { x: 6 }}${ { x: 6 } }`;
|
||||
var a9d: { x: number; };
|
||||
|
||||
// Generic tag with multiple parameters of generic type where one argument is of type 'any'
|
||||
var anyVar: any;
|
||||
var a = someGenerics9 `${ 7 }${ anyVar }${ 4 }`;
|
||||
var a: any;
|
||||
|
||||
// Generic tag with multiple parameters of generic type where one argument is [] and the other is not 'any'
|
||||
var arr = someGenerics9 `${ [] }${ null }${ undefined }`;
|
||||
var arr: any[];
|
||||
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
//// [taggedTemplateStringsTypeArgumentInferenceES6.ts]
|
||||
|
||||
// Generic tag with one parameter
|
||||
function noParams<T>(n: T) { }
|
||||
noParams ``;
|
||||
|
||||
// Generic tag with parameter which does not use type parameter
|
||||
function noGenericParams<T>(n: string[]) { }
|
||||
noGenericParams ``;
|
||||
|
||||
// Generic tag with multiple type parameters and only one used in parameter type annotation
|
||||
function someGenerics1a<T, U>(n: T, m: number) { }
|
||||
someGenerics1a `${3}`;
|
||||
|
||||
function someGenerics1b<T, U>(n: string[], m: U) { }
|
||||
someGenerics1b `${3}`;
|
||||
|
||||
// Generic tag with argument of function type whose parameter is of type parameter type
|
||||
function someGenerics2a<T>(strs: string[], n: (x: T) => void) { }
|
||||
someGenerics2a `${(n: string) => n}`;
|
||||
|
||||
function someGenerics2b<T, U>(strs: string[], n: (x: T, y: U) => void) { }
|
||||
someGenerics2b `${ (n: string, x: number) => n }`;
|
||||
|
||||
// Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter
|
||||
function someGenerics3<T>(strs: string[], producer: () => T) { }
|
||||
someGenerics3 `${() => ''}`;
|
||||
someGenerics3 `${() => undefined}`;
|
||||
someGenerics3 `${() => 3}`;
|
||||
|
||||
// 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type
|
||||
function someGenerics4<T, U>(strs: string[], n: T, f: (x: U) => void) { }
|
||||
someGenerics4 `${4}${ () => null }`;
|
||||
someGenerics4 `${''}${ () => 3 }`;
|
||||
someGenerics4 `${ null }${ null }`;
|
||||
|
||||
// 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type
|
||||
function someGenerics5<U, T>(strs: string[], n: T, f: (x: U) => void) { }
|
||||
someGenerics5 `${ 4 } ${ () => null }`;
|
||||
someGenerics5 `${ '' }${ () => 3 }`;
|
||||
someGenerics5 `${null}${null}`;
|
||||
|
||||
// Generic tag with multiple arguments of function types that each have parameters of the same generic type
|
||||
function someGenerics6<A>(strs: string[], a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { }
|
||||
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
|
||||
someGenerics6 `${ n => n }${ n => n}${ n => n}`;
|
||||
someGenerics6 `${ (n: number) => n }${ (n: number) => n }${ (n: number) => n }`;
|
||||
|
||||
// Generic tag with multiple arguments of function types that each have parameters of different generic type
|
||||
function someGenerics7<A, B, C>(strs: string[], a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { }
|
||||
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
|
||||
someGenerics7 `${ n => n }${ n => n }${ n => n }`;
|
||||
someGenerics7 `${(n: number) => n}${ (n: string) => n}${ (n: number) => n}`;
|
||||
|
||||
// Generic tag with argument of generic function type
|
||||
function someGenerics8<T>(strs: string[], n: T): T { return n; }
|
||||
var x = someGenerics8 `${ someGenerics7 }`;
|
||||
x `${null}${null}${null}`;
|
||||
|
||||
// Generic tag with multiple parameters of generic type passed arguments with no best common type
|
||||
function someGenerics9<T>(strs: string[], a: T, b: T, c: T): T {
|
||||
return null;
|
||||
}
|
||||
var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`;
|
||||
var a9a: {};
|
||||
|
||||
// Generic tag with multiple parameters of generic type passed arguments with multiple best common types
|
||||
interface A91 {
|
||||
x: number;
|
||||
y?: string;
|
||||
}
|
||||
interface A92 {
|
||||
x: number;
|
||||
z?: Date;
|
||||
}
|
||||
|
||||
var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`;
|
||||
var a9e: {};
|
||||
|
||||
// Generic tag with multiple parameters of generic type passed arguments with a single best common type
|
||||
var a9d = someGenerics9 `${ { x: 3 }}${ { x: 6 }}${ { x: 6 } }`;
|
||||
var a9d: { x: number; };
|
||||
|
||||
// Generic tag with multiple parameters of generic type where one argument is of type 'any'
|
||||
var anyVar: any;
|
||||
var a = someGenerics9 `${ 7 }${ anyVar }${ 4 }`;
|
||||
var a: any;
|
||||
|
||||
// Generic tag with multiple parameters of generic type where one argument is [] and the other is not 'any'
|
||||
var arr = someGenerics9 `${ [] }${ null }${ undefined }`;
|
||||
var arr: any[];
|
||||
|
||||
|
||||
|
||||
//// [taggedTemplateStringsTypeArgumentInferenceES6.js]
|
||||
// Generic tag with one parameter
|
||||
function noParams(n) {
|
||||
}
|
||||
noParams ``;
|
||||
// Generic tag with parameter which does not use type parameter
|
||||
function noGenericParams(n) {
|
||||
}
|
||||
noGenericParams ``;
|
||||
// Generic tag with multiple type parameters and only one used in parameter type annotation
|
||||
function someGenerics1a(n, m) {
|
||||
}
|
||||
someGenerics1a `${3}`;
|
||||
function someGenerics1b(n, m) {
|
||||
}
|
||||
someGenerics1b `${3}`;
|
||||
// Generic tag with argument of function type whose parameter is of type parameter type
|
||||
function someGenerics2a(strs, n) {
|
||||
}
|
||||
someGenerics2a `${function (n) { return n; }}`;
|
||||
function someGenerics2b(strs, n) {
|
||||
}
|
||||
someGenerics2b `${function (n, x) { return n; }}`;
|
||||
// Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter
|
||||
function someGenerics3(strs, producer) {
|
||||
}
|
||||
someGenerics3 `${function () { return ''; }}`;
|
||||
someGenerics3 `${function () { return undefined; }}`;
|
||||
someGenerics3 `${function () { return 3; }}`;
|
||||
// 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type
|
||||
function someGenerics4(strs, n, f) {
|
||||
}
|
||||
someGenerics4 `${4}${function () { return null; }}`;
|
||||
someGenerics4 `${''}${function () { return 3; }}`;
|
||||
someGenerics4 `${null}${null}`;
|
||||
// 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type
|
||||
function someGenerics5(strs, n, f) {
|
||||
}
|
||||
someGenerics5 `${4} ${function () { return null; }}`;
|
||||
someGenerics5 `${''}${function () { return 3; }}`;
|
||||
someGenerics5 `${null}${null}`;
|
||||
// Generic tag with multiple arguments of function types that each have parameters of the same generic type
|
||||
function someGenerics6(strs, a, b, c) {
|
||||
}
|
||||
someGenerics6 `${function (n) { return n; }}${function (n) { return n; }}${function (n) { return n; }}`;
|
||||
someGenerics6 `${function (n) { return n; }}${function (n) { return n; }}${function (n) { return n; }}`;
|
||||
someGenerics6 `${function (n) { return n; }}${function (n) { return n; }}${function (n) { return n; }}`;
|
||||
// Generic tag with multiple arguments of function types that each have parameters of different generic type
|
||||
function someGenerics7(strs, a, b, c) {
|
||||
}
|
||||
someGenerics7 `${function (n) { return n; }}${function (n) { return n; }}${function (n) { return n; }}`;
|
||||
someGenerics7 `${function (n) { return n; }}${function (n) { return n; }}${function (n) { return n; }}`;
|
||||
someGenerics7 `${function (n) { return n; }}${function (n) { return n; }}${function (n) { return n; }}`;
|
||||
// Generic tag with argument of generic function type
|
||||
function someGenerics8(strs, n) {
|
||||
return n;
|
||||
}
|
||||
var x = someGenerics8 `${someGenerics7}`;
|
||||
x `${null}${null}${null}`;
|
||||
// Generic tag with multiple parameters of generic type passed arguments with no best common type
|
||||
function someGenerics9(strs, a, b, c) {
|
||||
return null;
|
||||
}
|
||||
var a9a = someGenerics9 `${''}${0}${[]}`;
|
||||
var a9a;
|
||||
var a9e = someGenerics9 `${undefined}${{ x: 6, z: new Date() }}${{ x: 6, y: '' }}`;
|
||||
var a9e;
|
||||
// Generic tag with multiple parameters of generic type passed arguments with a single best common type
|
||||
var a9d = someGenerics9 `${{ x: 3 }}${{ x: 6 }}${{ x: 6 }}`;
|
||||
var a9d;
|
||||
// Generic tag with multiple parameters of generic type where one argument is of type 'any'
|
||||
var anyVar;
|
||||
var a = someGenerics9 `${7}${anyVar}${4}`;
|
||||
var a;
|
||||
// Generic tag with multiple parameters of generic type where one argument is [] and the other is not 'any'
|
||||
var arr = someGenerics9 `${[]}${null}${undefined}`;
|
||||
var arr;
|
||||
+27
-1
@@ -8,9 +8,17 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,57): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (10 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (18 errors) ====
|
||||
interface I {
|
||||
(stringParts: string[], ...rest: boolean[]): I;
|
||||
g: I;
|
||||
@@ -29,6 +37,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped
|
||||
f `abc${1}def${2}ghi`;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc`.member
|
||||
~~~~~~~
|
||||
@@ -37,6 +47,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped
|
||||
f `abc${1}def${2}ghi`.member;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc`["member"];
|
||||
~~~~~~~
|
||||
@@ -45,18 +57,32 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped
|
||||
f `abc${1}def${2}ghi`["member"];
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc`[0].member `abc${1}def${2}ghi`;
|
||||
~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f.thisIsNotATag(`abc`);
|
||||
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(14,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(18,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(22,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(24,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(26,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(28,57): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts (6 errors) ====
|
||||
interface I {
|
||||
(stringParts: string[], ...rest: boolean[]): I;
|
||||
g: I;
|
||||
h: I;
|
||||
member: I;
|
||||
thisIsNotATag(x: string): void
|
||||
[x: number]: I;
|
||||
}
|
||||
|
||||
var f: I;
|
||||
|
||||
f `abc`
|
||||
|
||||
f `abc${1}def${2}ghi`;
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc`.member
|
||||
|
||||
f `abc${1}def${2}ghi`.member;
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc`["member"];
|
||||
|
||||
f `abc${1}def${2}ghi`["member"];
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc`[0].member `abc${1}def${2}ghi`;
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`;
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'.
|
||||
|
||||
f.thisIsNotATag(`abc`);
|
||||
|
||||
f.thisIsNotATag(`abc${1}def${2}ghi`);
|
||||
@@ -26,10 +26,11 @@ f `abc`[0].member `abc${1}def${2}ghi`;
|
||||
|
||||
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
|
||||
|
||||
f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`;
|
||||
|
||||
f.thisIsNotATag(`abc`);
|
||||
|
||||
f.thisIsNotATag(`abc${1}def${2}ghi`);
|
||||
|
||||
f.thisIsNotATag(`abc${1}def${2}ghi`);
|
||||
|
||||
//// [taggedTemplateStringsWithIncompatibleTypedTagsES6.js]
|
||||
var f;
|
||||
@@ -41,5 +42,6 @@ f `abc`["member"];
|
||||
f `abc${1}def${2}ghi`["member"];
|
||||
f `abc`[0].member `abc${1}def${2}ghi`;
|
||||
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
|
||||
f `abc${true}def${true}ghi`["member"].member `abc${1}def${2}ghi`;
|
||||
f.thisIsNotATag(`abc`);
|
||||
f.thisIsNotATag(`abc${1}def${2}ghi`);
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts ===
|
||||
interface I {
|
||||
>I : I
|
||||
|
||||
(stringParts: string[], ...rest: boolean[]): I;
|
||||
>stringParts : string[]
|
||||
>rest : boolean[]
|
||||
>I : I
|
||||
|
||||
g: I;
|
||||
>g : I
|
||||
>I : I
|
||||
|
||||
h: I;
|
||||
>h : I
|
||||
>I : I
|
||||
|
||||
member: I;
|
||||
>member : I
|
||||
>I : I
|
||||
|
||||
thisIsNotATag(x: string): void
|
||||
>thisIsNotATag : (x: string) => void
|
||||
>x : string
|
||||
|
||||
[x: number]: I;
|
||||
>x : number
|
||||
>I : I
|
||||
}
|
||||
|
||||
var f: I;
|
||||
>f : I
|
||||
>I : I
|
||||
|
||||
f `abc`
|
||||
>f : I
|
||||
|
||||
f `abc${1}def${2}ghi`;
|
||||
>f : I
|
||||
|
||||
f `abc`.member
|
||||
>f `abc`.member : any
|
||||
>f : I
|
||||
>member : any
|
||||
|
||||
f `abc${1}def${2}ghi`.member;
|
||||
>f `abc${1}def${2}ghi`.member : any
|
||||
>f : I
|
||||
>member : any
|
||||
|
||||
f `abc`["member"];
|
||||
>f `abc`["member"] : any
|
||||
>f : I
|
||||
|
||||
f `abc${1}def${2}ghi`["member"];
|
||||
>f `abc${1}def${2}ghi`["member"] : any
|
||||
>f : I
|
||||
|
||||
f `abc`[0].member `abc${1}def${2}ghi`;
|
||||
>f `abc`[0].member : any
|
||||
>f `abc`[0] : any
|
||||
>f : I
|
||||
>member : any
|
||||
|
||||
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
|
||||
>f `abc${1}def${2}ghi`["member"].member : any
|
||||
>f `abc${1}def${2}ghi`["member"] : any
|
||||
>f : I
|
||||
>member : any
|
||||
|
||||
f.thisIsNotATag(`abc`);
|
||||
>f.thisIsNotATag(`abc`) : void
|
||||
>f.thisIsNotATag : (x: string) => void
|
||||
>f : I
|
||||
>thisIsNotATag : (x: string) => void
|
||||
|
||||
f.thisIsNotATag(`abc${1}def${2}ghi`);
|
||||
>f.thisIsNotATag(`abc${1}def${2}ghi`) : void
|
||||
>f.thisIsNotATag : (x: string) => void
|
||||
>f : I
|
||||
>thisIsNotATag : (x: string) => void
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMember
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithManyCallAndMemberExpressions.ts (1 errors) ====
|
||||
interface I {
|
||||
(strs: string[], subs: number[]): I;
|
||||
(strs: string[], ...subs: number[]): I;
|
||||
member: {
|
||||
new (s: string): {
|
||||
new (n: number): {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
//// [taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts]
|
||||
interface I {
|
||||
(strs: string[], subs: number[]): I;
|
||||
(strs: string[], ...subs: number[]): I;
|
||||
member: {
|
||||
new (s: string): {
|
||||
new (n: number): {
|
||||
|
||||
+6
-6
@@ -2,7 +2,7 @@
|
||||
interface I {
|
||||
>I : I
|
||||
|
||||
(strs: string[], subs: number[]): I;
|
||||
(strs: string[], ...subs: number[]): I;
|
||||
>strs : string[]
|
||||
>subs : number[]
|
||||
>I : I
|
||||
@@ -28,11 +28,11 @@ var f: I;
|
||||
var x = new new new f `abc${ 0 }def`.member("hello")(42) === true;
|
||||
>x : boolean
|
||||
>new new new f `abc${ 0 }def`.member("hello")(42) === true : boolean
|
||||
>new new new f `abc${ 0 }def`.member("hello")(42) : any
|
||||
>new new f `abc${ 0 }def`.member("hello")(42) : any
|
||||
>new f `abc${ 0 }def`.member("hello") : any
|
||||
>f `abc${ 0 }def`.member : any
|
||||
>new new new f `abc${ 0 }def`.member("hello")(42) : boolean
|
||||
>new new f `abc${ 0 }def`.member("hello")(42) : new () => boolean
|
||||
>new f `abc${ 0 }def`.member("hello") : new (n: number) => new () => boolean
|
||||
>f `abc${ 0 }def`.member : new (s: string) => new (n: number) => new () => boolean
|
||||
>f : I
|
||||
>member : any
|
||||
>member : new (s: string) => new (n: number) => new () => boolean
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(16,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(17,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(18,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(20,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(12,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(14,9): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,9): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts (10 errors) ====
|
||||
function foo(strs: string[]): number;
|
||||
function foo(strs: string[], x: number): string;
|
||||
function foo(strs: string[], x: number, y: number): boolean;
|
||||
function foo(strs: string[], x: number, y: string): {};
|
||||
function foo(...stuff: any[]): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var a = foo([]); // number
|
||||
var b = foo([], 1); // string
|
||||
var c = foo([], 1, 2); // boolean
|
||||
var d = foo([], 1, true); // boolean (with error)
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
var e = foo([], 1, "2"); // {}
|
||||
var f = foo([], 1, 2, 3); // any (with error)
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
var u = foo ``; // number
|
||||
~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var v = foo `${1}`; // string
|
||||
~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var w = foo `${1}${2}`; // boolean
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var x = foo `${1}${true}`; // boolean (with error)
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
var y = foo `${1}${"2"}`; // {}
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var z = foo `${1}${2}${3}`; // any (with error)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(12,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(14,9): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(19,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(21,9): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts (4 errors) ====
|
||||
function foo(strs: string[]): number;
|
||||
function foo(strs: string[], x: number): string;
|
||||
function foo(strs: string[], x: number, y: number): boolean;
|
||||
function foo(strs: string[], x: number, y: string): {};
|
||||
function foo(...stuff: any[]): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var a = foo([]); // number
|
||||
var b = foo([], 1); // string
|
||||
var c = foo([], 1, 2); // boolean
|
||||
var d = foo([], 1, true); // boolean (with error)
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
var e = foo([], 1, "2"); // {}
|
||||
var f = foo([], 1, 2, 3); // any (with error)
|
||||
~~~~~~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
var u = foo ``; // number
|
||||
var v = foo `${1}`; // string
|
||||
var w = foo `${1}${2}`; // boolean
|
||||
var x = foo `${1}${true}`; // boolean (with error)
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
var y = foo `${1}${"2"}`; // {}
|
||||
var z = foo `${1}${2}${3}`; // any (with error)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
//// [taggedTemplateStringsWithOverloadResolution1_ES6.ts]
|
||||
function foo(strs: string[]): number;
|
||||
function foo(strs: string[], x: number): string;
|
||||
function foo(strs: string[], x: number, y: number): boolean;
|
||||
function foo(strs: string[], x: number, y: string): {};
|
||||
function foo(...stuff: any[]): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var a = foo([]); // number
|
||||
var b = foo([], 1); // string
|
||||
var c = foo([], 1, 2); // boolean
|
||||
var d = foo([], 1, true); // boolean (with error)
|
||||
var e = foo([], 1, "2"); // {}
|
||||
var f = foo([], 1, 2, 3); // any (with error)
|
||||
|
||||
var u = foo ``; // number
|
||||
var v = foo `${1}`; // string
|
||||
var w = foo `${1}${2}`; // boolean
|
||||
var x = foo `${1}${true}`; // boolean (with error)
|
||||
var y = foo `${1}${"2"}`; // {}
|
||||
var z = foo `${1}${2}${3}`; // any (with error)
|
||||
|
||||
|
||||
//// [taggedTemplateStringsWithOverloadResolution1_ES6.js]
|
||||
function foo() {
|
||||
var stuff = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
stuff[_i - 0] = arguments[_i];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
var a = foo([]); // number
|
||||
var b = foo([], 1); // string
|
||||
var c = foo([], 1, 2); // boolean
|
||||
var d = foo([], 1, true); // boolean (with error)
|
||||
var e = foo([], 1, "2"); // {}
|
||||
var f = foo([], 1, 2, 3); // any (with error)
|
||||
var u = foo ``; // number
|
||||
var v = foo `${1}`; // string
|
||||
var w = foo `${1}${2}`; // boolean
|
||||
var x = foo `${1}${true}`; // boolean (with error)
|
||||
var y = foo `${1}${"2"}`; // {}
|
||||
var z = foo `${1}${2}${3}`; // any (with error)
|
||||
@@ -0,0 +1,27 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution2.ts(8,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution2.ts(17,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution2.ts (2 errors) ====
|
||||
|
||||
function foo1(strs: TemplateStringsArray, x: number): string;
|
||||
function foo1(strs: string[], x: number): number;
|
||||
function foo1(...stuff: any[]): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var a = foo1 `${1}`; // string
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var b = foo1([], 1); // number
|
||||
|
||||
function foo2(strs: string[], x: number): number;
|
||||
function foo2(strs: TemplateStringsArray, x: number): string;
|
||||
function foo2(...stuff: any[]): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var c = foo2 `${1}`; // number
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var d = foo2([], 1); // number
|
||||
@@ -0,0 +1,38 @@
|
||||
//// [taggedTemplateStringsWithOverloadResolution2_ES6.ts]
|
||||
function foo1(strs: TemplateStringsArray, x: number): string;
|
||||
function foo1(strs: string[], x: number): number;
|
||||
function foo1(...stuff: any[]): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var a = foo1 `${1}`; // string
|
||||
var b = foo1([], 1); // number
|
||||
|
||||
function foo2(strs: string[], x: number): number;
|
||||
function foo2(strs: TemplateStringsArray, x: number): string;
|
||||
function foo2(...stuff: any[]): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var c = foo2 `${1}`; // number
|
||||
var d = foo2([], 1); // number
|
||||
|
||||
//// [taggedTemplateStringsWithOverloadResolution2_ES6.js]
|
||||
function foo1() {
|
||||
var stuff = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
stuff[_i - 0] = arguments[_i];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
var a = foo1 `${1}`; // string
|
||||
var b = foo1([], 1); // number
|
||||
function foo2() {
|
||||
var stuff = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
stuff[_i - 0] = arguments[_i];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
var c = foo2 `${1}`; // number
|
||||
var d = foo2([], 1); // number
|
||||
@@ -0,0 +1,59 @@
|
||||
=== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution2_ES6.ts ===
|
||||
function foo1(strs: TemplateStringsArray, x: number): string;
|
||||
>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; }
|
||||
>strs : TemplateStringsArray
|
||||
>TemplateStringsArray : TemplateStringsArray
|
||||
>x : number
|
||||
|
||||
function foo1(strs: string[], x: number): number;
|
||||
>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; }
|
||||
>strs : string[]
|
||||
>x : number
|
||||
|
||||
function foo1(...stuff: any[]): any {
|
||||
>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; }
|
||||
>stuff : any[]
|
||||
|
||||
return undefined;
|
||||
>undefined : undefined
|
||||
}
|
||||
|
||||
var a = foo1 `${1}`; // string
|
||||
>a : string
|
||||
>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; }
|
||||
|
||||
var b = foo1([], 1); // number
|
||||
>b : number
|
||||
>foo1([], 1) : number
|
||||
>foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; }
|
||||
>[] : undefined[]
|
||||
|
||||
function foo2(strs: string[], x: number): number;
|
||||
>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; }
|
||||
>strs : string[]
|
||||
>x : number
|
||||
|
||||
function foo2(strs: TemplateStringsArray, x: number): string;
|
||||
>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; }
|
||||
>strs : TemplateStringsArray
|
||||
>TemplateStringsArray : TemplateStringsArray
|
||||
>x : number
|
||||
|
||||
function foo2(...stuff: any[]): any {
|
||||
>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; }
|
||||
>stuff : any[]
|
||||
|
||||
return undefined;
|
||||
>undefined : undefined
|
||||
}
|
||||
|
||||
var c = foo2 `${1}`; // number
|
||||
>c : number
|
||||
>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; }
|
||||
|
||||
var d = foo2([], 1); // number
|
||||
>d : number
|
||||
>foo2([], 1) : number
|
||||
>foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; }
|
||||
>[] : undefined[]
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(7,17): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(10,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(16,16): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(17,16): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(23,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(26,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(34,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(35,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(36,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(40,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(41,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(42,9): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(45,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(54,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(55,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(56,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(57,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(60,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(63,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(64,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(70,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(71,1): error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(10,9): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(19,4): error TS2339: Property 'foo' does not exist on type 'Date'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(45,1): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(63,9): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(64,18): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(70,18): error TS2339: Property 'toFixed' does not exist on type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts (28 errors) ====
|
||||
|
||||
// Ambiguous call picks the first overload in declaration order
|
||||
function fn1(strs: TemplateStringsArray, s: string): string;
|
||||
function fn1(strs: TemplateStringsArray, n: number): number;
|
||||
function fn1() { return null; }
|
||||
|
||||
var s: string = fn1 `${ undefined }`;
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// No candidate overloads found
|
||||
fn1 `${ {} }`; // Error
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~
|
||||
!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'.
|
||||
|
||||
function fn2(strs: TemplateStringsArray, s: string, n: number): number;
|
||||
function fn2<T>(strs: TemplateStringsArray, n: number, t: T): T;
|
||||
function fn2() { return undefined; }
|
||||
|
||||
var d1: Date = fn2 `${ 0 }${ undefined }`; // contextually typed
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var d2 = fn2 `${ 0 }${ undefined }`; // any
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
d1.foo(); // error
|
||||
~~~
|
||||
!!! error TS2339: Property 'foo' does not exist on type 'Date'.
|
||||
d2(); // no error (typed as any)
|
||||
|
||||
// Generic and non-generic overload where generic overload is the only candidate
|
||||
fn2 `${ 0 }${ '' }`; // OK
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// Generic and non-generic overload where non-generic overload is the only candidate
|
||||
fn2 `${ '' }${ 0 }`; // OK
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// Generic overloads with differing arity
|
||||
function fn3<T>(strs: TemplateStringsArray, n: T): string;
|
||||
function fn3<T, U>(strs: TemplateStringsArray, s: string, t: T, u: U): U;
|
||||
function fn3<T, U, V>(strs: TemplateStringsArray, v: V, u: U, t: T): number;
|
||||
function fn3() { return null; }
|
||||
|
||||
var s = fn3 `${ 3 }`;
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var s = fn3 `${'' }${ 3 }${ '' }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var n = fn3 `${ 5 }${ 5 }${ 5 }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var n: number;
|
||||
|
||||
// Generic overloads with differing arity tagging with arguments matching each overload type parameter count
|
||||
var s = fn3 `${ 4 }`
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var s = fn3 `${ '' }${ '' }${ '' }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
var n = fn3 `${ '' }${ '' }${ 3 }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// Generic overloads with differing arity tagging with argument count that doesn't match any overload
|
||||
fn3 ``; // Error
|
||||
~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
// Generic overloads with constraints
|
||||
function fn4<T extends string, U extends number>(strs: TemplateStringsArray, n: T, m: U);
|
||||
function fn4<T extends number, U extends string>(strs: TemplateStringsArray, n: T, m: U);
|
||||
function fn4(strs: TemplateStringsArray)
|
||||
function fn4() { }
|
||||
|
||||
// Generic overloads with constraints tagged with types that satisfy the constraints
|
||||
fn4 `${ '' }${ 3 }`;
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
fn4 `${ 3 }${ '' }`;
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
fn4 `${ 3 }${ undefined }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
fn4 `${ '' }${ null }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// Generic overloads with constraints called with type arguments that do not satisfy the constraints
|
||||
fn4 `${ null }${ null }`; // Error
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
// Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints
|
||||
fn4 `${ true }${ null }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'.
|
||||
fn4 `${ null }${ true }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
|
||||
// Non - generic overloads where contextual typing of function arguments has errors
|
||||
function fn5(strs: TemplateStringsArray, f: (n: string) => void): string;
|
||||
function fn5(strs: TemplateStringsArray, f: (n: number) => void): number;
|
||||
function fn5() { return undefined; }
|
||||
fn5 `${ (n) => n.toFixed() }`; // will error; 'n' should have type 'string'.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~
|
||||
!!! error TS2339: Property 'toFixed' does not exist on type 'string'.
|
||||
fn5 `${ (n) => n.substr(0) }`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(9,9): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(18,4): error TS2339: Property 'foo' does not exist on type 'Date'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(44,1): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(62,9): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(63,18): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(69,18): error TS2339: Property 'toFixed' does not exist on type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts (6 errors) ====
|
||||
// Ambiguous call picks the first overload in declaration order
|
||||
function fn1(strs: TemplateStringsArray, s: string): string;
|
||||
function fn1(strs: TemplateStringsArray, n: number): number;
|
||||
function fn1() { return null; }
|
||||
|
||||
var s: string = fn1 `${ undefined }`;
|
||||
|
||||
// No candidate overloads found
|
||||
fn1 `${ {} }`; // Error
|
||||
~~
|
||||
!!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'.
|
||||
|
||||
function fn2(strs: TemplateStringsArray, s: string, n: number): number;
|
||||
function fn2<T>(strs: TemplateStringsArray, n: number, t: T): T;
|
||||
function fn2() { return undefined; }
|
||||
|
||||
var d1: Date = fn2 `${ 0 }${ undefined }`; // contextually typed
|
||||
var d2 = fn2 `${ 0 }${ undefined }`; // any
|
||||
|
||||
d1.foo(); // error
|
||||
~~~
|
||||
!!! error TS2339: Property 'foo' does not exist on type 'Date'.
|
||||
d2(); // no error (typed as any)
|
||||
|
||||
// Generic and non-generic overload where generic overload is the only candidate
|
||||
fn2 `${ 0 }${ '' }`; // OK
|
||||
|
||||
// Generic and non-generic overload where non-generic overload is the only candidate
|
||||
fn2 `${ '' }${ 0 }`; // OK
|
||||
|
||||
// Generic overloads with differing arity
|
||||
function fn3<T>(strs: TemplateStringsArray, n: T): string;
|
||||
function fn3<T, U>(strs: TemplateStringsArray, s: string, t: T, u: U): U;
|
||||
function fn3<T, U, V>(strs: TemplateStringsArray, v: V, u: U, t: T): number;
|
||||
function fn3() { return null; }
|
||||
|
||||
var s = fn3 `${ 3 }`;
|
||||
var s = fn3 `${'' }${ 3 }${ '' }`;
|
||||
var n = fn3 `${ 5 }${ 5 }${ 5 }`;
|
||||
var n: number;
|
||||
|
||||
// Generic overloads with differing arity tagging with arguments matching each overload type parameter count
|
||||
var s = fn3 `${ 4 }`
|
||||
var s = fn3 `${ '' }${ '' }${ '' }`;
|
||||
var n = fn3 `${ '' }${ '' }${ 3 }`;
|
||||
|
||||
// Generic overloads with differing arity tagging with argument count that doesn't match any overload
|
||||
fn3 ``; // Error
|
||||
~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
// Generic overloads with constraints
|
||||
function fn4<T extends string, U extends number>(strs: TemplateStringsArray, n: T, m: U);
|
||||
function fn4<T extends number, U extends string>(strs: TemplateStringsArray, n: T, m: U);
|
||||
function fn4(strs: TemplateStringsArray)
|
||||
function fn4() { }
|
||||
|
||||
// Generic overloads with constraints tagged with types that satisfy the constraints
|
||||
fn4 `${ '' }${ 3 }`;
|
||||
fn4 `${ 3 }${ '' }`;
|
||||
fn4 `${ 3 }${ undefined }`;
|
||||
fn4 `${ '' }${ null }`;
|
||||
|
||||
// Generic overloads with constraints called with type arguments that do not satisfy the constraints
|
||||
fn4 `${ null }${ null }`; // Error
|
||||
|
||||
// Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints
|
||||
fn4 `${ true }${ null }`;
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'.
|
||||
fn4 `${ null }${ true }`;
|
||||
~~~~
|
||||
!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'.
|
||||
|
||||
// Non - generic overloads where contextual typing of function arguments has errors
|
||||
function fn5(strs: TemplateStringsArray, f: (n: string) => void): string;
|
||||
function fn5(strs: TemplateStringsArray, f: (n: number) => void): number;
|
||||
function fn5() { return undefined; }
|
||||
fn5 `${ (n) => n.toFixed() }`; // will error; 'n' should have type 'string'.
|
||||
~~~~~~~
|
||||
!!! error TS2339: Property 'toFixed' does not exist on type 'string'.
|
||||
fn5 `${ (n) => n.substr(0) }`;
|
||||
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
//// [taggedTemplateStringsWithOverloadResolution3_ES6.ts]
|
||||
// Ambiguous call picks the first overload in declaration order
|
||||
function fn1(strs: TemplateStringsArray, s: string): string;
|
||||
function fn1(strs: TemplateStringsArray, n: number): number;
|
||||
function fn1() { return null; }
|
||||
|
||||
var s: string = fn1 `${ undefined }`;
|
||||
|
||||
// No candidate overloads found
|
||||
fn1 `${ {} }`; // Error
|
||||
|
||||
function fn2(strs: TemplateStringsArray, s: string, n: number): number;
|
||||
function fn2<T>(strs: TemplateStringsArray, n: number, t: T): T;
|
||||
function fn2() { return undefined; }
|
||||
|
||||
var d1: Date = fn2 `${ 0 }${ undefined }`; // contextually typed
|
||||
var d2 = fn2 `${ 0 }${ undefined }`; // any
|
||||
|
||||
d1.foo(); // error
|
||||
d2(); // no error (typed as any)
|
||||
|
||||
// Generic and non-generic overload where generic overload is the only candidate
|
||||
fn2 `${ 0 }${ '' }`; // OK
|
||||
|
||||
// Generic and non-generic overload where non-generic overload is the only candidate
|
||||
fn2 `${ '' }${ 0 }`; // OK
|
||||
|
||||
// Generic overloads with differing arity
|
||||
function fn3<T>(strs: TemplateStringsArray, n: T): string;
|
||||
function fn3<T, U>(strs: TemplateStringsArray, s: string, t: T, u: U): U;
|
||||
function fn3<T, U, V>(strs: TemplateStringsArray, v: V, u: U, t: T): number;
|
||||
function fn3() { return null; }
|
||||
|
||||
var s = fn3 `${ 3 }`;
|
||||
var s = fn3 `${'' }${ 3 }${ '' }`;
|
||||
var n = fn3 `${ 5 }${ 5 }${ 5 }`;
|
||||
var n: number;
|
||||
|
||||
// Generic overloads with differing arity tagging with arguments matching each overload type parameter count
|
||||
var s = fn3 `${ 4 }`
|
||||
var s = fn3 `${ '' }${ '' }${ '' }`;
|
||||
var n = fn3 `${ '' }${ '' }${ 3 }`;
|
||||
|
||||
// Generic overloads with differing arity tagging with argument count that doesn't match any overload
|
||||
fn3 ``; // Error
|
||||
|
||||
// Generic overloads with constraints
|
||||
function fn4<T extends string, U extends number>(strs: TemplateStringsArray, n: T, m: U);
|
||||
function fn4<T extends number, U extends string>(strs: TemplateStringsArray, n: T, m: U);
|
||||
function fn4(strs: TemplateStringsArray)
|
||||
function fn4() { }
|
||||
|
||||
// Generic overloads with constraints tagged with types that satisfy the constraints
|
||||
fn4 `${ '' }${ 3 }`;
|
||||
fn4 `${ 3 }${ '' }`;
|
||||
fn4 `${ 3 }${ undefined }`;
|
||||
fn4 `${ '' }${ null }`;
|
||||
|
||||
// Generic overloads with constraints called with type arguments that do not satisfy the constraints
|
||||
fn4 `${ null }${ null }`; // Error
|
||||
|
||||
// Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints
|
||||
fn4 `${ true }${ null }`;
|
||||
fn4 `${ null }${ true }`;
|
||||
|
||||
// Non - generic overloads where contextual typing of function arguments has errors
|
||||
function fn5(strs: TemplateStringsArray, f: (n: string) => void): string;
|
||||
function fn5(strs: TemplateStringsArray, f: (n: number) => void): number;
|
||||
function fn5() { return undefined; }
|
||||
fn5 `${ (n) => n.toFixed() }`; // will error; 'n' should have type 'string'.
|
||||
fn5 `${ (n) => n.substr(0) }`;
|
||||
|
||||
|
||||
|
||||
//// [taggedTemplateStringsWithOverloadResolution3_ES6.js]
|
||||
function fn1() {
|
||||
return null;
|
||||
}
|
||||
var s = fn1 `${undefined}`;
|
||||
// No candidate overloads found
|
||||
fn1 `${{}}`; // Error
|
||||
function fn2() {
|
||||
return undefined;
|
||||
}
|
||||
var d1 = fn2 `${0}${undefined}`; // contextually typed
|
||||
var d2 = fn2 `${0}${undefined}`; // any
|
||||
d1.foo(); // error
|
||||
d2(); // no error (typed as any)
|
||||
// Generic and non-generic overload where generic overload is the only candidate
|
||||
fn2 `${0}${''}`; // OK
|
||||
// Generic and non-generic overload where non-generic overload is the only candidate
|
||||
fn2 `${''}${0}`; // OK
|
||||
function fn3() {
|
||||
return null;
|
||||
}
|
||||
var s = fn3 `${3}`;
|
||||
var s = fn3 `${''}${3}${''}`;
|
||||
var n = fn3 `${5}${5}${5}`;
|
||||
var n;
|
||||
// Generic overloads with differing arity tagging with arguments matching each overload type parameter count
|
||||
var s = fn3 `${4}`;
|
||||
var s = fn3 `${''}${''}${''}`;
|
||||
var n = fn3 `${''}${''}${3}`;
|
||||
// Generic overloads with differing arity tagging with argument count that doesn't match any overload
|
||||
fn3 ``; // Error
|
||||
function fn4() {
|
||||
}
|
||||
// Generic overloads with constraints tagged with types that satisfy the constraints
|
||||
fn4 `${''}${3}`;
|
||||
fn4 `${3}${''}`;
|
||||
fn4 `${3}${undefined}`;
|
||||
fn4 `${''}${null}`;
|
||||
// Generic overloads with constraints called with type arguments that do not satisfy the constraints
|
||||
fn4 `${null}${null}`; // Error
|
||||
// Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints
|
||||
fn4 `${true}${null}`;
|
||||
fn4 `${null}${true}`;
|
||||
function fn5() {
|
||||
return undefined;
|
||||
}
|
||||
fn5 `${function (n) { return n.toFixed(); }}`; // will error; 'n' should have type 'string'.
|
||||
fn5 `${function (n) { return n.substr(0); }}`;
|
||||
@@ -39,34 +39,34 @@ f `abc${1}def${2}ghi`;
|
||||
>f : I
|
||||
|
||||
f `abc`.member
|
||||
>f `abc`.member : any
|
||||
>f `abc`.member : I
|
||||
>f : I
|
||||
>member : any
|
||||
>member : I
|
||||
|
||||
f `abc${1}def${2}ghi`.member;
|
||||
>f `abc${1}def${2}ghi`.member : any
|
||||
>f `abc${1}def${2}ghi`.member : I
|
||||
>f : I
|
||||
>member : any
|
||||
>member : I
|
||||
|
||||
f `abc`["member"];
|
||||
>f `abc`["member"] : any
|
||||
>f `abc`["member"] : I
|
||||
>f : I
|
||||
|
||||
f `abc${1}def${2}ghi`["member"];
|
||||
>f `abc${1}def${2}ghi`["member"] : any
|
||||
>f `abc${1}def${2}ghi`["member"] : I
|
||||
>f : I
|
||||
|
||||
f `abc`[0].member `abc${1}def${2}ghi`;
|
||||
>f `abc`[0].member : any
|
||||
>f `abc`[0] : any
|
||||
>f `abc`[0].member : I
|
||||
>f `abc`[0] : I
|
||||
>f : I
|
||||
>member : any
|
||||
>member : I
|
||||
|
||||
f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`;
|
||||
>f `abc${1}def${2}ghi`["member"].member : any
|
||||
>f `abc${1}def${2}ghi`["member"] : any
|
||||
>f `abc${1}def${2}ghi`["member"].member : I
|
||||
>f `abc${1}def${2}ghi`["member"] : I
|
||||
>f : I
|
||||
>member : any
|
||||
>member : I
|
||||
|
||||
f.thisIsNotATag(`abc`);
|
||||
>f.thisIsNotATag(`abc`) : void
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
tests/cases/compiler/taggedTemplatesWithIncompleteNoSubstitutionTemplate1.ts(6,15): error TS1126: Unexpected end of text.
|
||||
|
||||
|
||||
==== tests/cases/compiler/taggedTemplatesWithIncompleteNoSubstitutionTemplate1.ts (1 errors) ====
|
||||
|
||||
function f(x: TemplateStringsArray, y: string, z: string) {
|
||||
}
|
||||
|
||||
// Incomplete call, not enough parameters.
|
||||
f `123qdawdrqw
|
||||
|
||||
!!! error TS1126: Unexpected end of text.
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
tests/cases/compiler/taggedTemplatesWithIncompleteNoSubstitutionTemplate2.ts(6,4): error TS1126: Unexpected end of text.
|
||||
|
||||
|
||||
==== tests/cases/compiler/taggedTemplatesWithIncompleteNoSubstitutionTemplate2.ts (1 errors) ====
|
||||
|
||||
function f(x: TemplateStringsArray, y: string, z: string) {
|
||||
}
|
||||
|
||||
// Incomplete call, not enough parameters, at EOF.
|
||||
f `
|
||||
|
||||
!!! error TS1126: Unexpected end of text.
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions1.ts(6,17): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions1.ts (1 errors) ====
|
||||
|
||||
function f(x: TemplateStringsArray, y: string, z: string) {
|
||||
}
|
||||
|
||||
// Incomplete call, not enough parameters.
|
||||
f `123qdawdrqw${
|
||||
|
||||
!!! error TS1109: Expression expected.
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions2.ts(6,18): error TS1109: Expression expected.
|
||||
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions2.ts(6,21): error TS1109: Expression expected.
|
||||
|
||||
|
||||
==== tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions2.ts (2 errors) ====
|
||||
|
||||
function f(x: TemplateStringsArray, y: string, z: string) {
|
||||
}
|
||||
|
||||
// Incomplete call, enough parameters.
|
||||
f `123qdawdrqw${ }${
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
|
||||
!!! error TS1109: Expression expected.
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions3.ts(6,23): error TS1109: Expression expected.
|
||||
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions3.ts(6,18): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions3.ts (2 errors) ====
|
||||
|
||||
function f(x: TemplateStringsArray, y: string, z: string) {
|
||||
}
|
||||
|
||||
// Incomplete call, not enough parameters.
|
||||
f `123qdawdrqw${ 1 }${
|
||||
|
||||
!!! error TS1109: Expression expected.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions4.ts(6,24): error TS1109: Expression expected.
|
||||
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions4.ts(6,28): error TS1109: Expression expected.
|
||||
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions4.ts(6,1): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
|
||||
==== tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions4.ts (3 errors) ====
|
||||
|
||||
function f(x: TemplateStringsArray, y: string, z: string) {
|
||||
}
|
||||
|
||||
// Incomplete call, but too many parameters.
|
||||
f `123qdawdrqw${ 1 }${ }${
|
||||
~
|
||||
!!! error TS1109: Expression expected.
|
||||
|
||||
!!! error TS1109: Expression expected.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions5.ts(6,30): error TS1109: Expression expected.
|
||||
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions5.ts(6,1): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
|
||||
==== tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions5.ts (2 errors) ====
|
||||
|
||||
function f(x: TemplateStringsArray, y: string, z: string) {
|
||||
}
|
||||
|
||||
// Incomplete call, but too many parameters.
|
||||
f `123qdawdrqw${ 1 }${ 2 }${
|
||||
|
||||
!!! error TS1109: Expression expected.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions6.ts(6,23): error TS1109: Expression expected.
|
||||
tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions6.ts(6,18): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions6.ts (2 errors) ====
|
||||
|
||||
function f(x: TemplateStringsArray, y: string, z: string) {
|
||||
}
|
||||
|
||||
// Incomplete call, not enough parameters, at EOF.
|
||||
f `123qdawdrqw${ 1 }${
|
||||
|
||||
!!! error TS1109: Expression expected.
|
||||
~
|
||||
!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'.
|
||||
@@ -3,12 +3,15 @@ tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(3,5): err
|
||||
tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(3,8): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(3,10): error TS1134: Variable declaration expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(4,1): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts (5 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts (6 errors) ====
|
||||
var x = {
|
||||
~
|
||||
~
|
||||
a: `abc${ 123 }def`,
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
`b`: 321
|
||||
~~~~~~~
|
||||
@@ -19,6 +22,8 @@ tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(4,1): err
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
@@ -2,11 +2,14 @@ tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(3,5):
|
||||
tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(3,8): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(3,10): error TS1134: Variable declaration expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(4,1): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts (4 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts (5 errors) ====
|
||||
var x = {
|
||||
~
|
||||
a: `abc${ 123 }def`,
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
`b`: 321
|
||||
~~~
|
||||
!!! error TS1136: Property assignment expected.
|
||||
@@ -14,6 +17,8 @@ tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(4,1):
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
@@ -3,11 +3,13 @@ tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(2,5): err
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(2,8): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(2,10): error TS1134: Variable declaration expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(3,1): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts (5 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts (6 errors) ====
|
||||
var x = {
|
||||
~
|
||||
~
|
||||
`a`: 321
|
||||
~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
@@ -17,6 +19,8 @@ tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(3,1): err
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
@@ -3,11 +3,13 @@ tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(2,5): err
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(2,32): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(2,34): error TS1134: Variable declaration expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(3,1): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts (5 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts (6 errors) ====
|
||||
var x = {
|
||||
~
|
||||
~
|
||||
`abc${ 123 }def${ 456 }ghi`: 321
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1159: Tagged templates are only available when targeting ECMAScript 6 and higher.
|
||||
@@ -17,6 +19,8 @@ tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(3,1): err
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
@@ -2,10 +2,12 @@ tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(2,5):
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(2,8): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(2,10): error TS1134: Variable declaration expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(3,1): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts (4 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts (5 errors) ====
|
||||
var x = {
|
||||
~
|
||||
`a`: 321
|
||||
~~~
|
||||
!!! error TS1136: Property assignment expected.
|
||||
@@ -13,6 +15,8 @@ tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(3,1):
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
@@ -2,10 +2,12 @@ tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(2,5):
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(2,32): error TS1005: ',' expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(2,34): error TS1134: Variable declaration expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(3,1): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts (4 errors) ====
|
||||
==== tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts (5 errors) ====
|
||||
var x = {
|
||||
~
|
||||
`abc${ 123 }def${ 456 }ghi`: 321
|
||||
~~~~~~
|
||||
!!! error TS1136: Property assignment expected.
|
||||
@@ -13,6 +15,8 @@ tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(3,1):
|
||||
!!! error TS1005: ',' expected.
|
||||
~~~
|
||||
!!! error TS1134: Variable declaration expected.
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
}
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
@@ -6,6 +6,7 @@ error TS2318: Cannot find global type 'Number'.
|
||||
error TS2318: Cannot find global type 'Object'.
|
||||
error TS2318: Cannot find global type 'RegExp'.
|
||||
error TS2318: Cannot find global type 'String'.
|
||||
error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
tests/cases/compiler/typeCheckTypeArgument.ts(3,19): error TS2304: Cannot find name 'UNKNOWN'.
|
||||
tests/cases/compiler/typeCheckTypeArgument.ts(5,26): error TS2304: Cannot find name 'UNKNOWN'.
|
||||
tests/cases/compiler/typeCheckTypeArgument.ts(7,21): error TS2304: Cannot find name 'UNKNOWN'.
|
||||
@@ -22,6 +23,7 @@ tests/cases/compiler/typeCheckTypeArgument.ts(15,13): error TS2304: Cannot find
|
||||
!!! error TS2318: Cannot find global type 'Object'.
|
||||
!!! error TS2318: Cannot find global type 'RegExp'.
|
||||
!!! error TS2318: Cannot find global type 'String'.
|
||||
!!! error TS2318: Cannot find global type 'TemplateStringsArray'.
|
||||
==== tests/cases/compiler/typeCheckTypeArgument.ts (6 errors) ====
|
||||
/// <reference no-default-lib="true"/>
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
//// [typeGuardOfFormExpr1AndExpr2.ts]
|
||||
var str: string;
|
||||
var bool: boolean;
|
||||
var num: number;
|
||||
var strOrNum: string | number;
|
||||
var strOrNumOrBool: string | number | boolean;
|
||||
var numOrBool: number | boolean;
|
||||
class C { private p; }
|
||||
var c: C;
|
||||
var cOrBool: C| boolean;
|
||||
var strOrNumOrBoolOrC: string | number | boolean | C;
|
||||
|
||||
// A type guard of the form expr1 && expr2
|
||||
// - when true, narrows the type of x by expr1 when true and then by expr2 when true, or
|
||||
// - when false, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when
|
||||
// false, and T2 is the type of x narrowed by expr1 when true and then by expr2 when false.
|
||||
|
||||
// (typeguard1 && typeguard2)
|
||||
if (typeof strOrNumOrBool !== "string" && typeof strOrNumOrBool !== "number") {
|
||||
bool = strOrNumOrBool; // boolean
|
||||
}
|
||||
else {
|
||||
strOrNum = strOrNumOrBool; // string | number
|
||||
}
|
||||
// (typeguard1 && typeguard2 && typeguard3)
|
||||
if (typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "number" && typeof strOrNumOrBoolOrC !== "boolean") {
|
||||
c = strOrNumOrBoolOrC; // C
|
||||
}
|
||||
else {
|
||||
strOrNumOrBool = strOrNumOrBoolOrC; // string | number | boolean
|
||||
}
|
||||
// (typeguard1 && typeguard2 && typeguard11(onAnotherType))
|
||||
if (typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "number" && typeof strOrNumOrBool === "boolean") {
|
||||
cOrBool = strOrNumOrBoolOrC; // C | boolean
|
||||
bool = strOrNumOrBool; // boolean
|
||||
}
|
||||
else {
|
||||
var r1: string | number | boolean | C = strOrNumOrBoolOrC; // string | number | boolean | C
|
||||
var r2: string | number | boolean = strOrNumOrBool;
|
||||
}
|
||||
// (typeguard1) && simpleExpr
|
||||
if (typeof strOrNumOrBool !== "string" && numOrBool !== strOrNumOrBool) {
|
||||
numOrBool = strOrNumOrBool; // number | boolean
|
||||
}
|
||||
else {
|
||||
var r3: string | number | boolean = strOrNumOrBool; // string | number | boolean
|
||||
}
|
||||
|
||||
//// [typeGuardOfFormExpr1AndExpr2.js]
|
||||
var str;
|
||||
var bool;
|
||||
var num;
|
||||
var strOrNum;
|
||||
var strOrNumOrBool;
|
||||
var numOrBool;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
var c;
|
||||
var cOrBool;
|
||||
var strOrNumOrBoolOrC;
|
||||
// A type guard of the form expr1 && expr2
|
||||
// - when true, narrows the type of x by expr1 when true and then by expr2 when true, or
|
||||
// - when false, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when
|
||||
// false, and T2 is the type of x narrowed by expr1 when true and then by expr2 when false.
|
||||
// (typeguard1 && typeguard2)
|
||||
if (typeof strOrNumOrBool !== "string" && typeof strOrNumOrBool !== "number") {
|
||||
bool = strOrNumOrBool; // boolean
|
||||
}
|
||||
else {
|
||||
strOrNum = strOrNumOrBool; // string | number
|
||||
}
|
||||
// (typeguard1 && typeguard2 && typeguard3)
|
||||
if (typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "number" && typeof strOrNumOrBoolOrC !== "boolean") {
|
||||
c = strOrNumOrBoolOrC; // C
|
||||
}
|
||||
else {
|
||||
strOrNumOrBool = strOrNumOrBoolOrC; // string | number | boolean
|
||||
}
|
||||
// (typeguard1 && typeguard2 && typeguard11(onAnotherType))
|
||||
if (typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "number" && typeof strOrNumOrBool === "boolean") {
|
||||
cOrBool = strOrNumOrBoolOrC; // C | boolean
|
||||
bool = strOrNumOrBool; // boolean
|
||||
}
|
||||
else {
|
||||
var r1 = strOrNumOrBoolOrC; // string | number | boolean | C
|
||||
var r2 = strOrNumOrBool;
|
||||
}
|
||||
// (typeguard1) && simpleExpr
|
||||
if (typeof strOrNumOrBool !== "string" && numOrBool !== strOrNumOrBool) {
|
||||
numOrBool = strOrNumOrBool; // number | boolean
|
||||
}
|
||||
else {
|
||||
var r3 = strOrNumOrBool; // string | number | boolean
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormExpr1AndExpr2.ts ===
|
||||
var str: string;
|
||||
>str : string
|
||||
|
||||
var bool: boolean;
|
||||
>bool : boolean
|
||||
|
||||
var num: number;
|
||||
>num : number
|
||||
|
||||
var strOrNum: string | number;
|
||||
>strOrNum : string | number
|
||||
|
||||
var strOrNumOrBool: string | number | boolean;
|
||||
>strOrNumOrBool : string | number | boolean
|
||||
|
||||
var numOrBool: number | boolean;
|
||||
>numOrBool : number | boolean
|
||||
|
||||
class C { private p; }
|
||||
>C : C
|
||||
>p : any
|
||||
|
||||
var c: C;
|
||||
>c : C
|
||||
>C : C
|
||||
|
||||
var cOrBool: C| boolean;
|
||||
>cOrBool : boolean | C
|
||||
>C : C
|
||||
|
||||
var strOrNumOrBoolOrC: string | number | boolean | C;
|
||||
>strOrNumOrBoolOrC : string | number | boolean | C
|
||||
>C : C
|
||||
|
||||
// A type guard of the form expr1 && expr2
|
||||
// - when true, narrows the type of x by expr1 when true and then by expr2 when true, or
|
||||
// - when false, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when
|
||||
// false, and T2 is the type of x narrowed by expr1 when true and then by expr2 when false.
|
||||
|
||||
// (typeguard1 && typeguard2)
|
||||
if (typeof strOrNumOrBool !== "string" && typeof strOrNumOrBool !== "number") {
|
||||
>typeof strOrNumOrBool !== "string" && typeof strOrNumOrBool !== "number" : boolean
|
||||
>typeof strOrNumOrBool !== "string" : boolean
|
||||
>typeof strOrNumOrBool : string
|
||||
>strOrNumOrBool : string | number | boolean
|
||||
>typeof strOrNumOrBool !== "number" : boolean
|
||||
>typeof strOrNumOrBool : string
|
||||
>strOrNumOrBool : number | boolean
|
||||
|
||||
bool = strOrNumOrBool; // boolean
|
||||
>bool = strOrNumOrBool : boolean
|
||||
>bool : boolean
|
||||
>strOrNumOrBool : boolean
|
||||
}
|
||||
else {
|
||||
strOrNum = strOrNumOrBool; // string | number
|
||||
>strOrNum = strOrNumOrBool : string | number
|
||||
>strOrNum : string | number
|
||||
>strOrNumOrBool : string | number
|
||||
}
|
||||
// (typeguard1 && typeguard2 && typeguard3)
|
||||
if (typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "number" && typeof strOrNumOrBoolOrC !== "boolean") {
|
||||
>typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "number" && typeof strOrNumOrBoolOrC !== "boolean" : boolean
|
||||
>typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "number" : boolean
|
||||
>typeof strOrNumOrBoolOrC !== "string" : boolean
|
||||
>typeof strOrNumOrBoolOrC : string
|
||||
>strOrNumOrBoolOrC : string | number | boolean | C
|
||||
>typeof strOrNumOrBoolOrC !== "number" : boolean
|
||||
>typeof strOrNumOrBoolOrC : string
|
||||
>strOrNumOrBoolOrC : number | boolean | C
|
||||
>typeof strOrNumOrBoolOrC !== "boolean" : boolean
|
||||
>typeof strOrNumOrBoolOrC : string
|
||||
>strOrNumOrBoolOrC : boolean | C
|
||||
|
||||
c = strOrNumOrBoolOrC; // C
|
||||
>c = strOrNumOrBoolOrC : C
|
||||
>c : C
|
||||
>strOrNumOrBoolOrC : C
|
||||
}
|
||||
else {
|
||||
strOrNumOrBool = strOrNumOrBoolOrC; // string | number | boolean
|
||||
>strOrNumOrBool = strOrNumOrBoolOrC : string | number | boolean
|
||||
>strOrNumOrBool : string | number | boolean
|
||||
>strOrNumOrBoolOrC : string | number | boolean
|
||||
}
|
||||
// (typeguard1 && typeguard2 && typeguard11(onAnotherType))
|
||||
if (typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "number" && typeof strOrNumOrBool === "boolean") {
|
||||
>typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "number" && typeof strOrNumOrBool === "boolean" : boolean
|
||||
>typeof strOrNumOrBoolOrC !== "string" && typeof strOrNumOrBoolOrC !== "number" : boolean
|
||||
>typeof strOrNumOrBoolOrC !== "string" : boolean
|
||||
>typeof strOrNumOrBoolOrC : string
|
||||
>strOrNumOrBoolOrC : string | number | boolean | C
|
||||
>typeof strOrNumOrBoolOrC !== "number" : boolean
|
||||
>typeof strOrNumOrBoolOrC : string
|
||||
>strOrNumOrBoolOrC : number | boolean | C
|
||||
>typeof strOrNumOrBool === "boolean" : boolean
|
||||
>typeof strOrNumOrBool : string
|
||||
>strOrNumOrBool : string | number | boolean
|
||||
|
||||
cOrBool = strOrNumOrBoolOrC; // C | boolean
|
||||
>cOrBool = strOrNumOrBoolOrC : boolean | C
|
||||
>cOrBool : boolean | C
|
||||
>strOrNumOrBoolOrC : boolean | C
|
||||
|
||||
bool = strOrNumOrBool; // boolean
|
||||
>bool = strOrNumOrBool : boolean
|
||||
>bool : boolean
|
||||
>strOrNumOrBool : boolean
|
||||
}
|
||||
else {
|
||||
var r1: string | number | boolean | C = strOrNumOrBoolOrC; // string | number | boolean | C
|
||||
>r1 : string | number | boolean | C
|
||||
>C : C
|
||||
>strOrNumOrBoolOrC : string | number | boolean | C
|
||||
|
||||
var r2: string | number | boolean = strOrNumOrBool;
|
||||
>r2 : string | number | boolean
|
||||
>strOrNumOrBool : string | number | boolean
|
||||
}
|
||||
// (typeguard1) && simpleExpr
|
||||
if (typeof strOrNumOrBool !== "string" && numOrBool !== strOrNumOrBool) {
|
||||
>typeof strOrNumOrBool !== "string" && numOrBool !== strOrNumOrBool : boolean
|
||||
>typeof strOrNumOrBool !== "string" : boolean
|
||||
>typeof strOrNumOrBool : string
|
||||
>strOrNumOrBool : string | number | boolean
|
||||
>numOrBool !== strOrNumOrBool : boolean
|
||||
>numOrBool : number | boolean
|
||||
>strOrNumOrBool : number | boolean
|
||||
|
||||
numOrBool = strOrNumOrBool; // number | boolean
|
||||
>numOrBool = strOrNumOrBool : number | boolean
|
||||
>numOrBool : number | boolean
|
||||
>strOrNumOrBool : number | boolean
|
||||
}
|
||||
else {
|
||||
var r3: string | number | boolean = strOrNumOrBool; // string | number | boolean
|
||||
>r3 : string | number | boolean
|
||||
>strOrNumOrBool : string | number | boolean
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
//// [typeGuardOfFormExpr1OrExpr2.ts]
|
||||
var str: string;
|
||||
var bool: boolean;
|
||||
var num: number;
|
||||
var strOrNum: string | number;
|
||||
var strOrNumOrBool: string | number | boolean;
|
||||
var numOrBool: number | boolean;
|
||||
class C { private p; }
|
||||
var c: C;
|
||||
var cOrBool: C| boolean;
|
||||
var strOrNumOrBoolOrC: string | number | boolean | C;
|
||||
|
||||
// A type guard of the form expr1 || expr2
|
||||
// - when true, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when true,
|
||||
// and T2 is the type of x narrowed by expr1 when false and then by expr2 when true, or
|
||||
// - when false, narrows the type of x by expr1 when false and then by expr2 when false.
|
||||
|
||||
// (typeguard1 || typeguard2)
|
||||
if (typeof strOrNumOrBool === "string" || typeof strOrNumOrBool === "number") {
|
||||
strOrNum = strOrNumOrBool; // string | number
|
||||
}
|
||||
else {
|
||||
bool = strOrNumOrBool; // boolean
|
||||
}
|
||||
// (typeguard1 || typeguard2 || typeguard3)
|
||||
if (typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "number" || typeof strOrNumOrBoolOrC === "boolean") {
|
||||
strOrNumOrBool = strOrNumOrBoolOrC; // string | number | boolean
|
||||
}
|
||||
else {
|
||||
c = strOrNumOrBoolOrC; // C
|
||||
}
|
||||
// (typeguard1 || typeguard2 || typeguard11(onAnotherType))
|
||||
if (typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "number" || typeof strOrNumOrBool !== "boolean") {
|
||||
var r1: string | number | boolean | C = strOrNumOrBoolOrC; // string | number | boolean | C
|
||||
var r2: string | number | boolean = strOrNumOrBool;
|
||||
}
|
||||
else {
|
||||
cOrBool = strOrNumOrBoolOrC; // C | boolean
|
||||
bool = strOrNumOrBool; // boolean
|
||||
}
|
||||
// (typeguard1) || simpleExpr
|
||||
if (typeof strOrNumOrBool === "string" || numOrBool !== strOrNumOrBool) {
|
||||
var r3: string | number | boolean = strOrNumOrBool; // string | number | boolean
|
||||
}
|
||||
else {
|
||||
numOrBool = strOrNumOrBool; // number | boolean
|
||||
}
|
||||
|
||||
//// [typeGuardOfFormExpr1OrExpr2.js]
|
||||
var str;
|
||||
var bool;
|
||||
var num;
|
||||
var strOrNum;
|
||||
var strOrNumOrBool;
|
||||
var numOrBool;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
var c;
|
||||
var cOrBool;
|
||||
var strOrNumOrBoolOrC;
|
||||
// A type guard of the form expr1 || expr2
|
||||
// - when true, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when true,
|
||||
// and T2 is the type of x narrowed by expr1 when false and then by expr2 when true, or
|
||||
// - when false, narrows the type of x by expr1 when false and then by expr2 when false.
|
||||
// (typeguard1 || typeguard2)
|
||||
if (typeof strOrNumOrBool === "string" || typeof strOrNumOrBool === "number") {
|
||||
strOrNum = strOrNumOrBool; // string | number
|
||||
}
|
||||
else {
|
||||
bool = strOrNumOrBool; // boolean
|
||||
}
|
||||
// (typeguard1 || typeguard2 || typeguard3)
|
||||
if (typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "number" || typeof strOrNumOrBoolOrC === "boolean") {
|
||||
strOrNumOrBool = strOrNumOrBoolOrC; // string | number | boolean
|
||||
}
|
||||
else {
|
||||
c = strOrNumOrBoolOrC; // C
|
||||
}
|
||||
// (typeguard1 || typeguard2 || typeguard11(onAnotherType))
|
||||
if (typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "number" || typeof strOrNumOrBool !== "boolean") {
|
||||
var r1 = strOrNumOrBoolOrC; // string | number | boolean | C
|
||||
var r2 = strOrNumOrBool;
|
||||
}
|
||||
else {
|
||||
cOrBool = strOrNumOrBoolOrC; // C | boolean
|
||||
bool = strOrNumOrBool; // boolean
|
||||
}
|
||||
// (typeguard1) || simpleExpr
|
||||
if (typeof strOrNumOrBool === "string" || numOrBool !== strOrNumOrBool) {
|
||||
var r3 = strOrNumOrBool; // string | number | boolean
|
||||
}
|
||||
else {
|
||||
numOrBool = strOrNumOrBool; // number | boolean
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormExpr1OrExpr2.ts ===
|
||||
var str: string;
|
||||
>str : string
|
||||
|
||||
var bool: boolean;
|
||||
>bool : boolean
|
||||
|
||||
var num: number;
|
||||
>num : number
|
||||
|
||||
var strOrNum: string | number;
|
||||
>strOrNum : string | number
|
||||
|
||||
var strOrNumOrBool: string | number | boolean;
|
||||
>strOrNumOrBool : string | number | boolean
|
||||
|
||||
var numOrBool: number | boolean;
|
||||
>numOrBool : number | boolean
|
||||
|
||||
class C { private p; }
|
||||
>C : C
|
||||
>p : any
|
||||
|
||||
var c: C;
|
||||
>c : C
|
||||
>C : C
|
||||
|
||||
var cOrBool: C| boolean;
|
||||
>cOrBool : boolean | C
|
||||
>C : C
|
||||
|
||||
var strOrNumOrBoolOrC: string | number | boolean | C;
|
||||
>strOrNumOrBoolOrC : string | number | boolean | C
|
||||
>C : C
|
||||
|
||||
// A type guard of the form expr1 || expr2
|
||||
// - when true, narrows the type of x to T1 | T2, where T1 is the type of x narrowed by expr1 when true,
|
||||
// and T2 is the type of x narrowed by expr1 when false and then by expr2 when true, or
|
||||
// - when false, narrows the type of x by expr1 when false and then by expr2 when false.
|
||||
|
||||
// (typeguard1 || typeguard2)
|
||||
if (typeof strOrNumOrBool === "string" || typeof strOrNumOrBool === "number") {
|
||||
>typeof strOrNumOrBool === "string" || typeof strOrNumOrBool === "number" : boolean
|
||||
>typeof strOrNumOrBool === "string" : boolean
|
||||
>typeof strOrNumOrBool : string
|
||||
>strOrNumOrBool : string | number | boolean
|
||||
>typeof strOrNumOrBool === "number" : boolean
|
||||
>typeof strOrNumOrBool : string
|
||||
>strOrNumOrBool : number | boolean
|
||||
|
||||
strOrNum = strOrNumOrBool; // string | number
|
||||
>strOrNum = strOrNumOrBool : string | number
|
||||
>strOrNum : string | number
|
||||
>strOrNumOrBool : string | number
|
||||
}
|
||||
else {
|
||||
bool = strOrNumOrBool; // boolean
|
||||
>bool = strOrNumOrBool : boolean
|
||||
>bool : boolean
|
||||
>strOrNumOrBool : boolean
|
||||
}
|
||||
// (typeguard1 || typeguard2 || typeguard3)
|
||||
if (typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "number" || typeof strOrNumOrBoolOrC === "boolean") {
|
||||
>typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "number" || typeof strOrNumOrBoolOrC === "boolean" : boolean
|
||||
>typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "number" : boolean
|
||||
>typeof strOrNumOrBoolOrC === "string" : boolean
|
||||
>typeof strOrNumOrBoolOrC : string
|
||||
>strOrNumOrBoolOrC : string | number | boolean | C
|
||||
>typeof strOrNumOrBoolOrC === "number" : boolean
|
||||
>typeof strOrNumOrBoolOrC : string
|
||||
>strOrNumOrBoolOrC : number | boolean | C
|
||||
>typeof strOrNumOrBoolOrC === "boolean" : boolean
|
||||
>typeof strOrNumOrBoolOrC : string
|
||||
>strOrNumOrBoolOrC : boolean | C
|
||||
|
||||
strOrNumOrBool = strOrNumOrBoolOrC; // string | number | boolean
|
||||
>strOrNumOrBool = strOrNumOrBoolOrC : string | number | boolean
|
||||
>strOrNumOrBool : string | number | boolean
|
||||
>strOrNumOrBoolOrC : string | number | boolean
|
||||
}
|
||||
else {
|
||||
c = strOrNumOrBoolOrC; // C
|
||||
>c = strOrNumOrBoolOrC : C
|
||||
>c : C
|
||||
>strOrNumOrBoolOrC : C
|
||||
}
|
||||
// (typeguard1 || typeguard2 || typeguard11(onAnotherType))
|
||||
if (typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "number" || typeof strOrNumOrBool !== "boolean") {
|
||||
>typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "number" || typeof strOrNumOrBool !== "boolean" : boolean
|
||||
>typeof strOrNumOrBoolOrC === "string" || typeof strOrNumOrBoolOrC === "number" : boolean
|
||||
>typeof strOrNumOrBoolOrC === "string" : boolean
|
||||
>typeof strOrNumOrBoolOrC : string
|
||||
>strOrNumOrBoolOrC : string | number | boolean | C
|
||||
>typeof strOrNumOrBoolOrC === "number" : boolean
|
||||
>typeof strOrNumOrBoolOrC : string
|
||||
>strOrNumOrBoolOrC : number | boolean | C
|
||||
>typeof strOrNumOrBool !== "boolean" : boolean
|
||||
>typeof strOrNumOrBool : string
|
||||
>strOrNumOrBool : string | number | boolean
|
||||
|
||||
var r1: string | number | boolean | C = strOrNumOrBoolOrC; // string | number | boolean | C
|
||||
>r1 : string | number | boolean | C
|
||||
>C : C
|
||||
>strOrNumOrBoolOrC : string | number | boolean | C
|
||||
|
||||
var r2: string | number | boolean = strOrNumOrBool;
|
||||
>r2 : string | number | boolean
|
||||
>strOrNumOrBool : string | number | boolean
|
||||
}
|
||||
else {
|
||||
cOrBool = strOrNumOrBoolOrC; // C | boolean
|
||||
>cOrBool = strOrNumOrBoolOrC : boolean | C
|
||||
>cOrBool : boolean | C
|
||||
>strOrNumOrBoolOrC : boolean | C
|
||||
|
||||
bool = strOrNumOrBool; // boolean
|
||||
>bool = strOrNumOrBool : boolean
|
||||
>bool : boolean
|
||||
>strOrNumOrBool : boolean
|
||||
}
|
||||
// (typeguard1) || simpleExpr
|
||||
if (typeof strOrNumOrBool === "string" || numOrBool !== strOrNumOrBool) {
|
||||
>typeof strOrNumOrBool === "string" || numOrBool !== strOrNumOrBool : boolean
|
||||
>typeof strOrNumOrBool === "string" : boolean
|
||||
>typeof strOrNumOrBool : string
|
||||
>strOrNumOrBool : string | number | boolean
|
||||
>numOrBool !== strOrNumOrBool : boolean
|
||||
>numOrBool : number | boolean
|
||||
>strOrNumOrBool : number | boolean
|
||||
|
||||
var r3: string | number | boolean = strOrNumOrBool; // string | number | boolean
|
||||
>r3 : string | number | boolean
|
||||
>strOrNumOrBool : string | number | boolean
|
||||
}
|
||||
else {
|
||||
numOrBool = strOrNumOrBool; // number | boolean
|
||||
>numOrBool = strOrNumOrBool : number | boolean
|
||||
>numOrBool : number | boolean
|
||||
>strOrNumOrBool : number | boolean
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
//// [typeGuardOfFormInstanceOf.ts]
|
||||
// A type guard of the form x instanceof C, where C is of a subtype of the global type 'Function'
|
||||
// and C has a property named 'prototype'
|
||||
// - when true, narrows the type of x to the type of the 'prototype' property in C provided
|
||||
// it is a subtype of the type of x, or
|
||||
// - when false, has no effect on the type of x.
|
||||
|
||||
class C1 {
|
||||
p1: string;
|
||||
}
|
||||
class C2 {
|
||||
p2: number;
|
||||
}
|
||||
class D1 extends C1 {
|
||||
p3: number;
|
||||
}
|
||||
var str: string;
|
||||
var num: number;
|
||||
var strOrNum: string | number;
|
||||
|
||||
var c1Orc2: C1 | C2;
|
||||
str = c1Orc2 instanceof C1 && c1Orc2.p1; // C1
|
||||
num = c1Orc2 instanceof C2 && c1Orc2.p2; // C2
|
||||
str = c1Orc2 instanceof D1 && c1Orc2.p1; // D1
|
||||
num = c1Orc2 instanceof D1 && c1Orc2.p3; // D1
|
||||
|
||||
var c2Ord1: C2 | D1;
|
||||
num = c2Ord1 instanceof C2 && c2Ord1.p2; // C2
|
||||
num = c2Ord1 instanceof D1 && c2Ord1.p3; // D1
|
||||
str = c2Ord1 instanceof D1 && c2Ord1.p1; // D1
|
||||
var r2: D1 | C2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1
|
||||
|
||||
//// [typeGuardOfFormInstanceOf.js]
|
||||
// A type guard of the form x instanceof C, where C is of a subtype of the global type 'Function'
|
||||
// and C has a property named 'prototype'
|
||||
// - when true, narrows the type of x to the type of the 'prototype' property in C provided
|
||||
// it is a subtype of the type of x, or
|
||||
// - when false, has no effect on the type of x.
|
||||
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() {
|
||||
}
|
||||
return C1;
|
||||
})();
|
||||
var C2 = (function () {
|
||||
function C2() {
|
||||
}
|
||||
return C2;
|
||||
})();
|
||||
var D1 = (function (_super) {
|
||||
__extends(D1, _super);
|
||||
function D1() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return D1;
|
||||
})(C1);
|
||||
var str;
|
||||
var num;
|
||||
var strOrNum;
|
||||
var c1Orc2;
|
||||
str = c1Orc2 instanceof C1 && c1Orc2.p1; // C1
|
||||
num = c1Orc2 instanceof C2 && c1Orc2.p2; // C2
|
||||
str = c1Orc2 instanceof D1 && c1Orc2.p1; // D1
|
||||
num = c1Orc2 instanceof D1 && c1Orc2.p3; // D1
|
||||
var c2Ord1;
|
||||
num = c2Ord1 instanceof C2 && c2Ord1.p2; // C2
|
||||
num = c2Ord1 instanceof D1 && c2Ord1.p3; // D1
|
||||
str = c2Ord1 instanceof D1 && c2Ord1.p1; // D1
|
||||
var r2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1
|
||||
@@ -0,0 +1,132 @@
|
||||
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormInstanceOf.ts ===
|
||||
// A type guard of the form x instanceof C, where C is of a subtype of the global type 'Function'
|
||||
// and C has a property named 'prototype'
|
||||
// - when true, narrows the type of x to the type of the 'prototype' property in C provided
|
||||
// it is a subtype of the type of x, or
|
||||
// - when false, has no effect on the type of x.
|
||||
|
||||
class C1 {
|
||||
>C1 : C1
|
||||
|
||||
p1: string;
|
||||
>p1 : string
|
||||
}
|
||||
class C2 {
|
||||
>C2 : C2
|
||||
|
||||
p2: number;
|
||||
>p2 : number
|
||||
}
|
||||
class D1 extends C1 {
|
||||
>D1 : D1
|
||||
>C1 : C1
|
||||
|
||||
p3: number;
|
||||
>p3 : number
|
||||
}
|
||||
var str: string;
|
||||
>str : string
|
||||
|
||||
var num: number;
|
||||
>num : number
|
||||
|
||||
var strOrNum: string | number;
|
||||
>strOrNum : string | number
|
||||
|
||||
var c1Orc2: C1 | C2;
|
||||
>c1Orc2 : C1 | C2
|
||||
>C1 : C1
|
||||
>C2 : C2
|
||||
|
||||
str = c1Orc2 instanceof C1 && c1Orc2.p1; // C1
|
||||
>str = c1Orc2 instanceof C1 && c1Orc2.p1 : string
|
||||
>str : string
|
||||
>c1Orc2 instanceof C1 && c1Orc2.p1 : string
|
||||
>c1Orc2 instanceof C1 : boolean
|
||||
>c1Orc2 : C1 | C2
|
||||
>C1 : typeof C1
|
||||
>c1Orc2.p1 : string
|
||||
>c1Orc2 : C1
|
||||
>p1 : string
|
||||
|
||||
num = c1Orc2 instanceof C2 && c1Orc2.p2; // C2
|
||||
>num = c1Orc2 instanceof C2 && c1Orc2.p2 : number
|
||||
>num : number
|
||||
>c1Orc2 instanceof C2 && c1Orc2.p2 : number
|
||||
>c1Orc2 instanceof C2 : boolean
|
||||
>c1Orc2 : C1 | C2
|
||||
>C2 : typeof C2
|
||||
>c1Orc2.p2 : number
|
||||
>c1Orc2 : C2
|
||||
>p2 : number
|
||||
|
||||
str = c1Orc2 instanceof D1 && c1Orc2.p1; // D1
|
||||
>str = c1Orc2 instanceof D1 && c1Orc2.p1 : string
|
||||
>str : string
|
||||
>c1Orc2 instanceof D1 && c1Orc2.p1 : string
|
||||
>c1Orc2 instanceof D1 : boolean
|
||||
>c1Orc2 : C1 | C2
|
||||
>D1 : typeof D1
|
||||
>c1Orc2.p1 : string
|
||||
>c1Orc2 : D1
|
||||
>p1 : string
|
||||
|
||||
num = c1Orc2 instanceof D1 && c1Orc2.p3; // D1
|
||||
>num = c1Orc2 instanceof D1 && c1Orc2.p3 : number
|
||||
>num : number
|
||||
>c1Orc2 instanceof D1 && c1Orc2.p3 : number
|
||||
>c1Orc2 instanceof D1 : boolean
|
||||
>c1Orc2 : C1 | C2
|
||||
>D1 : typeof D1
|
||||
>c1Orc2.p3 : number
|
||||
>c1Orc2 : D1
|
||||
>p3 : number
|
||||
|
||||
var c2Ord1: C2 | D1;
|
||||
>c2Ord1 : C2 | D1
|
||||
>C2 : C2
|
||||
>D1 : D1
|
||||
|
||||
num = c2Ord1 instanceof C2 && c2Ord1.p2; // C2
|
||||
>num = c2Ord1 instanceof C2 && c2Ord1.p2 : number
|
||||
>num : number
|
||||
>c2Ord1 instanceof C2 && c2Ord1.p2 : number
|
||||
>c2Ord1 instanceof C2 : boolean
|
||||
>c2Ord1 : C2 | D1
|
||||
>C2 : typeof C2
|
||||
>c2Ord1.p2 : number
|
||||
>c2Ord1 : C2
|
||||
>p2 : number
|
||||
|
||||
num = c2Ord1 instanceof D1 && c2Ord1.p3; // D1
|
||||
>num = c2Ord1 instanceof D1 && c2Ord1.p3 : number
|
||||
>num : number
|
||||
>c2Ord1 instanceof D1 && c2Ord1.p3 : number
|
||||
>c2Ord1 instanceof D1 : boolean
|
||||
>c2Ord1 : C2 | D1
|
||||
>D1 : typeof D1
|
||||
>c2Ord1.p3 : number
|
||||
>c2Ord1 : D1
|
||||
>p3 : number
|
||||
|
||||
str = c2Ord1 instanceof D1 && c2Ord1.p1; // D1
|
||||
>str = c2Ord1 instanceof D1 && c2Ord1.p1 : string
|
||||
>str : string
|
||||
>c2Ord1 instanceof D1 && c2Ord1.p1 : string
|
||||
>c2Ord1 instanceof D1 : boolean
|
||||
>c2Ord1 : C2 | D1
|
||||
>D1 : typeof D1
|
||||
>c2Ord1.p1 : string
|
||||
>c2Ord1 : D1
|
||||
>p1 : string
|
||||
|
||||
var r2: D1 | C2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1
|
||||
>r2 : C2 | D1
|
||||
>D1 : D1
|
||||
>C2 : C2
|
||||
>c2Ord1 instanceof C1 && c2Ord1 : C2 | D1
|
||||
>c2Ord1 instanceof C1 : boolean
|
||||
>c2Ord1 : C2 | D1
|
||||
>C1 : typeof C1
|
||||
>c2Ord1 : C2 | D1
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
//// [typeGuardOfFormInstanceOfOnInterface.ts]
|
||||
// A type guard of the form x instanceof C, where C is of a subtype of the global type 'Function'
|
||||
// and C has a property named 'prototype'
|
||||
// - when true, narrows the type of x to the type of the 'prototype' property in C provided
|
||||
// it is a subtype of the type of x, or
|
||||
// - when false, has no effect on the type of x.
|
||||
|
||||
interface C1 {
|
||||
(): C1;
|
||||
prototype: C1;
|
||||
p1: string;
|
||||
}
|
||||
interface C2 {
|
||||
(): C2;
|
||||
prototype: C2;
|
||||
p2: number;
|
||||
}
|
||||
interface D1 extends C1 {
|
||||
prototype: D1;
|
||||
p3: number;
|
||||
}
|
||||
var str: string;
|
||||
var num: number;
|
||||
var strOrNum: string | number;
|
||||
|
||||
var c1: C1;
|
||||
var c2: C2;
|
||||
var d1: D1;
|
||||
var c1Orc2: C1 | C2;
|
||||
str = c1Orc2 instanceof c1 && c1Orc2.p1; // C1
|
||||
num = c1Orc2 instanceof c2 && c1Orc2.p2; // C2
|
||||
str = c1Orc2 instanceof d1 && c1Orc2.p1; // C1
|
||||
num = c1Orc2 instanceof d1 && c1Orc2.p3; // D1
|
||||
|
||||
var c2Ord1: C2 | D1;
|
||||
num = c2Ord1 instanceof c2 && c2Ord1.p2; // C2
|
||||
num = c2Ord1 instanceof d1 && c2Ord1.p3; // D1
|
||||
str = c2Ord1 instanceof d1 && c2Ord1.p1; // D1
|
||||
var r2: D1 | C2 = c2Ord1 instanceof c1 && c2Ord1; // C2 | D1
|
||||
|
||||
//// [typeGuardOfFormInstanceOfOnInterface.js]
|
||||
// A type guard of the form x instanceof C, where C is of a subtype of the global type 'Function'
|
||||
// and C has a property named 'prototype'
|
||||
// - when true, narrows the type of x to the type of the 'prototype' property in C provided
|
||||
// it is a subtype of the type of x, or
|
||||
// - when false, has no effect on the type of x.
|
||||
var str;
|
||||
var num;
|
||||
var strOrNum;
|
||||
var c1;
|
||||
var c2;
|
||||
var d1;
|
||||
var c1Orc2;
|
||||
str = c1Orc2 instanceof c1 && c1Orc2.p1; // C1
|
||||
num = c1Orc2 instanceof c2 && c1Orc2.p2; // C2
|
||||
str = c1Orc2 instanceof d1 && c1Orc2.p1; // C1
|
||||
num = c1Orc2 instanceof d1 && c1Orc2.p3; // D1
|
||||
var c2Ord1;
|
||||
num = c2Ord1 instanceof c2 && c2Ord1.p2; // C2
|
||||
num = c2Ord1 instanceof d1 && c2Ord1.p3; // D1
|
||||
str = c2Ord1 instanceof d1 && c2Ord1.p1; // D1
|
||||
var r2 = c2Ord1 instanceof c1 && c2Ord1; // C2 | D1
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user