Merge branch 'master' into glob2_merged

This commit is contained in:
Richard Knoll 2016-06-17 17:55:15 -07:00
commit f817ffaf47
191 changed files with 4918 additions and 1216 deletions

View file

@ -756,13 +756,14 @@ function runConsoleTests(defaultReporter, runInParallel) {
colors = process.env.colors || process.env.color;
colors = colors ? ' --no-colors ' : ' --colors ';
reporter = process.env.reporter || process.env.r || defaultReporter;
var bail = (process.env.bail || process.env.b) ? "--bail" : "";
var lintFlag = process.env.lint !== 'false';
// timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally
// default timeout is 2sec which really should be enough, but maybe we just need a small amount longer
if(!runInParallel) {
tests = tests ? ' -g "' + tests + '"' : '';
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + ' -t ' + testTimeout + ' ' + run;
var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + bail + ' -t ' + testTimeout + ' ' + run;
console.log(cmd);
var savedNodeEnv = process.env.NODE_ENV;
@ -827,7 +828,7 @@ task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], functio
runConsoleTests('min', /*runInParallel*/ true);
}, {async: true});
desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|<more>] d[ebug]=true color[s]=false lint=true.");
desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|<more>] d[ebug]=true color[s]=false lint=true bail=false.");
task("runtests", ["build-rules", "tests", builtLocalDirectory], function() {
runConsoleTests('mocha-fivemat-progress-reporter', /*runInParallel*/ false);
}, {async: true});

View file

@ -578,12 +578,6 @@ namespace ts {
}
}
function isNarrowableReference(expr: Expression): boolean {
return expr.kind === SyntaxKind.Identifier ||
expr.kind === SyntaxKind.ThisKeyword ||
expr.kind === SyntaxKind.PropertyAccessExpression && isNarrowableReference((<PropertyAccessExpression>expr).expression);
}
function isNarrowingExpression(expr: Expression): boolean {
switch (expr.kind) {
case SyntaxKind.Identifier:
@ -591,7 +585,7 @@ namespace ts {
case SyntaxKind.PropertyAccessExpression:
return isNarrowableReference(expr);
case SyntaxKind.CallExpression:
return true;
return hasNarrowableArgument(<CallExpression>expr);
case SyntaxKind.ParenthesizedExpression:
return isNarrowingExpression((<ParenthesizedExpression>expr).expression);
case SyntaxKind.BinaryExpression:
@ -602,6 +596,39 @@ namespace ts {
return false;
}
function isNarrowableReference(expr: Expression): boolean {
return expr.kind === SyntaxKind.Identifier ||
expr.kind === SyntaxKind.ThisKeyword ||
expr.kind === SyntaxKind.PropertyAccessExpression && isNarrowableReference((<PropertyAccessExpression>expr).expression);
}
function hasNarrowableArgument(expr: CallExpression) {
if (expr.arguments) {
for (const argument of expr.arguments) {
if (isNarrowableReference(argument)) {
return true;
}
}
}
if (expr.expression.kind === SyntaxKind.PropertyAccessExpression &&
isNarrowableReference((<PropertyAccessExpression>expr.expression).expression)) {
return true;
}
return false;
}
function isNarrowingNullCheckOperands(expr1: Expression, expr2: Expression) {
return (expr1.kind === SyntaxKind.NullKeyword || expr1.kind === SyntaxKind.Identifier && (<Identifier>expr1).text === "undefined") && isNarrowableOperand(expr2);
}
function isNarrowingTypeofOperands(expr1: Expression, expr2: Expression) {
return expr1.kind === SyntaxKind.TypeOfExpression && isNarrowableOperand((<TypeOfExpression>expr1).expression) && expr2.kind === SyntaxKind.StringLiteral;
}
function isNarrowingDiscriminant(expr: Expression) {
return expr.kind === SyntaxKind.PropertyAccessExpression && isNarrowableReference((<PropertyAccessExpression>expr).expression);
}
function isNarrowingBinaryExpression(expr: BinaryExpression) {
switch (expr.operatorToken.kind) {
case SyntaxKind.EqualsToken:
@ -610,34 +637,35 @@ namespace ts {
case SyntaxKind.ExclamationEqualsToken:
case SyntaxKind.EqualsEqualsEqualsToken:
case SyntaxKind.ExclamationEqualsEqualsToken:
if ((isNarrowingExpression(expr.left) && (expr.right.kind === SyntaxKind.NullKeyword || expr.right.kind === SyntaxKind.Identifier)) ||
(isNarrowingExpression(expr.right) && (expr.left.kind === SyntaxKind.NullKeyword || expr.left.kind === SyntaxKind.Identifier))) {
return true;
}
if (isTypeOfNarrowingBinaryExpression(expr)) {
return true;
}
return false;
return isNarrowingNullCheckOperands(expr.right, expr.left) || isNarrowingNullCheckOperands(expr.left, expr.right) ||
isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right) ||
isNarrowingDiscriminant(expr.left) || isNarrowingDiscriminant(expr.right);
case SyntaxKind.InstanceOfKeyword:
return isNarrowingExpression(expr.left);
return isNarrowableOperand(expr.left);
case SyntaxKind.CommaToken:
return isNarrowingExpression(expr.right);
}
return false;
}
function isTypeOfNarrowingBinaryExpression(expr: BinaryExpression) {
let typeOf: Expression;
if (expr.left.kind === SyntaxKind.StringLiteral) {
typeOf = expr.right;
function isNarrowableOperand(expr: Expression): boolean {
switch (expr.kind) {
case SyntaxKind.ParenthesizedExpression:
return isNarrowableOperand((<ParenthesizedExpression>expr).expression);
case SyntaxKind.BinaryExpression:
switch ((<BinaryExpression>expr).operatorToken.kind) {
case SyntaxKind.EqualsToken:
return isNarrowableOperand((<BinaryExpression>expr).left);
case SyntaxKind.CommaToken:
return isNarrowableOperand((<BinaryExpression>expr).right);
}
}
else if (expr.right.kind === SyntaxKind.StringLiteral) {
typeOf = expr.left;
}
else {
typeOf = undefined;
}
return typeOf && typeOf.kind === SyntaxKind.TypeOfExpression && isNarrowingExpression((<TypeOfExpression>typeOf).expression);
return isNarrowableReference(expr);
}
function isNarrowingSwitchStatement(switchStatement: SwitchStatement) {
const expr = switchStatement.expression;
return expr.kind === SyntaxKind.PropertyAccessExpression && isNarrowableReference((<PropertyAccessExpression>expr).expression);
}
function createBranchLabel(): FlowLabel {
@ -683,8 +711,22 @@ namespace ts {
setFlowNodeReferenced(antecedent);
return <FlowCondition>{
flags,
antecedent,
expression,
antecedent
};
}
function createFlowSwitchClause(antecedent: FlowNode, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number): FlowNode {
if (!isNarrowingSwitchStatement(switchStatement)) {
return antecedent;
}
setFlowNodeReferenced(antecedent);
return <FlowSwitchClause>{
flags: FlowFlags.SwitchClause,
switchStatement,
clauseStart,
clauseEnd,
antecedent
};
}
@ -913,9 +955,12 @@ namespace ts {
preSwitchCaseFlow = currentFlow;
bind(node.caseBlock);
addAntecedent(postSwitchLabel, currentFlow);
const hasNonEmptyDefault = forEach(node.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause && c.statements.length);
if (!hasNonEmptyDefault) {
addAntecedent(postSwitchLabel, preSwitchCaseFlow);
const hasDefault = forEach(node.caseBlock.clauses, c => c.kind === SyntaxKind.DefaultClause);
// We mark a switch statement as possibly exhaustive if it has no default clause and if all
// case clauses have unreachable end points (e.g. they all return).
node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents;
if (!hasDefault) {
addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0));
}
currentBreakTarget = saveBreakTarget;
preSwitchCaseFlow = savePreSwitchCaseFlow;
@ -924,25 +969,22 @@ namespace ts {
function bindCaseBlock(node: CaseBlock): void {
const clauses = node.clauses;
let fallthroughFlow = unreachableFlow;
for (let i = 0; i < clauses.length; i++) {
const clause = clauses[i];
if (clause.statements.length) {
if (currentFlow.flags & FlowFlags.Unreachable) {
currentFlow = preSwitchCaseFlow;
}
else {
const preCaseLabel = createBranchLabel();
addAntecedent(preCaseLabel, preSwitchCaseFlow);
addAntecedent(preCaseLabel, currentFlow);
currentFlow = finishFlowLabel(preCaseLabel);
}
bind(clause);
if (!(currentFlow.flags & FlowFlags.Unreachable) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) {
errorOnFirstToken(clause, Diagnostics.Fallthrough_case_in_switch);
}
const clauseStart = i;
while (!clauses[i].statements.length && i + 1 < clauses.length) {
bind(clauses[i]);
i++;
}
else {
bind(clause);
const preCaseLabel = createBranchLabel();
addAntecedent(preCaseLabel, createFlowSwitchClause(preSwitchCaseFlow, <SwitchStatement>node.parent, clauseStart, i + 1));
addAntecedent(preCaseLabel, fallthroughFlow);
currentFlow = finishFlowLabel(preCaseLabel);
const clause = clauses[i];
bind(clause);
fallthroughFlow = currentFlow;
if (!(currentFlow.flags & FlowFlags.Unreachable) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) {
errorOnFirstToken(clause, Diagnostics.Fallthrough_case_in_switch);
}
}
}
@ -1961,7 +2003,7 @@ namespace ts {
classPrototype.parent = leftSideOfAssignment;
const funcSymbol = container.locals[constructorFunction.text];
if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function)) {
if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) {
return;
}

View file

@ -562,7 +562,8 @@ namespace ts {
const declarationFile = getSourceFileOfNode(declaration);
const useFile = getSourceFileOfNode(usage);
if (declarationFile !== useFile) {
if (modulekind || (!compilerOptions.outFile && !compilerOptions.out)) {
if ((modulekind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
(!compilerOptions.outFile && !compilerOptions.out)) {
// nodes are in different files and order cannot be determines
return true;
}
@ -852,7 +853,8 @@ namespace ts {
if (!result) {
if (nameNotFoundMessage) {
if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg)) {
if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
!checkAndReportErrorForExtendingInterface(errorLocation)) {
error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg));
}
}
@ -936,6 +938,31 @@ namespace ts {
return false;
}
function checkAndReportErrorForExtendingInterface(errorLocation: Node): boolean {
let parentClassExpression = errorLocation;
while (parentClassExpression) {
const kind = parentClassExpression.kind;
if (kind === SyntaxKind.Identifier || kind === SyntaxKind.PropertyAccessExpression) {
parentClassExpression = parentClassExpression.parent;
continue;
}
if (kind === SyntaxKind.ExpressionWithTypeArguments) {
break;
}
return false;
}
if (!parentClassExpression) {
return false;
}
const expression = (<ExpressionWithTypeArguments>parentClassExpression).expression;
if (resolveEntityName(expression, SymbolFlags.Interface, /*ignoreErrors*/ true)) {
error(errorLocation, Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, getTextOfNode(expression));
return true;
}
return false;
}
function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void {
Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0);
// Block-scoped variables cannot be used before their definition
@ -5185,7 +5212,6 @@ namespace ts {
if (hasProperty(stringLiteralTypes, text)) {
return stringLiteralTypes[text];
}
const type = stringLiteralTypes[text] = <StringLiteralType>createType(TypeFlags.StringLiteral);
type.text = text;
return type;
@ -5650,6 +5676,10 @@ namespace ts {
return checkTypeComparableTo(source, target, /*errorNode*/ undefined);
}
function areTypesComparable(type1: Type, type2: Type): boolean {
return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1);
}
function checkTypeSubtypeOf(source: Type, target: Type, errorNode: Node, headMessage?: DiagnosticMessage, containingMessageChain?: DiagnosticMessageChain): boolean {
return checkTypeRelatedTo(source, target, subtypeRelation, errorNode, headMessage, containingMessageChain);
}
@ -6830,8 +6860,10 @@ namespace ts {
return !!getPropertyOfType(type, "0");
}
function isStringLiteralType(type: Type) {
return type.flags & TypeFlags.StringLiteral;
function isStringLiteralUnionType(type: Type): boolean {
return type.flags & TypeFlags.StringLiteral ? true :
type.flags & TypeFlags.Union ? forEach((<UnionType>type).types, isStringLiteralUnionType) :
false;
}
/**
@ -7696,6 +7728,35 @@ namespace ts {
return node;
}
function getTypeOfSwitchClause(clause: CaseClause | DefaultClause) {
if (clause.kind === SyntaxKind.CaseClause) {
const expr = (<CaseClause>clause).expression;
return expr.kind === SyntaxKind.StringLiteral ? getStringLiteralTypeForText((<StringLiteral>expr).text) : checkExpression(expr);
}
return undefined;
}
function getSwitchClauseTypes(switchStatement: SwitchStatement): Type[] {
const links = getNodeLinks(switchStatement);
if (!links.switchTypes) {
// If all case clauses specify expressions that have unit types, we return an array
// of those unit types. Otherwise we return an empty array.
const types = map(switchStatement.caseBlock.clauses, getTypeOfSwitchClause);
links.switchTypes = forEach(types, t => !t || t.flags & TypeFlags.StringLiteral) ? types : emptyArray;
}
return links.switchTypes;
}
function eachTypeContainedIn(source: Type, types: Type[]) {
return source.flags & TypeFlags.Union ? !forEach((<UnionType>source).types, t => !contains(types, t)) : contains(types, source);
}
function filterType(type: Type, f: (t: Type) => boolean): Type {
return type.flags & TypeFlags.Union ?
getUnionType(filter((<UnionType>type).types, f)) :
f(type) ? type : neverType;
}
function getFlowTypeOfReference(reference: Node, declaredType: Type, assumeInitialized: boolean, includeOuterFunctions: boolean) {
let key: string;
if (!reference.flowNode || assumeInitialized && !(declaredType.flags & TypeFlags.Narrowable)) {
@ -7733,6 +7794,9 @@ namespace ts {
else if (flow.flags & FlowFlags.Condition) {
type = getTypeAtFlowCondition(<FlowCondition>flow);
}
else if (flow.flags & FlowFlags.SwitchClause) {
type = getTypeAtSwitchClause(<FlowSwitchClause>flow);
}
else if (flow.flags & FlowFlags.Label) {
if ((<FlowLabel>flow).antecedents.length === 1) {
flow = (<FlowLabel>flow).antecedents[0];
@ -7816,6 +7880,11 @@ namespace ts {
return type;
}
function getTypeAtSwitchClause(flow: FlowSwitchClause) {
const type = getTypeAtFlowNode(flow.antecedent);
return narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
}
function getTypeAtFlowBranchLabel(flow: FlowLabel) {
const antecedentTypes: Type[] = [];
for (const antecedent of flow.antecedents) {
@ -7895,12 +7964,26 @@ namespace ts {
case SyntaxKind.ExclamationEqualsToken:
case SyntaxKind.EqualsEqualsEqualsToken:
case SyntaxKind.ExclamationEqualsEqualsToken:
if (isNullOrUndefinedLiteral(expr.left) || isNullOrUndefinedLiteral(expr.right)) {
return narrowTypeByNullCheck(type, expr, assumeTrue);
const left = expr.left;
const operator = expr.operatorToken.kind;
const right = expr.right;
if (isNullOrUndefinedLiteral(right)) {
return narrowTypeByNullCheck(type, left, operator, right, assumeTrue);
}
if (expr.left.kind === SyntaxKind.TypeOfExpression && expr.right.kind === SyntaxKind.StringLiteral ||
expr.left.kind === SyntaxKind.StringLiteral && expr.right.kind === SyntaxKind.TypeOfExpression) {
return narrowTypeByTypeof(type, expr, assumeTrue);
if (isNullOrUndefinedLiteral(left)) {
return narrowTypeByNullCheck(type, right, operator, left, assumeTrue);
}
if (left.kind === SyntaxKind.TypeOfExpression && right.kind === SyntaxKind.StringLiteral) {
return narrowTypeByTypeof(type, <TypeOfExpression>left, operator, <LiteralExpression>right, assumeTrue);
}
if (right.kind === SyntaxKind.TypeOfExpression && left.kind === SyntaxKind.StringLiteral) {
return narrowTypeByTypeof(type, <TypeOfExpression>right, operator, <LiteralExpression>left, assumeTrue);
}
if (left.kind === SyntaxKind.PropertyAccessExpression) {
return narrowTypeByDiscriminant(type, <PropertyAccessExpression>left, operator, right, assumeTrue);
}
if (right.kind === SyntaxKind.PropertyAccessExpression) {
return narrowTypeByDiscriminant(type, <PropertyAccessExpression>right, operator, left, assumeTrue);
}
break;
case SyntaxKind.InstanceOfKeyword:
@ -7911,41 +7994,35 @@ namespace ts {
return type;
}
function narrowTypeByNullCheck(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type {
// We have '==', '!=', '===', or '!==' operator with 'null' or 'undefined' on one side
const operator = expr.operatorToken.kind;
const nullLike = isNullOrUndefinedLiteral(expr.left) ? expr.left : expr.right;
const narrowed = isNullOrUndefinedLiteral(expr.left) ? expr.right : expr.left;
function narrowTypeByNullCheck(type: Type, target: Expression, operator: SyntaxKind, literal: Expression, assumeTrue: boolean): Type {
// We have '==', '!=', '===', or '!==' operator with 'null' or 'undefined' as value
if (operator === SyntaxKind.ExclamationEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) {
assumeTrue = !assumeTrue;
}
if (!strictNullChecks || !isMatchingReference(reference, getReferenceFromExpression(narrowed))) {
if (!strictNullChecks || !isMatchingReference(reference, getReferenceFromExpression(target))) {
return type;
}
const doubleEquals = operator === SyntaxKind.EqualsEqualsToken || operator === SyntaxKind.ExclamationEqualsToken;
const facts = doubleEquals ?
assumeTrue ? TypeFacts.EQUndefinedOrNull : TypeFacts.NEUndefinedOrNull :
nullLike.kind === SyntaxKind.NullKeyword ?
literal.kind === SyntaxKind.NullKeyword ?
assumeTrue ? TypeFacts.EQNull : TypeFacts.NENull :
assumeTrue ? TypeFacts.EQUndefined : TypeFacts.NEUndefined;
return getTypeWithFacts(type, facts);
}
function narrowTypeByTypeof(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type {
// We have '==', '!=', '====', or !==' operator with 'typeof xxx' on the left
// and string literal on the right
const narrowed = getReferenceFromExpression((<TypeOfExpression>(expr.left.kind === SyntaxKind.TypeOfExpression ? expr.left : expr.right)).expression);
const literal = <LiteralExpression>(expr.right.kind === SyntaxKind.StringLiteral ? expr.right : expr.left);
if (!isMatchingReference(reference, narrowed)) {
function narrowTypeByTypeof(type: Type, typeOfExpr: TypeOfExpression, operator: SyntaxKind, literal: LiteralExpression, assumeTrue: boolean): Type {
// We have '==', '!=', '====', or !==' operator with 'typeof xxx' and string literal operands
const target = getReferenceFromExpression(typeOfExpr.expression);
if (!isMatchingReference(reference, target)) {
// For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the
// narrowed type of 'y' to its declared type.
if (containsMatchingReference(reference, narrowed)) {
if (containsMatchingReference(reference, target)) {
return declaredType;
}
return type;
}
if (expr.operatorToken.kind === SyntaxKind.ExclamationEqualsToken ||
expr.operatorToken.kind === SyntaxKind.ExclamationEqualsEqualsToken) {
if (operator === SyntaxKind.ExclamationEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) {
assumeTrue = !assumeTrue;
}
if (assumeTrue && !(type.flags & TypeFlags.Union)) {
@ -7963,6 +8040,58 @@ namespace ts {
return getTypeWithFacts(type, facts);
}
function narrowTypeByDiscriminant(type: Type, propAccess: PropertyAccessExpression, operator: SyntaxKind, value: Expression, assumeTrue: boolean): Type {
// We have '==', '!=', '===', or '!==' operator with property access as target
if (!isMatchingReference(reference, propAccess.expression)) {
return type;
}
const propName = propAccess.name.text;
const propType = getTypeOfPropertyOfType(type, propName);
if (!propType || !isStringLiteralUnionType(propType)) {
return type;
}
const discriminantType = value.kind === SyntaxKind.StringLiteral ? getStringLiteralTypeForText((<StringLiteral>value).text) : checkExpression(value);
if (!isStringLiteralUnionType(discriminantType)) {
return type;
}
if (operator === SyntaxKind.ExclamationEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) {
assumeTrue = !assumeTrue;
}
if (assumeTrue) {
return filterType(type, t => areTypesComparable(getTypeOfPropertyOfType(t, propName), discriminantType));
}
if (discriminantType.flags & TypeFlags.StringLiteral) {
return filterType(type, t => getTypeOfPropertyOfType(t, propName) !== discriminantType);
}
return type;
}
function narrowTypeBySwitchOnDiscriminant(type: Type, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number) {
// We have switch statement with property access expression
if (!isMatchingReference(reference, (<PropertyAccessExpression>switchStatement.expression).expression)) {
return type;
}
const propName = (<PropertyAccessExpression>switchStatement.expression).name.text;
const propType = getTypeOfPropertyOfType(type, propName);
if (!propType || !isStringLiteralUnionType(propType)) {
return type;
}
const switchTypes = getSwitchClauseTypes(switchStatement);
if (!switchTypes.length) {
return type;
}
const clauseTypes = switchTypes.slice(clauseStart, clauseEnd);
const hasDefaultClause = clauseStart === clauseEnd || contains(clauseTypes, undefined);
const caseTypes = hasDefaultClause ? filter(clauseTypes, t => !!t) : clauseTypes;
const discriminantType = caseTypes.length ? getUnionType(caseTypes) : undefined;
const caseType = discriminantType && filterType(type, t => isTypeComparableTo(discriminantType, getTypeOfPropertyOfType(t, propName)));
if (!hasDefaultClause) {
return caseType;
}
const defaultType = filterType(type, t => !eachTypeContainedIn(getTypeOfPropertyOfType(t, propName), switchTypes));
return caseType ? getUnionType([caseType, defaultType]) : defaultType;
}
function narrowTypeByInstanceof(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type {
const left = getReferenceFromExpression(expr.left);
if (!isMatchingReference(reference, left)) {
@ -8933,10 +9062,6 @@ namespace ts {
return applyToContextualType(type, t => getIndexTypeOfStructuredType(t, kind));
}
function contextualTypeIsStringLiteralType(type: Type): boolean {
return !!(type.flags & TypeFlags.Union ? forEach((<UnionType>type).types, isStringLiteralType) : isStringLiteralType(type));
}
// Return true if the given contextual type is a tuple-like type
function contextualTypeIsTupleLikeType(type: Type): boolean {
return !!(type.flags & TypeFlags.Union ? forEach((<UnionType>type).types, isTupleLikeType) : isTupleLikeType(type));
@ -10038,7 +10163,7 @@ namespace ts {
}
const prop = getPropertyOfType(apparentType, right.text);
if (!prop) {
if (right.text) {
if (right.text && !checkAndReportErrorForExtendingInterface(node)) {
error(right, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(right), typeToString(type.flags & TypeFlags.ThisType ? apparentType : type));
}
return unknownType;
@ -11495,8 +11620,12 @@ namespace ts {
// When resolved signature is a call signature (and not a construct signature) the result type is any, unless
// the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations
// in a JS file
const funcSymbol = checkExpression(node.expression).symbol;
if (funcSymbol && funcSymbol.members && (funcSymbol.flags & SymbolFlags.Function)) {
// Note:JS inferred classes might come from a variable declaration instead of a function declaration.
// In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration.
const funcSymbol = node.expression.kind === SyntaxKind.Identifier ?
getResolvedSymbol(node.expression as Identifier) :
checkExpression(node.expression).symbol;
if (funcSymbol && funcSymbol.members && (funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) {
return getInferredClassType(funcSymbol);
}
else if (compilerOptions.noImplicitAny) {
@ -11520,7 +11649,10 @@ namespace ts {
function checkAssertion(node: AssertionExpression) {
const exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression));
checkSourceElement(node.type);
const targetType = getTypeFromTypeNode(node.type);
if (produceDiagnostics && targetType !== unknownType) {
const widenedType = getWidenedType(exprType);
if (!isTypeComparableTo(targetType, widenedType)) {
@ -11760,10 +11892,42 @@ namespace ts {
return aggregatedTypes;
}
function isExhaustiveSwitchStatement(node: SwitchStatement): boolean {
const expr = node.expression;
if (!node.possiblyExhaustive || expr.kind !== SyntaxKind.PropertyAccessExpression) {
return false;
}
const type = checkExpression((<PropertyAccessExpression>expr).expression);
if (!(type.flags & TypeFlags.Union)) {
return false;
}
const propName = (<PropertyAccessExpression>expr).name.text;
const propType = getTypeOfPropertyOfType(type, propName);
if (!propType || !isStringLiteralUnionType(propType)) {
return false;
}
const switchTypes = getSwitchClauseTypes(node);
if (!switchTypes.length) {
return false;
}
return eachTypeContainedIn(propType, switchTypes);
}
function functionHasImplicitReturn(func: FunctionLikeDeclaration) {
if (!(func.flags & NodeFlags.HasImplicitReturn)) {
return false;
}
const lastStatement = lastOrUndefined((<Block>func.body).statements);
if (lastStatement && lastStatement.kind === SyntaxKind.SwitchStatement && isExhaustiveSwitchStatement(<SwitchStatement>lastStatement)) {
return false;
}
return true;
}
function checkAndAggregateReturnExpressionTypes(func: FunctionLikeDeclaration, contextualMapper: TypeMapper): Type[] {
const isAsync = isAsyncFunctionLike(func);
const aggregatedTypes: Type[] = [];
let hasReturnWithNoExpression = !!(func.flags & NodeFlags.HasImplicitReturn);
let hasReturnWithNoExpression = functionHasImplicitReturn(func);
let hasReturnOfTypeNever = false;
forEachReturnStatement(<Block>func.body, returnStatement => {
const expr = returnStatement.expression;
@ -11820,7 +11984,7 @@ namespace ts {
// If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check.
// also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw
if (nodeIsMissing(func.body) || func.body.kind !== SyntaxKind.Block || !(func.flags & NodeFlags.HasImplicitReturn)) {
if (nodeIsMissing(func.body) || func.body.kind !== SyntaxKind.Block || !functionHasImplicitReturn(func)) {
return;
}
@ -12598,7 +12762,7 @@ namespace ts {
function checkStringLiteralExpression(node: StringLiteral): Type {
const contextualType = getContextualType(node);
if (contextualType && contextualTypeIsStringLiteralType(contextualType)) {
if (contextualType && isStringLiteralUnionType(contextualType)) {
return getStringLiteralTypeForText(node.text);
}
@ -13555,9 +13719,6 @@ namespace ts {
}
}
// when checking exported function declarations across modules check only duplicate implementations
// names and consistency of modifiers are verified when we check local symbol
const isExportSymbolInsideModule = symbol.parent && symbol.parent.flags & SymbolFlags.Module;
let duplicateFunctionDeclaration = false;
let multipleConstructorImplementation = false;
for (const current of declarations) {
@ -13590,7 +13751,7 @@ namespace ts {
duplicateFunctionDeclaration = true;
}
}
else if (!isExportSymbolInsideModule && previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) {
else if (previousDeclaration && previousDeclaration.parent === node.parent && previousDeclaration.end !== node.pos) {
reportImplementationExpectedError(previousDeclaration);
}
@ -13624,7 +13785,7 @@ namespace ts {
}
// Abstract methods can't have an implementation -- in particular, they don't need one.
if (!isExportSymbolInsideModule && lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
!(lastSeenNonAmbientDeclaration.flags & NodeFlags.Abstract) && !lastSeenNonAmbientDeclaration.questionToken) {
reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
}

View file

@ -412,6 +412,10 @@ namespace ts {
},
description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon
},
{
name: "disableProjectSizeLimit",
type: "boolean"
},
{
name: "strictNullChecks",
type: "boolean",
@ -493,13 +497,20 @@ namespace ts {
}
/* @internal */
export function parseListTypeOption(opt: CommandLineOptionOfListType, value: string, errors: Diagnostic[]): (string | number)[] {
const values = trimString((value || "")).split(",");
export function parseListTypeOption(opt: CommandLineOptionOfListType, value = "", errors: Diagnostic[]): (string | number)[] | undefined {
value = trimString(value);
if (startsWith(value, "-")) {
return undefined;
}
if (value === "") {
return [];
}
const values = value.split(",");
switch (opt.element.type) {
case "number":
return ts.map(values, parseInt);
return map(values, parseInt);
case "string":
return ts.map(values, v => v || "");
return map(values, v => v || "");
default:
return filter(map(values, v => parseCustomTypeOption(<CommandLineOptionOfCustomType>opt.element, v, errors)), v => !!v);
}
@ -560,8 +571,11 @@ namespace ts {
i++;
break;
case "list":
options[opt.name] = parseListTypeOption(<CommandLineOptionOfListType>opt, args[i], errors);
i++;
const result = parseListTypeOption(<CommandLineOptionOfListType>opt, args[i], errors);
options[opt.name] = result || [];
if (result) {
i++;
}
break;
// If not a primitive, the possible types are specified in what is effectively a map of options.
default:

View file

@ -1935,6 +1935,10 @@
"category": "Error",
"code": 2688
},
"Cannot extend an interface '{0}'. Did you mean 'implements'?": {
"category": "Error",
"code": 2689
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000
@ -2929,10 +2933,6 @@
"category": "Error",
"code": 8012
},
"'property declarations' can only be used in a .ts file.": {
"category": "Error",
"code": 8014
},
"'enum declarations' can only be used in a .ts file.": {
"category": "Error",
"code": 8015

View file

@ -2076,7 +2076,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
function createPropertyAccessExpression(expression: Expression, name: Identifier): PropertyAccessExpression {
const result = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression);
result.expression = parenthesizeForAccess(expression);
result.dotToken = createSynthesizedNode(SyntaxKind.DotToken);
result.name = name;
return result;
}
@ -2150,9 +2149,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}
// Return true if identifier resolves to an exported member of a namespace
function isNamespaceExportReference(node: Identifier) {
function isExportReference(node: Identifier) {
const container = resolver.getReferencedExportContainer(node);
return container && container.kind !== SyntaxKind.SourceFile;
return !!container;
}
// Return true if identifier resolves to an imported identifier
@ -2185,10 +2184,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
// const foo_1 = require('./foo');
// exports.baz = { foo: foo_1.foo };
//
if (languageVersion < ScriptTarget.ES6 || (modulekind !== ModuleKind.ES6 && isImportedReference(node.name)) || isNamespaceExportReference(node.name) ) {
if (languageVersion < ScriptTarget.ES6 || (modulekind !== ModuleKind.ES6 && isImportedReference(node.name)) || isExportReference(node.name)) {
// Emit identifier as an identifier
write(": ");
emit(node.name);
emitExpressionIdentifier(node.name);
}
if (languageVersion >= ScriptTarget.ES6 && node.objectAssignmentInitializer) {
@ -2223,11 +2222,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
// Returns 'true' if the code was actually indented, false otherwise.
// If the code is not indented, an optional valueToWriteWhenNotIndenting will be
// emitted instead.
function indentIfOnDifferentLines(parent: Node, node1: Node, node2: Node, valueToWriteWhenNotIndenting?: string): boolean {
function indentIfOnDifferentLines(parent: Node, node1: TextRange, node2: TextRange, valueToWriteWhenNotIndenting?: string): boolean {
const realNodesAreOnDifferentLines = !nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2);
// Always use a newline for synthesized code if the synthesizer desires it.
const synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2);
const synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2 as Node);
if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) {
increaseIndent();
@ -2257,7 +2256,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}
emit(node.expression);
const indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, node.dotToken);
const dotRangeStart = nodeIsSynthesized(node.expression) ? -1 : node.expression.end;
const dotRangeEnd = nodeIsSynthesized(node.expression) ? -1 : skipTrivia(currentText, node.expression.end) + 1;
const dotToken = <TextRange>{ pos: dotRangeStart, end: dotRangeEnd };
const indentedBeforeDot = indentIfOnDifferentLines(node, node.expression, dotToken);
// 1 .toString is a valid property access, emit a space after the literal
// Also emit a space if expression is a integer const enum value - it will appear in generated code as numeric literal
@ -2283,7 +2285,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
write(".");
}
const indentedAfterDot = indentIfOnDifferentLines(node, node.dotToken, node.name);
const indentedAfterDot = indentIfOnDifferentLines(node, dotToken, node.name);
emit(node.name);
decreaseIndentIf(indentedBeforeDot, indentedAfterDot);
}
@ -2780,7 +2782,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
const identifier = emitTempVariableAssignment(leftHandSideExpression.expression, /*canDefineTempVariablesInPlace*/ false, /*shouldEmitCommaBeforeAssignment*/ false);
synthesizedLHS.expression = identifier;
(<PropertyAccessExpression>synthesizedLHS).dotToken = leftHandSideExpression.dotToken;
(<PropertyAccessExpression>synthesizedLHS).name = leftHandSideExpression.name;
write(", ");
}
@ -3758,7 +3759,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
getLineOfLocalPositionFromLineMap(currentLineMap, node2.end);
}
function nodeEndIsOnSameLineAsNodeStart(node1: Node, node2: Node) {
function nodeEndIsOnSameLineAsNodeStart(node1: TextRange, node2: TextRange) {
return getLineOfLocalPositionFromLineMap(currentLineMap, node1.end) ===
getLineOfLocalPositionFromLineMap(currentLineMap, skipTrivia(currentText, node2.pos));
}
@ -6133,10 +6134,10 @@ const _super = (function (geti, seti) {
if (parameters[i].dotDotDotToken) {
let parameterType = parameters[i].type;
if (parameterType.kind === SyntaxKind.ArrayType) {
if (parameterType && parameterType.kind === SyntaxKind.ArrayType) {
parameterType = (<ArrayTypeNode>parameterType).elementType;
}
else if (parameterType.kind === SyntaxKind.TypeReference && (<TypeReferenceNode>parameterType).typeArguments && (<TypeReferenceNode>parameterType).typeArguments.length === 1) {
else if (parameterType && parameterType.kind === SyntaxKind.TypeReference && (<TypeReferenceNode>parameterType).typeArguments && (<TypeReferenceNode>parameterType).typeArguments.length === 1) {
parameterType = (<TypeReferenceNode>parameterType).typeArguments[0];
}
else {
@ -6156,9 +6157,15 @@ const _super = (function (geti, seti) {
/** Serializes the return type of function. Used by the __metadata decorator for a method. */
function emitSerializedReturnTypeOfNode(node: Node) {
if (node && isFunctionLike(node) && (<FunctionLikeDeclaration>node).type) {
emitSerializedTypeNode((<FunctionLikeDeclaration>node).type);
return;
if (node && isFunctionLike(node)) {
if ((<FunctionLikeDeclaration>node).type) {
emitSerializedTypeNode((<FunctionLikeDeclaration>node).type);
return;
}
else if (isAsyncFunctionLike(<FunctionLikeDeclaration>node)) {
write("Promise");
return;
}
}
write("void 0");

View file

@ -137,7 +137,6 @@ namespace ts {
return visitNodes(cbNodes, (<ObjectLiteralExpression>node).properties);
case SyntaxKind.PropertyAccessExpression:
return visitNode(cbNode, (<PropertyAccessExpression>node).expression) ||
visitNode(cbNode, (<PropertyAccessExpression>node).dotToken) ||
visitNode(cbNode, (<PropertyAccessExpression>node).name);
case SyntaxKind.ElementAccessExpression:
return visitNode(cbNode, (<ElementAccessExpression>node).expression) ||
@ -3571,7 +3570,7 @@ namespace ts {
// If it wasn't then just try to parse out a '.' and report an error.
const node = <PropertyAccessExpression>createNode(SyntaxKind.PropertyAccessExpression, expression.pos);
node.expression = expression;
node.dotToken = parseExpectedToken(SyntaxKind.DotToken, /*reportAtCurrentPosition*/ false, Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
parseExpectedToken(SyntaxKind.DotToken, /*reportAtCurrentPosition*/ false, Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
return finishNode(node);
}
@ -3807,7 +3806,6 @@ namespace ts {
if (dotToken) {
const propertyAccess = <PropertyAccessExpression>createNode(SyntaxKind.PropertyAccessExpression, expression.pos);
propertyAccess.expression = expression;
propertyAccess.dotToken = dotToken;
propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true);
expression = finishNode(propertyAccess);
continue;

View file

@ -1601,8 +1601,19 @@ namespace ts {
}
break;
case SyntaxKind.PropertyDeclaration:
diagnostics.push(createDiagnosticForNode(node, Diagnostics.property_declarations_can_only_be_used_in_a_ts_file));
return true;
const propertyDeclaration = <PropertyDeclaration>node;
if (propertyDeclaration.modifiers) {
for (const modifier of propertyDeclaration.modifiers) {
if (modifier.kind !== SyntaxKind.StaticKeyword) {
diagnostics.push(createDiagnosticForNode(modifier, Diagnostics._0_can_only_be_used_in_a_ts_file, tokenToString(modifier.kind)));
return true;
}
}
}
if (checkTypeAnnotation((<PropertyDeclaration>node).type)) {
return true;
}
break;
case SyntaxKind.EnumDeclaration:
diagnostics.push(createDiagnosticForNode(node, Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file));
return true;

View file

@ -15,6 +15,7 @@ namespace ts {
useCaseSensitiveFileNames: boolean;
write(s: string): void;
readFile(path: string, encoding?: string): string;
getFileSize?(path: string): number;
writeFile(path: string, data: string, writeByteOrderMark?: boolean): void;
watchFile?(path: string, callback: FileWatcherCallback): FileWatcher;
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
@ -79,7 +80,7 @@ namespace ts {
realpath(path: string): string;
};
export var sys: System = (function () {
export var sys: System = (function() {
function getWScriptSystem(): System {
@ -494,7 +495,7 @@ namespace ts {
}
);
},
resolvePath: function (path: string): string {
resolvePath: function(path: string): string {
return _path.resolve(path);
},
fileExists,
@ -531,6 +532,16 @@ namespace ts {
}
return process.memoryUsage().heapUsed;
},
getFileSize(path) {
try {
const stat = _fs.statSync(path);
if (stat.isFile()) {
return stat.size;
}
}
catch (e) { }
return 0;
},
exit(exitCode?: number): void {
process.exit(exitCode);
},

View file

@ -980,7 +980,6 @@ namespace ts {
// @kind(SyntaxKind.PropertyAccessExpression)
export interface PropertyAccessExpression extends MemberExpression, Declaration {
expression: LeftHandSideExpression;
dotToken: Node;
name: Identifier;
}
@ -1188,6 +1187,7 @@ namespace ts {
export interface SwitchStatement extends Statement {
expression: Expression;
caseBlock: CaseBlock;
possiblyExhaustive?: boolean;
}
// @kind(SyntaxKind.CaseBlock)
@ -1554,8 +1554,9 @@ namespace ts {
Assignment = 1 << 4, // Assignment
TrueCondition = 1 << 5, // Condition known to be true
FalseCondition = 1 << 6, // Condition known to be false
Referenced = 1 << 7, // Referenced as antecedent once
Shared = 1 << 8, // Referenced as antecedent more than once
SwitchClause = 1 << 7, // Switch statement clause
Referenced = 1 << 8, // Referenced as antecedent once
Shared = 1 << 9, // Referenced as antecedent more than once
Label = BranchLabel | LoopLabel,
Condition = TrueCondition | FalseCondition
}
@ -1591,6 +1592,13 @@ namespace ts {
antecedent: FlowNode;
}
export interface FlowSwitchClause extends FlowNode {
switchStatement: SwitchStatement;
clauseStart: number; // Start index of case/default clause range
clauseEnd: number; // End index of case/default clause range
antecedent: FlowNode;
}
export interface AmdDependency {
path: string;
name: string;
@ -2193,6 +2201,7 @@ namespace ts {
resolvedJsxType?: Type; // resolved element attributes type of a JSX openinglike element
hasSuperCall?: boolean; // recorded result when we try to find super-call. We only try to find one if this flag is undefined, indicating that we haven't made an attempt.
superCall?: ExpressionStatement; // Cached first super-call found in the constructor. Used in checking whether super is called before this-accessing
switchTypes?: Type[]; // Cached array of switch case expression types
}
export const enum TypeFlags {
@ -2232,7 +2241,8 @@ namespace ts {
/* @internal */
Nullable = Undefined | Null,
Falsy = String | Number | Boolean | Void | Undefined | Null,
/* @internal */
Falsy = Void | Undefined | Null, // TODO: Add false, 0, and ""
/* @internal */
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null | Never,
/* @internal */
@ -2569,6 +2579,7 @@ namespace ts {
/* @internal */ suppressOutputPathCheck?: boolean;
target?: ScriptTarget;
traceResolution?: boolean;
disableSizeLimit?: boolean;
types?: string[];
/** Paths used to used to compute primary types search locations */
typeRoots?: string[];

View file

@ -1264,6 +1264,18 @@ namespace ts {
return charCode === CharacterCodes.singleQuote || charCode === CharacterCodes.doubleQuote;
}
/**
* Returns true if the node is a variable declaration whose initializer is a function expression.
* This function does not test if the node is in a JavaScript file or not.
*/
export function isDeclarationOfFunctionExpression(s: Symbol) {
if (s.valueDeclaration && s.valueDeclaration.kind === SyntaxKind.VariableDeclaration) {
const declaration = s.valueDeclaration as VariableDeclaration;
return declaration.initializer && declaration.initializer.kind === SyntaxKind.FunctionExpression;
}
return false;
}
/// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property
/// assignments we treat as special in the binder
export function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind {
@ -2702,6 +2714,10 @@ namespace ts {
return forEach(supportedJavascriptExtensions, extension => fileExtensionIs(fileName, extension));
}
export function hasTypeScriptFileExtension(fileName: string) {
return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension));
}
/**
* Replace each instance of non-ascii characters by one, two, three, or four escape sequences
* representing the UTF-8 encoding of the character, and return the expanded char code list.

View file

@ -717,6 +717,8 @@ namespace FourSlash {
public verifyCompletionEntryDetails(entryName: string, expectedText: string, expectedDocumentation?: string, kind?: string) {
const details = this.getCompletionEntryDetails(entryName);
assert(details, "no completion entry available");
assert.equal(ts.displayPartsToString(details.displayParts), expectedText, this.assertionMessageAtLastKnownMarker("completion entry details text"));
if (expectedDocumentation !== undefined) {
@ -728,27 +730,6 @@ namespace FourSlash {
}
}
public verifyReferencesAtPositionListContains(fileName: string, start: number, end: number, isWriteAccess?: boolean) {
const references = this.getReferencesAtCaret();
if (!references || references.length === 0) {
this.raiseError("verifyReferencesAtPositionListContains failed - found 0 references, expected at least one.");
}
for (let i = 0; i < references.length; i++) {
const reference = references[i];
if (reference && reference.fileName === fileName && reference.textSpan.start === start && ts.textSpanEnd(reference.textSpan) === end) {
if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) {
this.raiseError(`verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ${reference.isWriteAccess}, expected: ${isWriteAccess}.`);
}
return;
}
}
const missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess };
this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(references)})`);
}
public verifyReferencesCountIs(count: number, localFilesOnly = true) {
const references = this.getReferencesAtCaret();
let referencesCount = 0;
@ -772,6 +753,73 @@ namespace FourSlash {
}
}
public verifyReferencesAre(expectedReferences: Range[]) {
const actualReferences = this.getReferencesAtCaret() || [];
if (actualReferences.length > expectedReferences.length) {
// Find the unaccounted-for reference.
for (const actual of actualReferences) {
if (!ts.forEach(expectedReferences, r => r.start === actual.textSpan.start)) {
this.raiseError(`A reference ${actual} is unaccounted for.`);
}
}
// Probably will never reach here.
this.raiseError(`There are ${actualReferences.length} references but only ${expectedReferences.length} were expected.`);
}
for (const reference of expectedReferences) {
const {fileName, start, end} = reference;
if (reference.marker) {
const {isWriteAccess, isDefinition} = reference.marker.data;
this.verifyReferencesWorker(actualReferences, fileName, start, end, isWriteAccess, isDefinition);
}
else {
this.verifyReferencesWorker(actualReferences, fileName, start, end);
}
}
}
public verifyReferencesOf({fileName, start}: Range, references: Range[]) {
this.openFile(fileName);
this.goToPosition(start);
this.verifyReferencesAre(references);
}
public verifyRangesReferenceEachOther(ranges?: Range[]) {
ranges = ranges || this.getRanges();
assert(ranges.length);
for (const range of ranges) {
this.verifyReferencesOf(range, ranges);
}
}
public verifyReferencesAtPositionListContains(fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) {
const references = this.getReferencesAtCaret();
if (!references || references.length === 0) {
this.raiseError("verifyReferencesAtPositionListContains failed - found 0 references, expected at least one.");
}
this.verifyReferencesWorker(references, fileName, start, end, isWriteAccess, isDefinition);
}
private verifyReferencesWorker(references: ts.ReferenceEntry[], fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) {
for (let i = 0; i < references.length; i++) {
const reference = references[i];
if (reference && reference.fileName === fileName && reference.textSpan.start === start && ts.textSpanEnd(reference.textSpan) === end) {
if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) {
this.raiseError(`verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ${reference.isWriteAccess}, expected: ${isWriteAccess}.`);
}
if (typeof isDefinition !== "undefined" && reference.isDefinition !== isDefinition) {
this.raiseError(`verifyReferencesAtPositionListContains failed - item isDefinition value does not match, actual: ${reference.isDefinition}, expected: ${isDefinition}.`);
}
return;
}
}
const missingItem = { fileName, start, end, isWriteAccess, isDefinition };
this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(references)})`);
}
private getMemberListAtCaret() {
return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition);
}
@ -2831,14 +2879,6 @@ namespace FourSlashInterface {
this.state.verifyMemberListIsEmpty(this.negative);
}
public referencesCountIs(count: number) {
this.state.verifyReferencesCountIs(count, /*localFilesOnly*/ false);
}
public referencesAtPositionContains(range: FourSlash.Range, isWriteAccess?: boolean) {
this.state.verifyReferencesAtPositionListContains(range.fileName, range.start, range.end, isWriteAccess);
}
public signatureHelpPresent() {
this.state.verifySignatureHelpPresent(!this.negative);
}
@ -2930,6 +2970,22 @@ namespace FourSlashInterface {
this.state.verifyGetEmitOutputContentsForCurrentFile(expected);
}
public referencesCountIs(count: number) {
this.state.verifyReferencesCountIs(count, /*localFilesOnly*/ false);
}
public referencesAre(ranges: FourSlash.Range[]) {
this.state.verifyReferencesAre(ranges);
}
public referencesOf(start: FourSlash.Range, references: FourSlash.Range[]) {
this.state.verifyReferencesOf(start, references);
}
public rangesReferenceEachOther(ranges?: FourSlash.Range[]) {
this.state.verifyRangesReferenceEachOther(ranges);
}
public currentParameterHelpArgumentNameIs(name: string) {
this.state.verifyCurrentParameterHelpName(name);
}

View file

@ -4,7 +4,7 @@
/////////////////////////////
interface Algorithm {
name?: string;
name: string;
}
interface AriaRequestEventInit extends EventInit {
@ -851,6 +851,7 @@ interface UIEventInit extends EventInit {
}
interface WebGLContextAttributes {
failIfMajorPerformanceCaveat?: boolean;
alpha?: boolean;
depth?: boolean;
stencil?: boolean;
@ -919,7 +920,7 @@ interface ApplicationCache extends EventTarget {
oncached: (ev: Event) => any;
onchecking: (ev: Event) => any;
ondownloading: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onnoupdate: (ev: Event) => any;
onobsolete: (ev: Event) => any;
onprogress: (ev: ProgressEvent) => any;
@ -2410,7 +2411,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
* Fires when the user aborts the download.
* @param ev The event.
*/
onabort: (ev: Event) => any;
onabort: (ev: UIEvent) => any;
/**
* Fires when the object is set as the active element.
* @param ev The event.
@ -2512,7 +2513,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
* Fires when an error occurs during object loading.
* @param ev The event.
*/
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
/**
* Fires when the object receives focus.
* @param ev The event.
@ -2988,7 +2989,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven
* Returns a reference to the first object with the specified value of the ID or NAME attribute.
* @param elementId String that specifies the ID value. Case-insensitive.
*/
getElementById(elementId: string): HTMLElement;
getElementById(elementId: string): HTMLElement | null;
getElementsByClassName(classNames: string): HTMLCollectionOf<Element>;
/**
* Gets a collection of objects based on the value of the NAME or ID attribute.
@ -3463,7 +3464,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
readonly scrollWidth: number;
readonly tagName: string;
innerHTML: string;
getAttribute(name?: string): string | null;
getAttribute(name: string): string | null;
getAttributeNS(namespaceURI: string, localName: string): string;
getAttributeNode(name: string): Attr;
getAttributeNodeNS(namespaceURI: string, localName: string): Attr;
@ -3673,6 +3674,7 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec
webkitRequestFullscreen(): void;
getElementsByClassName(classNames: string): NodeListOf<Element>;
matches(selector: string): boolean;
closest(selector: string): Element | null;
addEventListener(type: "MSGestureChange", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureDoubleTap", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
addEventListener(type: "MSGestureEnd", listener: (ev: MSGestureEvent) => any, useCapture?: boolean): void;
@ -4203,7 +4205,7 @@ interface HTMLBodyElement extends HTMLElement {
onbeforeprint: (ev: Event) => any;
onbeforeunload: (ev: BeforeUnloadEvent) => any;
onblur: (ev: FocusEvent) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onfocus: (ev: FocusEvent) => any;
onhashchange: (ev: HashChangeEvent) => any;
onload: (ev: Event) => any;
@ -4432,9 +4434,9 @@ interface HTMLCanvasElement extends HTMLElement {
* Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas.
* @param contextId The identifier (ID) of the type of canvas to create. Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using canvas.getContext("2d"); IE11 Preview also supports 3-D or WebGL context using canvas.getContext("experimental-webgl");
*/
getContext(contextId: "2d"): CanvasRenderingContext2D;
getContext(contextId: "experimental-webgl"): WebGLRenderingContext;
getContext(contextId: string, ...args: any[]): CanvasRenderingContext2D | WebGLRenderingContext;
getContext(contextId: "2d", contextAttributes?: Canvas2DContextAttributes): CanvasRenderingContext2D | null;
getContext(contextId: "webgl" | "experimental-webgl", contextAttributes?: WebGLContextAttributes): WebGLRenderingContext | null;
getContext(contextId: string, contextAttributes?: {}): CanvasRenderingContext2D | WebGLRenderingContext | null;
/**
* Returns a blob object encoded as a Portable Network Graphics (PNG) format from a canvas image or drawing.
*/
@ -4444,7 +4446,7 @@ interface HTMLCanvasElement extends HTMLElement {
* @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image.
*/
toDataURL(type?: string, ...args: any[]): string;
toBlob(): Blob;
toBlob(callback: (result: Blob | null) => void, ... arguments: any[]): void;
}
declare var HTMLCanvasElement: {
@ -4542,7 +4544,7 @@ interface HTMLElement extends Element {
readonly offsetParent: Element;
readonly offsetTop: number;
readonly offsetWidth: number;
onabort: (ev: Event) => any;
onabort: (ev: UIEvent) => any;
onactivate: (ev: UIEvent) => any;
onbeforeactivate: (ev: UIEvent) => any;
onbeforecopy: (ev: ClipboardEvent) => any;
@ -4570,7 +4572,7 @@ interface HTMLElement extends Element {
ondurationchange: (ev: Event) => any;
onemptied: (ev: Event) => any;
onended: (ev: MediaStreamErrorEvent) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onfocus: (ev: FocusEvent) => any;
oninput: (ev: Event) => any;
oninvalid: (ev: Event) => any;
@ -5120,7 +5122,7 @@ interface HTMLFrameSetElement extends HTMLElement {
* Fires when the object loses the input focus.
*/
onblur: (ev: FocusEvent) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
/**
* Fires when the object receives focus.
*/
@ -5643,7 +5645,7 @@ interface HTMLInputElement extends HTMLElement {
/**
* Returns a FileList object on a file type input object.
*/
readonly files: FileList;
readonly files: FileList | null;
/**
* Retrieves a reference to the form that the object is embedded in.
*/
@ -6614,7 +6616,7 @@ declare var HTMLOptionElement: {
create(): HTMLOptionElement;
}
interface HTMLOptionsCollection extends HTMLCollection {
interface HTMLOptionsCollection extends HTMLCollectionOf<HTMLOptionElement> {
length: number;
selectedIndex: number;
add(element: HTMLOptionElement | HTMLOptGroupElement, before?: HTMLElement | number): void;
@ -6778,7 +6780,7 @@ interface HTMLSelectElement extends HTMLElement {
* Sets or retrieves the name of the object.
*/
name: string;
options: HTMLCollectionOf<HTMLOptionElement>;
readonly options: HTMLOptionsCollection;
/**
* When present, marks an element that can't be submitted without a value.
*/
@ -7574,7 +7576,7 @@ interface IDBDatabase extends EventTarget {
readonly name: string;
readonly objectStoreNames: DOMStringList;
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
version: number;
onversionchange: (ev: IDBVersionChangeEvent) => any;
close(): void;
@ -7677,7 +7679,7 @@ declare var IDBOpenDBRequest: {
interface IDBRequest extends EventTarget {
readonly error: DOMError;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onsuccess: (ev: Event) => any;
readonly readyState: string;
readonly result: any;
@ -7699,7 +7701,7 @@ interface IDBTransaction extends EventTarget {
readonly mode: string;
onabort: (ev: Event) => any;
oncomplete: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
abort(): void;
objectStore(name: string): IDBObjectStore;
readonly READ_ONLY: string;
@ -7842,7 +7844,7 @@ declare var MSApp: MSApp;
interface MSAppAsyncOperation extends EventTarget {
readonly error: DOMError;
oncomplete: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
readonly readyState: number;
readonly result: any;
start(): void;
@ -8202,7 +8204,7 @@ declare var MSStreamReader: {
interface MSWebViewAsyncOperation extends EventTarget {
readonly error: DOMError;
oncomplete: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
readonly readyState: number;
readonly result: any;
readonly target: MSHTMLWebViewElement;
@ -8738,7 +8740,7 @@ interface Node extends EventTarget {
contains(child: Node): boolean;
hasAttributes(): boolean;
hasChildNodes(): boolean;
insertBefore(newChild: Node, refChild: Node): Node;
insertBefore(newChild: Node, refChild: Node | null): Node;
isDefaultNamespace(namespaceURI: string | null): boolean;
isEqualNode(arg: Node): boolean;
isSameNode(other: Node): boolean;
@ -8747,7 +8749,6 @@ interface Node extends EventTarget {
normalize(): void;
removeChild(oldChild: Node): Node;
replaceChild(newChild: Node, oldChild: Node): Node;
contains(node: Node): boolean;
readonly ATTRIBUTE_NODE: number;
readonly CDATA_SECTION_NODE: number;
readonly COMMENT_NODE: number;
@ -9283,7 +9284,7 @@ declare var RTCDTMFToneChangeEvent: {
interface RTCDtlsTransport extends RTCStatsProvider {
ondtlsstatechange: ((ev: RTCDtlsTransportStateChangedEvent) => any) | null;
onerror: ((ev: Event) => any) | null;
onerror: ((ev: ErrorEvent) => any) | null;
readonly state: string;
readonly transport: RTCIceTransport;
getLocalParameters(): RTCDtlsParameters;
@ -9338,7 +9339,7 @@ declare var RTCIceCandidatePairChangedEvent: {
interface RTCIceGatherer extends RTCStatsProvider {
readonly component: string;
onerror: ((ev: Event) => any) | null;
onerror: ((ev: ErrorEvent) => any) | null;
onlocalcandidate: ((ev: RTCIceGathererEvent) => any) | null;
createAssociatedGatherer(): RTCIceGatherer;
getLocalCandidates(): RTCIceCandidate[];
@ -9397,7 +9398,7 @@ declare var RTCIceTransportStateChangedEvent: {
}
interface RTCRtpReceiver extends RTCStatsProvider {
onerror: ((ev: Event) => any) | null;
onerror: ((ev: ErrorEvent) => any) | null;
readonly rtcpTransport: RTCDtlsTransport;
readonly track: MediaStreamTrack | null;
readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport;
@ -9417,7 +9418,7 @@ declare var RTCRtpReceiver: {
}
interface RTCRtpSender extends RTCStatsProvider {
onerror: ((ev: Event) => any) | null;
onerror: ((ev: ErrorEvent) => any) | null;
onssrcconflict: ((ev: RTCSsrcConflictEvent) => any) | null;
readonly rtcpTransport: RTCDtlsTransport;
readonly track: MediaStreamTrack;
@ -9438,7 +9439,7 @@ declare var RTCRtpSender: {
}
interface RTCSrtpSdesTransport extends EventTarget {
onerror: ((ev: Event) => any) | null;
onerror: ((ev: ErrorEvent) => any) | null;
readonly transport: RTCIceTransport;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
@ -11478,18 +11479,24 @@ declare var StyleSheetPageList: {
}
interface SubtleCrypto {
decrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): PromiseLike<any>;
deriveBits(algorithm: string | Algorithm, baseKey: CryptoKey, length: number): PromiseLike<any>;
deriveKey(algorithm: string | Algorithm, baseKey: CryptoKey, derivedKeyType: string | Algorithm, extractable: boolean, keyUsages: string[]): PromiseLike<any>;
digest(algorithm: string | Algorithm, data: ArrayBufferView): PromiseLike<any>;
encrypt(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): PromiseLike<any>;
exportKey(format: string, key: CryptoKey): PromiseLike<any>;
generateKey(algorithm: string | Algorithm, extractable: boolean, keyUsages: string[]): PromiseLike<any>;
importKey(format: string, keyData: ArrayBufferView, algorithm: string | Algorithm | null, extractable: boolean, keyUsages: string[]): PromiseLike<any>;
sign(algorithm: string | Algorithm, key: CryptoKey, data: ArrayBufferView): PromiseLike<any>;
unwrapKey(format: string, wrappedKey: ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | Algorithm, unwrappedKeyAlgorithm: string | Algorithm | null, extractable: boolean, keyUsages: string[]): PromiseLike<any>;
verify(algorithm: string | Algorithm, key: CryptoKey, signature: ArrayBufferView, data: ArrayBufferView): PromiseLike<any>;
wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | Algorithm): PromiseLike<any>;
decrypt(algorithm: string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams, key: CryptoKey, data: BufferSource): PromiseLike<ArrayBuffer>;
deriveBits(algorithm: string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, baseKey: CryptoKey, length: number): PromiseLike<ArrayBuffer>;
deriveKey(algorithm: string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: string | AesDerivedKeyParams | HmacImportParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
digest(algorithm: AlgorithmIdentifier, data: BufferSource): PromiseLike<ArrayBuffer>;
encrypt(algorithm: string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams, key: CryptoKey, data: BufferSource): PromiseLike<ArrayBuffer>;
exportKey(format: "jwk", key: CryptoKey): PromiseLike<JsonWebKey>;
exportKey(format: "raw" | "pkcs8" | "spki", key: CryptoKey): PromiseLike<ArrayBuffer>;
exportKey(format: string, key: CryptoKey): PromiseLike<JsonWebKey | ArrayBuffer>;
generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKeyPair | CryptoKey>;
generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams | DhKeyGenParams, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKeyPair>;
generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
importKey(format: "jwk", keyData: JsonWebKey, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable:boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
importKey(format: "raw" | "pkcs8" | "spki", keyData: BufferSource, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable:boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
importKey(format: string, keyData: JsonWebKey | BufferSource, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable:boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
sign(algorithm: string | RsaPssParams | EcdsaParams | AesCmacParams, key: CryptoKey, data: BufferSource): PromiseLike<ArrayBuffer>;
unwrapKey(format: string, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier, unwrappedKeyAlgorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: string[]): PromiseLike<CryptoKey>;
verify(algorithm: string | RsaPssParams | EcdsaParams | AesCmacParams, key: CryptoKey, signature: BufferSource, data: BufferSource): PromiseLike<boolean>;
wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AlgorithmIdentifier): PromiseLike<ArrayBuffer>;
}
declare var SubtleCrypto: {
@ -11557,7 +11564,7 @@ interface TextTrack extends EventTarget {
readonly language: string;
mode: any;
oncuechange: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onload: (ev: Event) => any;
readonly readyState: number;
addCue(cue: TextTrackCue): void;
@ -12046,18 +12053,12 @@ interface WebGLRenderingContext {
stencilMaskSeparate(face: number, mask: number): void;
stencilOp(fail: number, zfail: number, zpass: number): void;
stencilOpSeparate(face: number, fail: number, zfail: number, zpass: number): void;
texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView): void;
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, image: HTMLImageElement): void;
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, canvas: HTMLCanvasElement): void;
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, video: HTMLVideoElement): void;
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageData): void;
texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels?: ArrayBufferView): void;
texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels?: ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void;
texParameterf(target: number, pname: number, param: number): void;
texParameteri(target: number, pname: number, param: number): void;
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView): void;
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, image: HTMLImageElement): void;
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, canvas: HTMLCanvasElement): void;
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, video: HTMLVideoElement): void;
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageData): void;
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels?: ArrayBufferView): void;
texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels?: ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void;
uniform1f(location: WebGLUniformLocation | null, x: number): void;
uniform1fv(location: WebGLUniformLocation, v: Float32Array | number[]): void;
uniform1i(location: WebGLUniformLocation | null, x: number): void;
@ -12780,7 +12781,7 @@ interface WebSocket extends EventTarget {
readonly bufferedAmount: number;
readonly extensions: string;
onclose: (ev: CloseEvent) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onmessage: (ev: MessageEvent) => any;
onopen: (ev: Event) => any;
readonly protocol: string;
@ -12855,7 +12856,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
name: string;
readonly navigator: Navigator;
offscreenBuffering: string | boolean;
onabort: (ev: Event) => any;
onabort: (ev: UIEvent) => any;
onafterprint: (ev: Event) => any;
onbeforeprint: (ev: Event) => any;
onbeforeunload: (ev: BeforeUnloadEvent) => any;
@ -12971,6 +12972,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window
readonly top: Window;
readonly window: Window;
URL: typeof URL;
Blob: typeof Blob;
alert(message?: any): void;
blur(): void;
cancelAnimationFrame(handle: number): void;
@ -13127,7 +13129,6 @@ declare var XMLDocument: {
}
interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
msCaching: string;
onreadystatechange: (ev: ProgressEvent) => any;
readonly readyState: number;
readonly response: any;
@ -13139,6 +13140,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
timeout: number;
readonly upload: XMLHttpRequestUpload;
withCredentials: boolean;
msCaching?: string;
abort(): void;
getAllResponseHeaders(): string;
getResponseHeader(header: string): string | null;
@ -13277,7 +13279,7 @@ declare var XSLTProcessor: {
}
interface AbstractWorker {
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
@ -13436,7 +13438,7 @@ interface LinkStyle {
interface MSBaseReader {
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onload: (ev: Event) => any;
onloadend: (ev: ProgressEvent) => any;
onloadstart: (ev: Event) => any;
@ -13501,7 +13503,359 @@ interface NavigatorUserMedia {
}
interface NodeSelector {
querySelector(selectors: "a"): HTMLAnchorElement;
querySelector(selectors: "abbr"): HTMLElement;
querySelector(selectors: "acronym"): HTMLElement;
querySelector(selectors: "address"): HTMLElement;
querySelector(selectors: "applet"): HTMLAppletElement;
querySelector(selectors: "area"): HTMLAreaElement;
querySelector(selectors: "article"): HTMLElement;
querySelector(selectors: "aside"): HTMLElement;
querySelector(selectors: "audio"): HTMLAudioElement;
querySelector(selectors: "b"): HTMLElement;
querySelector(selectors: "base"): HTMLBaseElement;
querySelector(selectors: "basefont"): HTMLBaseFontElement;
querySelector(selectors: "bdo"): HTMLElement;
querySelector(selectors: "big"): HTMLElement;
querySelector(selectors: "blockquote"): HTMLQuoteElement;
querySelector(selectors: "body"): HTMLBodyElement;
querySelector(selectors: "br"): HTMLBRElement;
querySelector(selectors: "button"): HTMLButtonElement;
querySelector(selectors: "canvas"): HTMLCanvasElement;
querySelector(selectors: "caption"): HTMLTableCaptionElement;
querySelector(selectors: "center"): HTMLElement;
querySelector(selectors: "circle"): SVGCircleElement;
querySelector(selectors: "cite"): HTMLElement;
querySelector(selectors: "clippath"): SVGClipPathElement;
querySelector(selectors: "code"): HTMLElement;
querySelector(selectors: "col"): HTMLTableColElement;
querySelector(selectors: "colgroup"): HTMLTableColElement;
querySelector(selectors: "datalist"): HTMLDataListElement;
querySelector(selectors: "dd"): HTMLElement;
querySelector(selectors: "defs"): SVGDefsElement;
querySelector(selectors: "del"): HTMLModElement;
querySelector(selectors: "desc"): SVGDescElement;
querySelector(selectors: "dfn"): HTMLElement;
querySelector(selectors: "dir"): HTMLDirectoryElement;
querySelector(selectors: "div"): HTMLDivElement;
querySelector(selectors: "dl"): HTMLDListElement;
querySelector(selectors: "dt"): HTMLElement;
querySelector(selectors: "ellipse"): SVGEllipseElement;
querySelector(selectors: "em"): HTMLElement;
querySelector(selectors: "embed"): HTMLEmbedElement;
querySelector(selectors: "feblend"): SVGFEBlendElement;
querySelector(selectors: "fecolormatrix"): SVGFEColorMatrixElement;
querySelector(selectors: "fecomponenttransfer"): SVGFEComponentTransferElement;
querySelector(selectors: "fecomposite"): SVGFECompositeElement;
querySelector(selectors: "feconvolvematrix"): SVGFEConvolveMatrixElement;
querySelector(selectors: "fediffuselighting"): SVGFEDiffuseLightingElement;
querySelector(selectors: "fedisplacementmap"): SVGFEDisplacementMapElement;
querySelector(selectors: "fedistantlight"): SVGFEDistantLightElement;
querySelector(selectors: "feflood"): SVGFEFloodElement;
querySelector(selectors: "fefunca"): SVGFEFuncAElement;
querySelector(selectors: "fefuncb"): SVGFEFuncBElement;
querySelector(selectors: "fefuncg"): SVGFEFuncGElement;
querySelector(selectors: "fefuncr"): SVGFEFuncRElement;
querySelector(selectors: "fegaussianblur"): SVGFEGaussianBlurElement;
querySelector(selectors: "feimage"): SVGFEImageElement;
querySelector(selectors: "femerge"): SVGFEMergeElement;
querySelector(selectors: "femergenode"): SVGFEMergeNodeElement;
querySelector(selectors: "femorphology"): SVGFEMorphologyElement;
querySelector(selectors: "feoffset"): SVGFEOffsetElement;
querySelector(selectors: "fepointlight"): SVGFEPointLightElement;
querySelector(selectors: "fespecularlighting"): SVGFESpecularLightingElement;
querySelector(selectors: "fespotlight"): SVGFESpotLightElement;
querySelector(selectors: "fetile"): SVGFETileElement;
querySelector(selectors: "feturbulence"): SVGFETurbulenceElement;
querySelector(selectors: "fieldset"): HTMLFieldSetElement;
querySelector(selectors: "figcaption"): HTMLElement;
querySelector(selectors: "figure"): HTMLElement;
querySelector(selectors: "filter"): SVGFilterElement;
querySelector(selectors: "font"): HTMLFontElement;
querySelector(selectors: "footer"): HTMLElement;
querySelector(selectors: "foreignobject"): SVGForeignObjectElement;
querySelector(selectors: "form"): HTMLFormElement;
querySelector(selectors: "frame"): HTMLFrameElement;
querySelector(selectors: "frameset"): HTMLFrameSetElement;
querySelector(selectors: "g"): SVGGElement;
querySelector(selectors: "h1"): HTMLHeadingElement;
querySelector(selectors: "h2"): HTMLHeadingElement;
querySelector(selectors: "h3"): HTMLHeadingElement;
querySelector(selectors: "h4"): HTMLHeadingElement;
querySelector(selectors: "h5"): HTMLHeadingElement;
querySelector(selectors: "h6"): HTMLHeadingElement;
querySelector(selectors: "head"): HTMLHeadElement;
querySelector(selectors: "header"): HTMLElement;
querySelector(selectors: "hgroup"): HTMLElement;
querySelector(selectors: "hr"): HTMLHRElement;
querySelector(selectors: "html"): HTMLHtmlElement;
querySelector(selectors: "i"): HTMLElement;
querySelector(selectors: "iframe"): HTMLIFrameElement;
querySelector(selectors: "image"): SVGImageElement;
querySelector(selectors: "img"): HTMLImageElement;
querySelector(selectors: "input"): HTMLInputElement;
querySelector(selectors: "ins"): HTMLModElement;
querySelector(selectors: "isindex"): HTMLUnknownElement;
querySelector(selectors: "kbd"): HTMLElement;
querySelector(selectors: "keygen"): HTMLElement;
querySelector(selectors: "label"): HTMLLabelElement;
querySelector(selectors: "legend"): HTMLLegendElement;
querySelector(selectors: "li"): HTMLLIElement;
querySelector(selectors: "line"): SVGLineElement;
querySelector(selectors: "lineargradient"): SVGLinearGradientElement;
querySelector(selectors: "link"): HTMLLinkElement;
querySelector(selectors: "listing"): HTMLPreElement;
querySelector(selectors: "map"): HTMLMapElement;
querySelector(selectors: "mark"): HTMLElement;
querySelector(selectors: "marker"): SVGMarkerElement;
querySelector(selectors: "marquee"): HTMLMarqueeElement;
querySelector(selectors: "mask"): SVGMaskElement;
querySelector(selectors: "menu"): HTMLMenuElement;
querySelector(selectors: "meta"): HTMLMetaElement;
querySelector(selectors: "metadata"): SVGMetadataElement;
querySelector(selectors: "meter"): HTMLMeterElement;
querySelector(selectors: "nav"): HTMLElement;
querySelector(selectors: "nextid"): HTMLUnknownElement;
querySelector(selectors: "nobr"): HTMLElement;
querySelector(selectors: "noframes"): HTMLElement;
querySelector(selectors: "noscript"): HTMLElement;
querySelector(selectors: "object"): HTMLObjectElement;
querySelector(selectors: "ol"): HTMLOListElement;
querySelector(selectors: "optgroup"): HTMLOptGroupElement;
querySelector(selectors: "option"): HTMLOptionElement;
querySelector(selectors: "p"): HTMLParagraphElement;
querySelector(selectors: "param"): HTMLParamElement;
querySelector(selectors: "path"): SVGPathElement;
querySelector(selectors: "pattern"): SVGPatternElement;
querySelector(selectors: "picture"): HTMLPictureElement;
querySelector(selectors: "plaintext"): HTMLElement;
querySelector(selectors: "polygon"): SVGPolygonElement;
querySelector(selectors: "polyline"): SVGPolylineElement;
querySelector(selectors: "pre"): HTMLPreElement;
querySelector(selectors: "progress"): HTMLProgressElement;
querySelector(selectors: "q"): HTMLQuoteElement;
querySelector(selectors: "radialgradient"): SVGRadialGradientElement;
querySelector(selectors: "rect"): SVGRectElement;
querySelector(selectors: "rt"): HTMLElement;
querySelector(selectors: "ruby"): HTMLElement;
querySelector(selectors: "s"): HTMLElement;
querySelector(selectors: "samp"): HTMLElement;
querySelector(selectors: "script"): HTMLScriptElement;
querySelector(selectors: "section"): HTMLElement;
querySelector(selectors: "select"): HTMLSelectElement;
querySelector(selectors: "small"): HTMLElement;
querySelector(selectors: "source"): HTMLSourceElement;
querySelector(selectors: "span"): HTMLSpanElement;
querySelector(selectors: "stop"): SVGStopElement;
querySelector(selectors: "strike"): HTMLElement;
querySelector(selectors: "strong"): HTMLElement;
querySelector(selectors: "style"): HTMLStyleElement;
querySelector(selectors: "sub"): HTMLElement;
querySelector(selectors: "sup"): HTMLElement;
querySelector(selectors: "svg"): SVGSVGElement;
querySelector(selectors: "switch"): SVGSwitchElement;
querySelector(selectors: "symbol"): SVGSymbolElement;
querySelector(selectors: "table"): HTMLTableElement;
querySelector(selectors: "tbody"): HTMLTableSectionElement;
querySelector(selectors: "td"): HTMLTableDataCellElement;
querySelector(selectors: "template"): HTMLTemplateElement;
querySelector(selectors: "text"): SVGTextElement;
querySelector(selectors: "textpath"): SVGTextPathElement;
querySelector(selectors: "textarea"): HTMLTextAreaElement;
querySelector(selectors: "tfoot"): HTMLTableSectionElement;
querySelector(selectors: "th"): HTMLTableHeaderCellElement;
querySelector(selectors: "thead"): HTMLTableSectionElement;
querySelector(selectors: "title"): HTMLTitleElement;
querySelector(selectors: "tr"): HTMLTableRowElement;
querySelector(selectors: "track"): HTMLTrackElement;
querySelector(selectors: "tspan"): SVGTSpanElement;
querySelector(selectors: "tt"): HTMLElement;
querySelector(selectors: "u"): HTMLElement;
querySelector(selectors: "ul"): HTMLUListElement;
querySelector(selectors: "use"): SVGUseElement;
querySelector(selectors: "var"): HTMLElement;
querySelector(selectors: "video"): HTMLVideoElement;
querySelector(selectors: "view"): SVGViewElement;
querySelector(selectors: "wbr"): HTMLElement;
querySelector(selectors: "x-ms-webview"): MSHTMLWebViewElement;
querySelector(selectors: "xmp"): HTMLPreElement;
querySelector(selectors: string): Element;
querySelectorAll(selectors: "a"): NodeListOf<HTMLAnchorElement>;
querySelectorAll(selectors: "abbr"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "acronym"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "address"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "applet"): NodeListOf<HTMLAppletElement>;
querySelectorAll(selectors: "area"): NodeListOf<HTMLAreaElement>;
querySelectorAll(selectors: "article"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "aside"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "audio"): NodeListOf<HTMLAudioElement>;
querySelectorAll(selectors: "b"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "base"): NodeListOf<HTMLBaseElement>;
querySelectorAll(selectors: "basefont"): NodeListOf<HTMLBaseFontElement>;
querySelectorAll(selectors: "bdo"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "big"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "blockquote"): NodeListOf<HTMLQuoteElement>;
querySelectorAll(selectors: "body"): NodeListOf<HTMLBodyElement>;
querySelectorAll(selectors: "br"): NodeListOf<HTMLBRElement>;
querySelectorAll(selectors: "button"): NodeListOf<HTMLButtonElement>;
querySelectorAll(selectors: "canvas"): NodeListOf<HTMLCanvasElement>;
querySelectorAll(selectors: "caption"): NodeListOf<HTMLTableCaptionElement>;
querySelectorAll(selectors: "center"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "circle"): NodeListOf<SVGCircleElement>;
querySelectorAll(selectors: "cite"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "clippath"): NodeListOf<SVGClipPathElement>;
querySelectorAll(selectors: "code"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "col"): NodeListOf<HTMLTableColElement>;
querySelectorAll(selectors: "colgroup"): NodeListOf<HTMLTableColElement>;
querySelectorAll(selectors: "datalist"): NodeListOf<HTMLDataListElement>;
querySelectorAll(selectors: "dd"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "defs"): NodeListOf<SVGDefsElement>;
querySelectorAll(selectors: "del"): NodeListOf<HTMLModElement>;
querySelectorAll(selectors: "desc"): NodeListOf<SVGDescElement>;
querySelectorAll(selectors: "dfn"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "dir"): NodeListOf<HTMLDirectoryElement>;
querySelectorAll(selectors: "div"): NodeListOf<HTMLDivElement>;
querySelectorAll(selectors: "dl"): NodeListOf<HTMLDListElement>;
querySelectorAll(selectors: "dt"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "ellipse"): NodeListOf<SVGEllipseElement>;
querySelectorAll(selectors: "em"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "embed"): NodeListOf<HTMLEmbedElement>;
querySelectorAll(selectors: "feblend"): NodeListOf<SVGFEBlendElement>;
querySelectorAll(selectors: "fecolormatrix"): NodeListOf<SVGFEColorMatrixElement>;
querySelectorAll(selectors: "fecomponenttransfer"): NodeListOf<SVGFEComponentTransferElement>;
querySelectorAll(selectors: "fecomposite"): NodeListOf<SVGFECompositeElement>;
querySelectorAll(selectors: "feconvolvematrix"): NodeListOf<SVGFEConvolveMatrixElement>;
querySelectorAll(selectors: "fediffuselighting"): NodeListOf<SVGFEDiffuseLightingElement>;
querySelectorAll(selectors: "fedisplacementmap"): NodeListOf<SVGFEDisplacementMapElement>;
querySelectorAll(selectors: "fedistantlight"): NodeListOf<SVGFEDistantLightElement>;
querySelectorAll(selectors: "feflood"): NodeListOf<SVGFEFloodElement>;
querySelectorAll(selectors: "fefunca"): NodeListOf<SVGFEFuncAElement>;
querySelectorAll(selectors: "fefuncb"): NodeListOf<SVGFEFuncBElement>;
querySelectorAll(selectors: "fefuncg"): NodeListOf<SVGFEFuncGElement>;
querySelectorAll(selectors: "fefuncr"): NodeListOf<SVGFEFuncRElement>;
querySelectorAll(selectors: "fegaussianblur"): NodeListOf<SVGFEGaussianBlurElement>;
querySelectorAll(selectors: "feimage"): NodeListOf<SVGFEImageElement>;
querySelectorAll(selectors: "femerge"): NodeListOf<SVGFEMergeElement>;
querySelectorAll(selectors: "femergenode"): NodeListOf<SVGFEMergeNodeElement>;
querySelectorAll(selectors: "femorphology"): NodeListOf<SVGFEMorphologyElement>;
querySelectorAll(selectors: "feoffset"): NodeListOf<SVGFEOffsetElement>;
querySelectorAll(selectors: "fepointlight"): NodeListOf<SVGFEPointLightElement>;
querySelectorAll(selectors: "fespecularlighting"): NodeListOf<SVGFESpecularLightingElement>;
querySelectorAll(selectors: "fespotlight"): NodeListOf<SVGFESpotLightElement>;
querySelectorAll(selectors: "fetile"): NodeListOf<SVGFETileElement>;
querySelectorAll(selectors: "feturbulence"): NodeListOf<SVGFETurbulenceElement>;
querySelectorAll(selectors: "fieldset"): NodeListOf<HTMLFieldSetElement>;
querySelectorAll(selectors: "figcaption"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "figure"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "filter"): NodeListOf<SVGFilterElement>;
querySelectorAll(selectors: "font"): NodeListOf<HTMLFontElement>;
querySelectorAll(selectors: "footer"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "foreignobject"): NodeListOf<SVGForeignObjectElement>;
querySelectorAll(selectors: "form"): NodeListOf<HTMLFormElement>;
querySelectorAll(selectors: "frame"): NodeListOf<HTMLFrameElement>;
querySelectorAll(selectors: "frameset"): NodeListOf<HTMLFrameSetElement>;
querySelectorAll(selectors: "g"): NodeListOf<SVGGElement>;
querySelectorAll(selectors: "h1"): NodeListOf<HTMLHeadingElement>;
querySelectorAll(selectors: "h2"): NodeListOf<HTMLHeadingElement>;
querySelectorAll(selectors: "h3"): NodeListOf<HTMLHeadingElement>;
querySelectorAll(selectors: "h4"): NodeListOf<HTMLHeadingElement>;
querySelectorAll(selectors: "h5"): NodeListOf<HTMLHeadingElement>;
querySelectorAll(selectors: "h6"): NodeListOf<HTMLHeadingElement>;
querySelectorAll(selectors: "head"): NodeListOf<HTMLHeadElement>;
querySelectorAll(selectors: "header"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "hgroup"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "hr"): NodeListOf<HTMLHRElement>;
querySelectorAll(selectors: "html"): NodeListOf<HTMLHtmlElement>;
querySelectorAll(selectors: "i"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "iframe"): NodeListOf<HTMLIFrameElement>;
querySelectorAll(selectors: "image"): NodeListOf<SVGImageElement>;
querySelectorAll(selectors: "img"): NodeListOf<HTMLImageElement>;
querySelectorAll(selectors: "input"): NodeListOf<HTMLInputElement>;
querySelectorAll(selectors: "ins"): NodeListOf<HTMLModElement>;
querySelectorAll(selectors: "isindex"): NodeListOf<HTMLUnknownElement>;
querySelectorAll(selectors: "kbd"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "keygen"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "label"): NodeListOf<HTMLLabelElement>;
querySelectorAll(selectors: "legend"): NodeListOf<HTMLLegendElement>;
querySelectorAll(selectors: "li"): NodeListOf<HTMLLIElement>;
querySelectorAll(selectors: "line"): NodeListOf<SVGLineElement>;
querySelectorAll(selectors: "lineargradient"): NodeListOf<SVGLinearGradientElement>;
querySelectorAll(selectors: "link"): NodeListOf<HTMLLinkElement>;
querySelectorAll(selectors: "listing"): NodeListOf<HTMLPreElement>;
querySelectorAll(selectors: "map"): NodeListOf<HTMLMapElement>;
querySelectorAll(selectors: "mark"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "marker"): NodeListOf<SVGMarkerElement>;
querySelectorAll(selectors: "marquee"): NodeListOf<HTMLMarqueeElement>;
querySelectorAll(selectors: "mask"): NodeListOf<SVGMaskElement>;
querySelectorAll(selectors: "menu"): NodeListOf<HTMLMenuElement>;
querySelectorAll(selectors: "meta"): NodeListOf<HTMLMetaElement>;
querySelectorAll(selectors: "metadata"): NodeListOf<SVGMetadataElement>;
querySelectorAll(selectors: "meter"): NodeListOf<HTMLMeterElement>;
querySelectorAll(selectors: "nav"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "nextid"): NodeListOf<HTMLUnknownElement>;
querySelectorAll(selectors: "nobr"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "noframes"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "noscript"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "object"): NodeListOf<HTMLObjectElement>;
querySelectorAll(selectors: "ol"): NodeListOf<HTMLOListElement>;
querySelectorAll(selectors: "optgroup"): NodeListOf<HTMLOptGroupElement>;
querySelectorAll(selectors: "option"): NodeListOf<HTMLOptionElement>;
querySelectorAll(selectors: "p"): NodeListOf<HTMLParagraphElement>;
querySelectorAll(selectors: "param"): NodeListOf<HTMLParamElement>;
querySelectorAll(selectors: "path"): NodeListOf<SVGPathElement>;
querySelectorAll(selectors: "pattern"): NodeListOf<SVGPatternElement>;
querySelectorAll(selectors: "picture"): NodeListOf<HTMLPictureElement>;
querySelectorAll(selectors: "plaintext"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "polygon"): NodeListOf<SVGPolygonElement>;
querySelectorAll(selectors: "polyline"): NodeListOf<SVGPolylineElement>;
querySelectorAll(selectors: "pre"): NodeListOf<HTMLPreElement>;
querySelectorAll(selectors: "progress"): NodeListOf<HTMLProgressElement>;
querySelectorAll(selectors: "q"): NodeListOf<HTMLQuoteElement>;
querySelectorAll(selectors: "radialgradient"): NodeListOf<SVGRadialGradientElement>;
querySelectorAll(selectors: "rect"): NodeListOf<SVGRectElement>;
querySelectorAll(selectors: "rt"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "ruby"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "s"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "samp"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "script"): NodeListOf<HTMLScriptElement>;
querySelectorAll(selectors: "section"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "select"): NodeListOf<HTMLSelectElement>;
querySelectorAll(selectors: "small"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "source"): NodeListOf<HTMLSourceElement>;
querySelectorAll(selectors: "span"): NodeListOf<HTMLSpanElement>;
querySelectorAll(selectors: "stop"): NodeListOf<SVGStopElement>;
querySelectorAll(selectors: "strike"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "strong"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "style"): NodeListOf<HTMLStyleElement>;
querySelectorAll(selectors: "sub"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "sup"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "svg"): NodeListOf<SVGSVGElement>;
querySelectorAll(selectors: "switch"): NodeListOf<SVGSwitchElement>;
querySelectorAll(selectors: "symbol"): NodeListOf<SVGSymbolElement>;
querySelectorAll(selectors: "table"): NodeListOf<HTMLTableElement>;
querySelectorAll(selectors: "tbody"): NodeListOf<HTMLTableSectionElement>;
querySelectorAll(selectors: "td"): NodeListOf<HTMLTableDataCellElement>;
querySelectorAll(selectors: "template"): NodeListOf<HTMLTemplateElement>;
querySelectorAll(selectors: "text"): NodeListOf<SVGTextElement>;
querySelectorAll(selectors: "textpath"): NodeListOf<SVGTextPathElement>;
querySelectorAll(selectors: "textarea"): NodeListOf<HTMLTextAreaElement>;
querySelectorAll(selectors: "tfoot"): NodeListOf<HTMLTableSectionElement>;
querySelectorAll(selectors: "th"): NodeListOf<HTMLTableHeaderCellElement>;
querySelectorAll(selectors: "thead"): NodeListOf<HTMLTableSectionElement>;
querySelectorAll(selectors: "title"): NodeListOf<HTMLTitleElement>;
querySelectorAll(selectors: "tr"): NodeListOf<HTMLTableRowElement>;
querySelectorAll(selectors: "track"): NodeListOf<HTMLTrackElement>;
querySelectorAll(selectors: "tspan"): NodeListOf<SVGTSpanElement>;
querySelectorAll(selectors: "tt"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "u"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "ul"): NodeListOf<HTMLUListElement>;
querySelectorAll(selectors: "use"): NodeListOf<SVGUseElement>;
querySelectorAll(selectors: "var"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "video"): NodeListOf<HTMLVideoElement>;
querySelectorAll(selectors: "view"): NodeListOf<SVGViewElement>;
querySelectorAll(selectors: "wbr"): NodeListOf<HTMLElement>;
querySelectorAll(selectors: "x-ms-webview"): NodeListOf<MSHTMLWebViewElement>;
querySelectorAll(selectors: "xmp"): NodeListOf<HTMLPreElement>;
querySelectorAll(selectors: string): NodeListOf<Element>;
}
@ -13589,18 +13943,21 @@ interface WindowSessionStorage {
interface WindowTimers extends Object, WindowTimersExtension {
clearInterval(handle: number): void;
clearTimeout(handle: number): void;
setInterval(handler: (...args: any[]) => void, timeout: number): number;
setInterval(handler: any, timeout?: any, ...args: any[]): number;
setTimeout(handler: (...args: any[]) => void, timeout: number): number;
setTimeout(handler: any, timeout?: any, ...args: any[]): number;
}
interface WindowTimersExtension {
clearImmediate(handle: number): void;
setImmediate(expression: any, ...args: any[]): number;
setImmediate(handler: (...args: any[]) => void): number;
setImmediate(handler: any, ...args: any[]): number;
}
interface XMLHttpRequestEventTarget {
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onload: (ev: Event) => any;
onloadend: (ev: ProgressEvent) => any;
onloadstart: (ev: Event) => any;
@ -13624,6 +13981,13 @@ interface StorageEventInit extends EventInit {
storageArea?: Storage;
}
interface Canvas2DContextAttributes {
alpha?: boolean;
willReadFrequently?: boolean;
storage?: boolean;
[attribute: string]: boolean | string;
}
interface NodeListOf<TNode extends Node> extends NodeList {
length: number;
item(index: number): TNode;
@ -13673,6 +14037,177 @@ interface ClipboardEventInit extends EventInit {
interface IDBArrayKey extends Array<IDBValidKey> {
}
interface RsaKeyGenParams extends Algorithm {
modulusLength: number;
publicExponent: Uint8Array;
}
interface RsaHashedKeyGenParams extends RsaKeyGenParams {
hash: AlgorithmIdentifier;
}
interface RsaKeyAlgorithm extends KeyAlgorithm {
modulusLength: number;
publicExponent: Uint8Array;
}
interface RsaHashedKeyAlgorithm extends RsaKeyAlgorithm {
hash: AlgorithmIdentifier;
}
interface RsaHashedImportParams {
hash: AlgorithmIdentifier;
}
interface RsaPssParams {
saltLength: number;
}
interface RsaOaepParams extends Algorithm {
label?: BufferSource;
}
interface EcdsaParams extends Algorithm {
hash: AlgorithmIdentifier;
}
interface EcKeyGenParams extends Algorithm {
typedCurve: string;
}
interface EcKeyAlgorithm extends KeyAlgorithm {
typedCurve: string;
}
interface EcKeyImportParams {
namedCurve: string;
}
interface EcdhKeyDeriveParams extends Algorithm {
public: CryptoKey;
}
interface AesCtrParams extends Algorithm {
counter: BufferSource;
length: number;
}
interface AesKeyAlgorithm extends KeyAlgorithm {
length: number;
}
interface AesKeyGenParams extends Algorithm {
length: number;
}
interface AesDerivedKeyParams extends Algorithm {
length: number;
}
interface AesCbcParams extends Algorithm {
iv: BufferSource;
}
interface AesCmacParams extends Algorithm {
length: number;
}
interface AesGcmParams extends Algorithm {
iv: BufferSource;
additionalData?: BufferSource;
tagLength?: number;
}
interface AesCfbParams extends Algorithm {
iv: BufferSource;
}
interface HmacImportParams extends Algorithm {
hash?: AlgorithmIdentifier;
length?: number;
}
interface HmacKeyAlgorithm extends KeyAlgorithm {
hash: AlgorithmIdentifier;
length: number;
}
interface HmacKeyGenParams extends Algorithm {
hash: AlgorithmIdentifier;
length?: number;
}
interface DhKeyGenParams extends Algorithm {
prime: Uint8Array;
generator: Uint8Array;
}
interface DhKeyAlgorithm extends KeyAlgorithm {
prime: Uint8Array;
generator: Uint8Array;
}
interface DhKeyDeriveParams extends Algorithm {
public: CryptoKey;
}
interface DhImportKeyParams extends Algorithm {
prime: Uint8Array;
generator: Uint8Array;
}
interface ConcatParams extends Algorithm {
hash?: AlgorithmIdentifier;
algorithmId: Uint8Array;
partyUInfo: Uint8Array;
partyVInfo: Uint8Array;
publicInfo?: Uint8Array;
privateInfo?: Uint8Array;
}
interface HkdfCtrParams extends Algorithm {
hash: AlgorithmIdentifier;
label: BufferSource;
context: BufferSource;
}
interface Pbkdf2Params extends Algorithm {
salt: BufferSource;
iterations: number;
hash: AlgorithmIdentifier;
}
interface RsaOtherPrimesInfo {
r: string;
d: string;
t: string;
}
interface JsonWebKey {
kty: string;
use?: string;
key_ops?: string[];
alg?: string;
kid?: string;
x5u?: string;
x5c?: string;
x5t?: string;
ext?: boolean;
crv?: string;
x?: string;
y?: string;
d?: string;
n?: string;
e?: string;
p?: string;
q?: string;
dp?: string;
dq?: string;
qi?: string;
oth?: RsaOtherPrimesInfo[];
k?: string;
}
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface ErrorEventHandler {
@ -13746,7 +14281,7 @@ declare var msCredentials: MSCredentials;
declare var name: string;
declare var navigator: Navigator;
declare var offscreenBuffering: string | boolean;
declare var onabort: (ev: Event) => any;
declare var onabort: (ev: UIEvent) => any;
declare var onafterprint: (ev: Event) => any;
declare var onbeforeprint: (ev: Event) => any;
declare var onbeforeunload: (ev: BeforeUnloadEvent) => any;
@ -13896,10 +14431,13 @@ declare function dispatchEvent(evt: Event): boolean;
declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void;
declare function clearInterval(handle: number): void;
declare function clearTimeout(handle: number): void;
declare function setInterval(handler: (...args: any[]) => void, timeout: number): number;
declare function setInterval(handler: any, timeout?: any, ...args: any[]): number;
declare function setTimeout(handler: (...args: any[]) => void, timeout: number): number;
declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number;
declare function clearImmediate(handle: number): void;
declare function setImmediate(expression: any, ...args: any[]): number;
declare function setImmediate(handler: (...args: any[]) => void): number;
declare function setImmediate(handler: any, ...args: any[]): number;
declare var sessionStorage: Storage;
declare var localStorage: Storage;
declare var console: Console;
@ -14042,4 +14580,6 @@ type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload;
type RTCIceGatherCandidate = RTCIceCandidate | RTCIceCandidateComplete;
type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport;
type payloadtype = number;
type IDBValidKey = number | string | Date | IDBArrayKey;
type IDBValidKey = number | string | Date | IDBArrayKey;
type BufferSource = ArrayBuffer | ArrayBufferView;
type MouseWheelEvent = WheelEvent;

View file

@ -323,7 +323,7 @@ interface IDBDatabase extends EventTarget {
readonly name: string;
readonly objectStoreNames: DOMStringList;
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
version: number;
onversionchange: (ev: IDBVersionChangeEvent) => any;
close(): void;
@ -426,7 +426,7 @@ declare var IDBOpenDBRequest: {
interface IDBRequest extends EventTarget {
readonly error: DOMError;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onsuccess: (ev: Event) => any;
readonly readyState: string;
readonly result: any;
@ -448,7 +448,7 @@ interface IDBTransaction extends EventTarget {
readonly mode: string;
onabort: (ev: Event) => any;
oncomplete: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
abort(): void;
objectStore(name: string): IDBObjectStore;
readonly READ_ONLY: string;
@ -516,7 +516,7 @@ declare var MSApp: MSApp;
interface MSAppAsyncOperation extends EventTarget {
readonly error: DOMError;
oncomplete: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
readonly readyState: number;
readonly result: any;
start(): void;
@ -665,7 +665,7 @@ interface WebSocket extends EventTarget {
readonly bufferedAmount: number;
readonly extensions: string;
onclose: (ev: CloseEvent) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onmessage: (ev: MessageEvent) => any;
onopen: (ev: Event) => any;
readonly protocol: string;
@ -708,7 +708,6 @@ declare var Worker: {
}
interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
msCaching: string;
onreadystatechange: (ev: ProgressEvent) => any;
readonly readyState: number;
readonly response: any;
@ -720,6 +719,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget {
timeout: number;
readonly upload: XMLHttpRequestUpload;
withCredentials: boolean;
msCaching?: string;
abort(): void;
getAllResponseHeaders(): string;
getResponseHeader(header: string): string | null;
@ -766,14 +766,14 @@ declare var XMLHttpRequestUpload: {
}
interface AbstractWorker {
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
addEventListener(type: "error", listener: (ev: ErrorEvent) => any, useCapture?: boolean): void;
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
}
interface MSBaseReader {
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onload: (ev: Event) => any;
onloadend: (ev: ProgressEvent) => any;
onloadstart: (ev: Event) => any;
@ -819,7 +819,7 @@ interface WindowConsole {
interface XMLHttpRequestEventTarget {
onabort: (ev: Event) => any;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
onload: (ev: Event) => any;
onloadend: (ev: ProgressEvent) => any;
onloadstart: (ev: Event) => any;
@ -849,7 +849,7 @@ declare var FileReaderSync: {
interface WorkerGlobalScope extends EventTarget, WorkerUtils, DedicatedWorkerGlobalScope, WindowConsole {
readonly location: WorkerLocation;
onerror: (ev: Event) => any;
onerror: (ev: ErrorEvent) => any;
readonly self: WorkerGlobalScope;
close(): void;
msWriteProfilerMark(profilerMarkName: string): void;
@ -905,8 +905,11 @@ interface WorkerUtils extends Object, WindowBase64 {
clearInterval(handle: number): void;
clearTimeout(handle: number): void;
importScripts(...urls: string[]): void;
setImmediate(handler: (...args: any[]) => void): number;
setImmediate(handler: any, ...args: any[]): number;
setInterval(handler: (...args: any[]) => void, timeout: number): number;
setInterval(handler: any, timeout?: any, ...args: any[]): number;
setTimeout(handler: (...args: any[]) => void, timeout: number): number;
setTimeout(handler: any, timeout?: any, ...args: any[]): number;
}
@ -942,6 +945,177 @@ interface ProgressEventInit extends EventInit {
interface IDBArrayKey extends Array<IDBValidKey> {
}
interface RsaKeyGenParams extends Algorithm {
modulusLength: number;
publicExponent: Uint8Array;
}
interface RsaHashedKeyGenParams extends RsaKeyGenParams {
hash: AlgorithmIdentifier;
}
interface RsaKeyAlgorithm extends KeyAlgorithm {
modulusLength: number;
publicExponent: Uint8Array;
}
interface RsaHashedKeyAlgorithm extends RsaKeyAlgorithm {
hash: AlgorithmIdentifier;
}
interface RsaHashedImportParams {
hash: AlgorithmIdentifier;
}
interface RsaPssParams {
saltLength: number;
}
interface RsaOaepParams extends Algorithm {
label?: BufferSource;
}
interface EcdsaParams extends Algorithm {
hash: AlgorithmIdentifier;
}
interface EcKeyGenParams extends Algorithm {
typedCurve: string;
}
interface EcKeyAlgorithm extends KeyAlgorithm {
typedCurve: string;
}
interface EcKeyImportParams {
namedCurve: string;
}
interface EcdhKeyDeriveParams extends Algorithm {
public: CryptoKey;
}
interface AesCtrParams extends Algorithm {
counter: BufferSource;
length: number;
}
interface AesKeyAlgorithm extends KeyAlgorithm {
length: number;
}
interface AesKeyGenParams extends Algorithm {
length: number;
}
interface AesDerivedKeyParams extends Algorithm {
length: number;
}
interface AesCbcParams extends Algorithm {
iv: BufferSource;
}
interface AesCmacParams extends Algorithm {
length: number;
}
interface AesGcmParams extends Algorithm {
iv: BufferSource;
additionalData?: BufferSource;
tagLength?: number;
}
interface AesCfbParams extends Algorithm {
iv: BufferSource;
}
interface HmacImportParams extends Algorithm {
hash?: AlgorithmIdentifier;
length?: number;
}
interface HmacKeyAlgorithm extends KeyAlgorithm {
hash: AlgorithmIdentifier;
length: number;
}
interface HmacKeyGenParams extends Algorithm {
hash: AlgorithmIdentifier;
length?: number;
}
interface DhKeyGenParams extends Algorithm {
prime: Uint8Array;
generator: Uint8Array;
}
interface DhKeyAlgorithm extends KeyAlgorithm {
prime: Uint8Array;
generator: Uint8Array;
}
interface DhKeyDeriveParams extends Algorithm {
public: CryptoKey;
}
interface DhImportKeyParams extends Algorithm {
prime: Uint8Array;
generator: Uint8Array;
}
interface ConcatParams extends Algorithm {
hash?: AlgorithmIdentifier;
algorithmId: Uint8Array;
partyUInfo: Uint8Array;
partyVInfo: Uint8Array;
publicInfo?: Uint8Array;
privateInfo?: Uint8Array;
}
interface HkdfCtrParams extends Algorithm {
hash: AlgorithmIdentifier;
label: BufferSource;
context: BufferSource;
}
interface Pbkdf2Params extends Algorithm {
salt: BufferSource;
iterations: number;
hash: AlgorithmIdentifier;
}
interface RsaOtherPrimesInfo {
r: string;
d: string;
t: string;
}
interface JsonWebKey {
kty: string;
use?: string;
key_ops?: string[];
alg?: string;
kid?: string;
x5u?: string;
x5c?: string;
x5t?: string;
ext?: boolean;
crv?: string;
x?: string;
y?: string;
d?: string;
n?: string;
e?: string;
p?: string;
q?: string;
dp?: string;
dq?: string;
qi?: string;
oth?: RsaOtherPrimesInfo[];
k?: string;
}
declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject;
interface ErrorEventHandler {
@ -975,7 +1149,7 @@ interface FunctionStringCallback {
(data: string): void;
}
declare var location: WorkerLocation;
declare var onerror: (ev: Event) => any;
declare var onerror: (ev: ErrorEvent) => any;
declare var self: WorkerGlobalScope;
declare function close(): void;
declare function msWriteProfilerMark(profilerMarkName: string): void;
@ -990,8 +1164,11 @@ declare function clearImmediate(handle: number): void;
declare function clearInterval(handle: number): void;
declare function clearTimeout(handle: number): void;
declare function importScripts(...urls: string[]): void;
declare function setImmediate(handler: (...args: any[]) => void): number;
declare function setImmediate(handler: any, ...args: any[]): number;
declare function setInterval(handler: (...args: any[]) => void, timeout: number): number;
declare function setInterval(handler: any, timeout?: any, ...args: any[]): number;
declare function setTimeout(handler: (...args: any[]) => void, timeout: number): number;
declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number;
declare function atob(encodedString: string): string;
declare function btoa(rawString: string): string;
@ -1002,4 +1179,6 @@ declare function addEventListener(type: "error", listener: (ev: ErrorEvent) => a
declare function addEventListener(type: "message", listener: (ev: MessageEvent) => any, useCapture?: boolean): void;
declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
type IDBKeyPath = string;
type IDBValidKey = number | string | Date | IDBArrayKey;
type IDBValidKey = number | string | Date | IDBArrayKey;
type BufferSource = ArrayBuffer | ArrayBufferView;
type MouseWheelEvent = WheelEvent;

View file

@ -376,6 +376,7 @@ namespace ts.server {
fileName: fileName,
textSpan: ts.createTextSpanFromBounds(start, end),
isWriteAccess: entry.isWriteAccess,
isDefinition: entry.isDefinition,
};
});
}
@ -536,6 +537,7 @@ namespace ts.server {
fileName,
textSpan: ts.createTextSpanFromBounds(start, end),
isWriteAccess: entry.isWriteAccess,
isDefinition: false
};
});
}

View file

@ -27,6 +27,8 @@ namespace ts.server {
});
}
export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024;
export class ScriptInfo {
svc: ScriptVersionCache;
children: ScriptInfo[] = []; // files referenced by this file
@ -387,12 +389,29 @@ namespace ts.server {
/** Used for configured projects which may have multiple open roots */
openRefCount = 0;
constructor(public projectService: ProjectService, public projectOptions?: ProjectOptions) {
constructor(
public projectService: ProjectService,
public projectOptions?: ProjectOptions,
public languageServiceDiabled = false) {
if (projectOptions && projectOptions.files) {
// If files are listed explicitly, allow all extensions
projectOptions.compilerOptions.allowNonTsExtensions = true;
}
this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions);
if (!languageServiceDiabled) {
this.compilerService = new CompilerService(this, projectOptions && projectOptions.compilerOptions);
}
}
enableLanguageService() {
// if the language service was disabled, we should re-initiate the compiler service
if (this.languageServiceDiabled) {
this.compilerService = new CompilerService(this, this.projectOptions && this.projectOptions.compilerOptions);
}
this.languageServiceDiabled = false;
}
disableLanguageService() {
this.languageServiceDiabled = true;
}
addOpenRef() {
@ -409,19 +428,45 @@ namespace ts.server {
}
getRootFiles() {
if (this.languageServiceDiabled) {
// When the languageService was disabled, only return file list if it is a configured project
return this.projectOptions ? this.projectOptions.files : undefined;
}
return this.compilerService.host.roots.map(info => info.fileName);
}
getFileNames() {
if (this.languageServiceDiabled) {
if (!this.projectOptions) {
return undefined;
}
const fileNames: string[] = [];
if (this.projectOptions && this.projectOptions.compilerOptions) {
fileNames.push(getDefaultLibFilePath(this.projectOptions.compilerOptions));
}
ts.addRange(fileNames, this.projectOptions.files);
return fileNames;
}
const sourceFiles = this.program.getSourceFiles();
return sourceFiles.map(sourceFile => sourceFile.fileName);
}
getSourceFile(info: ScriptInfo) {
if (this.languageServiceDiabled) {
return undefined;
}
return this.filenameToSourceFile[info.fileName];
}
getSourceFileFromName(filename: string, requireOpen?: boolean) {
if (this.languageServiceDiabled) {
return undefined;
}
const info = this.projectService.getScriptInfo(filename);
if (info) {
if ((!requireOpen) || info.isOpen) {
@ -431,15 +476,27 @@ namespace ts.server {
}
isRoot(info: ScriptInfo) {
if (this.languageServiceDiabled) {
return undefined;
}
return this.compilerService.host.roots.some(root => root === info);
}
removeReferencedFile(info: ScriptInfo) {
if (this.languageServiceDiabled) {
return;
}
this.compilerService.host.removeReferencedFile(info);
this.updateGraph();
}
updateFileMap() {
if (this.languageServiceDiabled) {
return;
}
this.filenameToSourceFile = {};
const sourceFiles = this.program.getSourceFiles();
for (let i = 0, len = sourceFiles.length; i < len; i++) {
@ -449,11 +506,19 @@ namespace ts.server {
}
finishGraph() {
if (this.languageServiceDiabled) {
return;
}
this.updateGraph();
this.compilerService.languageService.getNavigateToItems(".*");
}
updateGraph() {
if (this.languageServiceDiabled) {
return;
}
this.program = this.compilerService.languageService.getProgram();
this.updateFileMap();
}
@ -464,15 +529,32 @@ namespace ts.server {
// add a root file to project
addRoot(info: ScriptInfo) {
if (this.languageServiceDiabled) {
return;
}
this.compilerService.host.addRoot(info);
}
// remove a root file from project
removeRoot(info: ScriptInfo) {
if (this.languageServiceDiabled) {
return;
}
this.compilerService.host.removeRoot(info);
}
filesToString() {
if (this.languageServiceDiabled) {
if (this.projectOptions) {
let strBuilder = "";
ts.forEach(this.projectOptions.files,
file => { strBuilder += file + "\n"; });
return strBuilder;
}
}
let strBuilder = "";
ts.forEachValue(this.filenameToSourceFile,
sourceFile => { strBuilder += sourceFile.fileName + "\n"; });
@ -483,7 +565,9 @@ namespace ts.server {
this.projectOptions = projectOptions;
if (projectOptions.compilerOptions) {
projectOptions.compilerOptions.allowNonTsExtensions = true;
this.compilerService.setCompilerOptions(projectOptions.compilerOptions);
if (!this.languageServiceDiabled) {
this.compilerService.setCompilerOptions(projectOptions.compilerOptions);
}
}
}
}
@ -811,6 +895,7 @@ namespace ts.server {
else {
this.findReferencingProjects(info);
if (info.defaultProject) {
info.defaultProject.addOpenRef();
this.openFilesReferenced.push(info);
}
else {
@ -1265,7 +1350,24 @@ namespace ts.server {
return { succeeded: true, projectOptions };
}
}
}
private exceedTotalNonTsFileSizeLimit(fileNames: string[]) {
let totalNonTsFileSize = 0;
if (!this.host.getFileSize) {
return false;
}
for (const fileName of fileNames) {
if (hasTypeScriptFileExtension(fileName)) {
continue;
}
totalNonTsFileSize += this.host.getFileSize(fileName);
if (totalNonTsFileSize > maxProgramSizeForNonTsFiles) {
return true;
}
}
return false;
}
openConfigFile(configFilename: string, clientFileName?: string): { success: boolean, project?: Project, errors?: Diagnostic[] } {
@ -1274,6 +1376,19 @@ namespace ts.server {
return { success: false, errors };
}
else {
if (!projectOptions.compilerOptions.disableSizeLimit && projectOptions.compilerOptions.allowJs) {
if (this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) {
const project = this.createProject(configFilename, projectOptions, /*languageServiceDisabled*/ true);
// for configured projects with languageService disabled, we only watch its config file,
// do not care about the directory changes in the folder.
project.projectFileWatcher = this.host.watchFile(
toPath(configFilename, configFilename, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)),
_ => this.watchedProjectConfigFileChanged(project));
return { success: true, project };
}
}
const project = this.createProject(configFilename, projectOptions);
let errors: Diagnostic[];
for (const rootFilename of projectOptions.files) {
@ -1315,7 +1430,7 @@ namespace ts.server {
}
}
updateConfiguredProject(project: Project) {
updateConfiguredProject(project: Project): Diagnostic[] {
if (!this.host.fileExists(project.projectFilename)) {
this.log("Config file deleted");
this.removeProject(project);
@ -1326,7 +1441,43 @@ namespace ts.server {
return errors;
}
else {
const oldFileNames = project.compilerService.host.roots.map(info => info.fileName);
if (projectOptions.compilerOptions && !projectOptions.compilerOptions.disableSizeLimit && this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) {
project.setProjectOptions(projectOptions);
if (project.languageServiceDiabled) {
return;
}
project.disableLanguageService();
if (project.directoryWatcher) {
project.directoryWatcher.close();
project.directoryWatcher = undefined;
}
return;
}
if (project.languageServiceDiabled) {
project.setProjectOptions(projectOptions);
project.enableLanguageService();
project.directoryWatcher = this.host.watchDirectory(
ts.getDirectoryPath(project.projectFilename),
path => this.directoryWatchedForSourceFilesChanged(project, path),
/*recursive*/ true
);
for (const rootFilename of projectOptions.files) {
if (this.host.fileExists(rootFilename)) {
const info = this.openFile(rootFilename, /*openedByClient*/ false);
project.addRoot(info);
}
}
project.finishGraph();
return;
}
// if the project is too large, the root files might not have been all loaded if the total
// program size reached the upper limit. In that case project.projectOptions.files should
// be more precise. However this would only happen for configured project.
const oldFileNames = project.projectOptions ? project.projectOptions.files : project.compilerService.host.roots.map(info => info.fileName);
const newFileNames = ts.filter(projectOptions.files, f => this.host.fileExists(f));
const fileNamesToRemove = oldFileNames.filter(f => newFileNames.indexOf(f) < 0);
const fileNamesToAdd = newFileNames.filter(f => oldFileNames.indexOf(f) < 0);
@ -1369,8 +1520,8 @@ namespace ts.server {
}
}
createProject(projectFilename: string, projectOptions?: ProjectOptions) {
const project = new Project(this, projectOptions);
createProject(projectFilename: string, projectOptions?: ProjectOptions, languageServiceDisabled?: boolean) {
const project = new Project(this, projectOptions, languageServiceDisabled);
project.projectFilename = projectFilename;
return project;
}

View file

@ -123,6 +123,10 @@ declare namespace ts.server.protocol {
* The list of normalized file name in the project, including 'lib.d.ts'
*/
fileNames?: string[];
/**
* Indicates if the project has a active language service instance
*/
languageServiceDisabled?: boolean;
}
/**
@ -304,6 +308,11 @@ declare namespace ts.server.protocol {
* True if reference is a write location, false otherwise.
*/
isWriteAccess: boolean;
/**
* True if reference is a definition, false otherwise.
*/
isDefinition: boolean;
}
/**

View file

@ -313,7 +313,7 @@ namespace ts.server {
private getDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@ -335,7 +335,7 @@ namespace ts.server {
private getTypeDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@ -358,7 +358,7 @@ namespace ts.server {
fileName = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(fileName);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@ -379,7 +379,7 @@ namespace ts.server {
start,
end,
file: fileName,
isWriteAccess
isWriteAccess,
};
});
}
@ -388,7 +388,7 @@ namespace ts.server {
fileName = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(fileName);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@ -423,15 +423,18 @@ namespace ts.server {
private getProjectInfo(fileName: string, needFileNameList: boolean): protocol.ProjectInfo {
fileName = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(fileName);
if (!project) {
throw Errors.NoProject;
}
const projectInfo: protocol.ProjectInfo = {
configFileName: project.projectFilename
configFileName: project.projectFilename,
languageServiceDisabled: project.languageServiceDiabled
};
if (needFileNameList) {
projectInfo.fileNames = project.getFileNames();
}
return projectInfo;
}
@ -439,11 +442,12 @@ namespace ts.server {
const file = ts.normalizePath(fileName);
const info = this.projectService.getScriptInfo(file);
const projects = this.projectService.findReferencingProjects(info);
if (!projects.length) {
const projectsWithLanguageServiceEnabeld = ts.filter(projects, p => !p.languageServiceDiabled);
if (projectsWithLanguageServiceEnabeld.length === 0) {
throw Errors.NoProject;
}
const defaultProject = projects[0];
const defaultProject = projectsWithLanguageServiceEnabeld[0];
// The rename info should be the same for every project
const defaultProjectCompilerService = defaultProject.compilerService;
const position = defaultProjectCompilerService.host.lineOffsetToPosition(file, line, offset);
@ -460,7 +464,7 @@ namespace ts.server {
}
const fileSpans = combineProjectOutput(
projects,
projectsWithLanguageServiceEnabeld,
(project: Project) => {
const compilerService = project.compilerService;
const renameLocations = compilerService.languageService.findRenameLocations(file, position, findInStrings, findInComments);
@ -521,11 +525,12 @@ namespace ts.server {
const file = ts.normalizePath(fileName);
const info = this.projectService.getScriptInfo(file);
const projects = this.projectService.findReferencingProjects(info);
if (!projects.length) {
const projectsWithLanguageServiceEnabeld = ts.filter(projects, p => !p.languageServiceDiabled);
if (projectsWithLanguageServiceEnabeld.length === 0) {
throw Errors.NoProject;
}
const defaultProject = projects[0];
const defaultProject = projectsWithLanguageServiceEnabeld[0];
const position = defaultProject.compilerService.host.lineOffsetToPosition(file, line, offset);
const nameInfo = defaultProject.compilerService.languageService.getQuickInfoAtPosition(file, position);
if (!nameInfo) {
@ -537,7 +542,7 @@ namespace ts.server {
const nameColStart = defaultProject.compilerService.host.positionToLineOffset(file, nameSpan.start).offset;
const nameText = defaultProject.compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan));
const refs = combineProjectOutput<protocol.ReferencesResponseItem>(
projects,
projectsWithLanguageServiceEnabeld,
(project: Project) => {
const compilerService = project.compilerService;
const references = compilerService.languageService.getReferencesAtPosition(file, position);
@ -555,7 +560,8 @@ namespace ts.server {
start: start,
lineText: lineText,
end: compilerService.host.positionToLineOffset(ref.fileName, ts.textSpanEnd(ref.textSpan)),
isWriteAccess: ref.isWriteAccess
isWriteAccess: ref.isWriteAccess,
isDefinition: ref.isDefinition
};
});
},
@ -595,7 +601,7 @@ namespace ts.server {
private getQuickInfo(line: number, offset: number, fileName: string): protocol.QuickInfoResponseBody {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@ -621,7 +627,7 @@ namespace ts.server {
private getFormattingEditsForRange(line: number, offset: number, endLine: number, endOffset: number, fileName: string): protocol.CodeEdit[] {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@ -649,7 +655,7 @@ namespace ts.server {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@ -727,7 +733,7 @@ namespace ts.server {
}
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@ -751,7 +757,7 @@ namespace ts.server {
entryNames: string[], fileName: string): protocol.CompletionEntryDetails[] {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@ -770,7 +776,7 @@ namespace ts.server {
private getSignatureHelpItems(line: number, offset: number, fileName: string): protocol.SignatureHelpItems {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@ -800,7 +806,7 @@ namespace ts.server {
const checkList = fileNames.reduce((accum: PendingErrorCheck[], fileName: string) => {
fileName = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(fileName);
if (project) {
if (project && !project.languageServiceDiabled) {
accum.push({ fileName, project });
}
return accum;
@ -814,7 +820,7 @@ namespace ts.server {
private change(line: number, offset: number, endLine: number, endOffset: number, insertString: string, fileName: string) {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (project) {
if (project && !project.languageServiceDiabled) {
const compilerService = project.compilerService;
const start = compilerService.host.lineOffsetToPosition(file, line, offset);
const end = compilerService.host.lineOffsetToPosition(file, endLine, endOffset);
@ -830,7 +836,7 @@ namespace ts.server {
const file = ts.normalizePath(fileName);
const tmpfile = ts.normalizePath(tempFileName);
const project = this.projectService.getProjectForFile(file);
if (project) {
if (project && !project.languageServiceDiabled) {
this.changeSeq++;
// make sure no changes happen before this one is finished
project.compilerService.host.reloadScript(file, tmpfile, () => {
@ -844,7 +850,7 @@ namespace ts.server {
const tmpfile = ts.normalizePath(tempFileName);
const project = this.projectService.getProjectForFile(file);
if (project) {
if (project && !project.languageServiceDiabled) {
project.compilerService.host.saveTo(file, tmpfile);
}
}
@ -880,7 +886,7 @@ namespace ts.server {
private getNavigationBarItems(fileName: string): protocol.NavigationBarItem[] {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@ -897,13 +903,13 @@ namespace ts.server {
const file = ts.normalizePath(fileName);
const info = this.projectService.getScriptInfo(file);
const projects = this.projectService.findReferencingProjects(info);
const defaultProject = projects[0];
if (!defaultProject) {
const projectsWithLanguageServiceEnabeld = ts.filter(projects, p => !p.languageServiceDiabled);
if (projectsWithLanguageServiceEnabeld.length === 0) {
throw Errors.NoProject;
}
const allNavToItems = combineProjectOutput(
projects,
projectsWithLanguageServiceEnabeld,
(project: Project) => {
const compilerService = project.compilerService;
const navItems = compilerService.languageService.getNavigateToItems(searchValue, maxResultCount);
@ -955,7 +961,7 @@ namespace ts.server {
const file = ts.normalizePath(fileName);
const project = this.projectService.getProjectForFile(file);
if (!project) {
if (!project || project.languageServiceDiabled) {
throw Errors.NoProject;
}
@ -974,7 +980,11 @@ namespace ts.server {
}
getDiagnosticsForProject(delay: number, fileName: string) {
const { fileNames } = this.getProjectInfo(fileName, /*needFileNameList*/ true);
const { fileNames, languageServiceDisabled } = this.getProjectInfo(fileName, /*needFileNameList*/ true);
if (languageServiceDisabled) {
return;
}
// No need to analyze lib.d.ts
let fileNamesInProject = fileNames.filter((value, index, array) => value.indexOf("lib.d.ts") < 0);

View file

@ -1,4 +1,5 @@
/// <reference path="..\compiler\program.ts"/>
/// <reference path="..\compiler\commandLineParser.ts"/>
/// <reference path='breakpoints.ts' />
/// <reference path='outliningElementsCollector.ts' />
@ -1209,6 +1210,7 @@ namespace ts {
textSpan: TextSpan;
fileName: string;
isWriteAccess: boolean;
isDefinition: boolean;
}
export interface DocumentHighlights {
@ -2000,6 +2002,10 @@ namespace ts {
// so pass --noLib to avoid reporting a file not found error.
options.noLib = true;
// Clear out the lib and types option as well
options.lib = undefined;
options.types = undefined;
// We are not doing a full typecheck, we are not resolving the whole context,
// so pass --noResolve to avoid reporting missing file errors.
options.noResolve = true;
@ -2977,7 +2983,8 @@ namespace ts {
oldSettings.moduleResolution !== newSettings.moduleResolution ||
oldSettings.noResolve !== newSettings.noResolve ||
oldSettings.jsx !== newSettings.jsx ||
oldSettings.allowJs !== newSettings.allowJs);
oldSettings.allowJs !== newSettings.allowJs ||
oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit);
// Now create a new compiler
const compilerHost: CompilerHost = {
@ -4141,7 +4148,7 @@ namespace ts {
if (!uniqueNames[name]) {
uniqueNames[name] = name;
const displayName = getCompletionEntryDisplayName(name, target, /*performCharacterChecks*/ true);
const displayName = getCompletionEntryDisplayName(unescapeIdentifier(name), target, /*performCharacterChecks*/ true);
if (displayName) {
const entry = {
name: displayName,
@ -5753,7 +5760,8 @@ namespace ts {
result.push({
fileName: entry.fileName,
textSpan: highlightSpan.textSpan,
isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference
isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference,
isDefinition: false
});
}
}
@ -6187,7 +6195,8 @@ namespace ts {
references: [{
fileName: sourceFile.fileName,
textSpan: createTextSpan(position, searchText.length),
isWriteAccess: false
isWriteAccess: false,
isDefinition: false
}]
});
}
@ -6741,7 +6750,8 @@ namespace ts {
return {
fileName: node.getSourceFile().fileName,
textSpan: createTextSpanFromBounds(start, end),
isWriteAccess: isWriteAccess(node)
isWriteAccess: isWriteAccess(node),
isDefinition: isDeclarationName(node) || isLiteralComputedPropertyDeclarationName(node)
};
}

View file

@ -165,7 +165,7 @@ namespace ts {
/**
* Returns a JSON-encoded value of the type:
* { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[]
* { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean, isDefinition?: boolean }[]
*/
getReferencesAtPosition(fileName: string, position: number): string;
@ -1165,4 +1165,4 @@ namespace TypeScript.Services {
/* @internal */
const toolsVersion = "1.9";
/* tslint:enable:no-unused-variable */
/* tslint:enable:no-unused-variable */

View file

@ -1,4 +1,4 @@
tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(7,18): error TS2304: Cannot find name 'Base'.
tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(7,18): error TS2689: Cannot extend an interface 'Base'. Did you mean 'implements'?
tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(45,18): error TS2508: No base constructor has the specified number of type arguments.
tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts(56,18): error TS2510: Base constructors must all have the same return type.
@ -12,7 +12,7 @@ tests/cases/conformance/classes/classDeclarations/classExtendingClassLikeType.ts
// Error, no Base constructor function
class D0 extends Base<string, string> {
~~~~
!!! error TS2304: Cannot find name 'Base'.
!!! error TS2689: Cannot extend an interface 'Base'. Did you mean 'implements'?
}
interface BaseConstructor {

View file

@ -1,4 +1,4 @@
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(4,17): error TS2304: Cannot find name 'I'.
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(4,17): error TS2689: Cannot extend an interface 'I'. Did you mean 'implements'?
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,18): error TS2507: Type '{ foo: any; }' is not a constructor function type.
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,25): error TS2304: Cannot find name 'string'.
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,31): error TS1005: ',' expected.
@ -14,7 +14,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla
}
class C extends I { } // error
~
!!! error TS2304: Cannot find name 'I'.
!!! error TS2689: Cannot extend an interface 'I'. Did you mean 'implements'?
class C2 extends { foo: string; } { } // error
~~~~~~~~~~~~~~~~

View file

@ -1,17 +1,17 @@
tests/cases/compiler/classExtendsInterface.ts(2,17): error TS2304: Cannot find name 'Comparable'.
tests/cases/compiler/classExtendsInterface.ts(6,21): error TS2304: Cannot find name 'Comparable2'.
tests/cases/compiler/classExtendsInterface.ts(2,17): error TS2689: Cannot extend an interface 'Comparable'. Did you mean 'implements'?
tests/cases/compiler/classExtendsInterface.ts(6,21): error TS2689: Cannot extend an interface 'Comparable2'. Did you mean 'implements'?
==== tests/cases/compiler/classExtendsInterface.ts (2 errors) ====
interface Comparable {}
class A extends Comparable {}
~~~~~~~~~~
!!! error TS2304: Cannot find name 'Comparable'.
!!! error TS2689: Cannot extend an interface 'Comparable'. Did you mean 'implements'?
class B implements Comparable {}
interface Comparable2<T> {}
class A2<T> extends Comparable2<T> {}
~~~~~~~~~~~
!!! error TS2304: Cannot find name 'Comparable2'.
!!! error TS2689: Cannot extend an interface 'Comparable2'. Did you mean 'implements'?
class B2<T> implements Comparable2<T> {}

View file

@ -2,7 +2,7 @@
interface Comparable {}
class A extends Comparable {}
class B implements Comparable {}
interface Comparable2<T> {}
class A2<T> extends Comparable2<T> {}
class B2<T> implements Comparable2<T> {}

View file

@ -0,0 +1,14 @@
tests/cases/compiler/classExtendsInterfaceInExpression.ts(7,25): error TS2304: Cannot find name 'A'.
==== tests/cases/compiler/classExtendsInterfaceInExpression.ts (1 errors) ====
interface A {}
function factory(a: any): {new(): Object} {
return null;
}
class C extends factory(A) {}
~
!!! error TS2304: Cannot find name 'A'.

View file

@ -0,0 +1,26 @@
//// [classExtendsInterfaceInExpression.ts]
interface A {}
function factory(a: any): {new(): Object} {
return null;
}
class C extends factory(A) {}
//// [classExtendsInterfaceInExpression.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
function factory(a) {
return null;
}
var C = (function (_super) {
__extends(C, _super);
function C() {
_super.apply(this, arguments);
}
return C;
}(factory(A)));

View file

@ -0,0 +1,27 @@
tests/cases/compiler/classExtendsInterfaceInModule.ts(5,18): error TS2689: Cannot extend an interface 'M.I1'. Did you mean 'implements'?
tests/cases/compiler/classExtendsInterfaceInModule.ts(6,21): error TS2689: Cannot extend an interface 'M.I2'. Did you mean 'implements'?
tests/cases/compiler/classExtendsInterfaceInModule.ts(14,17): error TS2689: Cannot extend an interface 'Mod.Nested.I'. Did you mean 'implements'?
==== tests/cases/compiler/classExtendsInterfaceInModule.ts (3 errors) ====
module M {
export interface I1 {}
export interface I2<T> {}
}
class C1 extends M.I1 {}
~
!!! error TS2689: Cannot extend an interface 'M.I1'. Did you mean 'implements'?
class C2<T> extends M.I2<T> {}
~
!!! error TS2689: Cannot extend an interface 'M.I2'. Did you mean 'implements'?
module Mod {
export namespace Nested {
export interface I {}
}
}
class D extends Mod.Nested.I {}
~~~
!!! error TS2689: Cannot extend an interface 'Mod.Nested.I'. Did you mean 'implements'?

View file

@ -0,0 +1,44 @@
//// [classExtendsInterfaceInModule.ts]
module M {
export interface I1 {}
export interface I2<T> {}
}
class C1 extends M.I1 {}
class C2<T> extends M.I2<T> {}
module Mod {
export namespace Nested {
export interface I {}
}
}
class D extends Mod.Nested.I {}
//// [classExtendsInterfaceInModule.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var C1 = (function (_super) {
__extends(C1, _super);
function C1() {
_super.apply(this, arguments);
}
return C1;
}(M.I1));
var C2 = (function (_super) {
__extends(C2, _super);
function C2() {
_super.apply(this, arguments);
}
return C2;
}(M.I2));
var D = (function (_super) {
__extends(D, _super);
function D() {
_super.apply(this, arguments);
}
return D;
}(Mod.Nested.I));

View file

@ -0,0 +1,11 @@
tests/cases/compiler/file1.ts(2,1): error TS2448: Block-scoped variable 'c' used before its declaration.
==== tests/cases/compiler/file1.ts (1 errors) ====
c;
~
!!! error TS2448: Block-scoped variable 'c' used before its declaration.
==== tests/cases/compiler/file2.ts (0 errors) ====
const c = 0;

View file

@ -0,0 +1,59 @@
//// [decoratorMetadataPromise.ts]
declare const decorator: MethodDecorator;
class A {
@decorator
async foo() {}
@decorator
async bar(): Promise<number> { return 0; }
@decorator
baz(n: Promise<number>): Promise<number> { return n; }
}
//// [decoratorMetadataPromise.js]
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments)).next());
});
};
class A {
foo() {
return __awaiter(this, void 0, void 0, function* () { });
}
bar() {
return __awaiter(this, void 0, void 0, function* () { return 0; });
}
baz(n) { return n; }
}
__decorate([
decorator,
__metadata('design:type', Function),
__metadata('design:paramtypes', []),
__metadata('design:returntype', Promise)
], A.prototype, "foo", null);
__decorate([
decorator,
__metadata('design:type', Function),
__metadata('design:paramtypes', []),
__metadata('design:returntype', Promise)
], A.prototype, "bar", null);
__decorate([
decorator,
__metadata('design:type', Function),
__metadata('design:paramtypes', [Promise]),
__metadata('design:returntype', Promise)
], A.prototype, "baz", null);

View file

@ -0,0 +1,33 @@
=== tests/cases/compiler/decoratorMetadataPromise.ts ===
declare const decorator: MethodDecorator;
>decorator : Symbol(decorator, Decl(decoratorMetadataPromise.ts, 1, 13))
>MethodDecorator : Symbol(MethodDecorator, Decl(lib.es5.d.ts, --, --))
class A {
>A : Symbol(A, Decl(decoratorMetadataPromise.ts, 1, 41))
@decorator
>decorator : Symbol(decorator, Decl(decoratorMetadataPromise.ts, 1, 13))
async foo() {}
>foo : Symbol(A.foo, Decl(decoratorMetadataPromise.ts, 3, 9))
@decorator
>decorator : Symbol(decorator, Decl(decoratorMetadataPromise.ts, 1, 13))
async bar(): Promise<number> { return 0; }
>bar : Symbol(A.bar, Decl(decoratorMetadataPromise.ts, 5, 18))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
@decorator
>decorator : Symbol(decorator, Decl(decoratorMetadataPromise.ts, 1, 13))
baz(n: Promise<number>): Promise<number> { return n; }
>baz : Symbol(A.baz, Decl(decoratorMetadataPromise.ts, 7, 46))
>n : Symbol(n, Decl(decoratorMetadataPromise.ts, 9, 8))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>n : Symbol(n, Decl(decoratorMetadataPromise.ts, 9, 8))
}

View file

@ -0,0 +1,34 @@
=== tests/cases/compiler/decoratorMetadataPromise.ts ===
declare const decorator: MethodDecorator;
>decorator : <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void
>MethodDecorator : <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void
class A {
>A : A
@decorator
>decorator : <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void
async foo() {}
>foo : () => Promise<void>
@decorator
>decorator : <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void
async bar(): Promise<number> { return 0; }
>bar : () => Promise<number>
>Promise : Promise<T>
>0 : number
@decorator
>decorator : <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void
baz(n: Promise<number>): Promise<number> { return n; }
>baz : (n: Promise<number>) => Promise<number>
>n : Promise<number>
>Promise : Promise<T>
>Promise : Promise<T>
>n : Promise<number>
}

View file

@ -1,8 +1,11 @@
tests/cases/compiler/defaultValueInFunctionTypes.ts(1,9): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
tests/cases/compiler/defaultValueInFunctionTypes.ts(2,11): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
==== tests/cases/compiler/defaultValueInFunctionTypes.ts (1 errors) ====
==== tests/cases/compiler/defaultValueInFunctionTypes.ts (2 errors) ====
var x: (a: number = 1) => number;
~~~~~~~~~~~~~
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
var y = <(a : string = "") => any>(undefined)
var y = <(a : string = "") => any>(undefined)
~~~~~~~~~~~~~~~
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.

View file

@ -0,0 +1,252 @@
//// [discriminatedUnionTypes1.ts]
interface Square {
kind: "square";
size: number;
}
interface Rectangle {
kind: "rectangle";
width: number;
height: number;
}
interface Circle {
kind: "circle";
radius: number;
}
type Shape = Square | Rectangle | Circle;
function area1(s: Shape) {
if (s.kind === "square") {
return s.size * s.size;
}
else if (s.kind === "circle") {
return Math.PI * s.radius * s.radius;
}
else if (s.kind === "rectangle") {
return s.width * s.height;
}
else {
return 0;
}
}
function area2(s: Shape) {
switch (s.kind) {
case "square": return s.size * s.size;
case "rectangle": return s.width * s.height;
case "circle": return Math.PI * s.radius * s.radius;
}
}
function assertNever(x: never): never {
throw new Error("Unexpected object: " + x);
}
function area3(s: Shape) {
switch (s.kind) {
case "square": return s.size * s.size;
case "rectangle": return s.width * s.height;
case "circle": return Math.PI * s.radius * s.radius;
default: return assertNever(s);
}
}
function area4(s: Shape) {
switch (s.kind) {
case "square": return s.size * s.size;
case "rectangle": return s.width * s.height;
case "circle": return Math.PI * s.radius * s.radius;
}
return assertNever(s);
}
type Message =
{ kind: "A", x: string } |
{ kind: "B" | "C", y: number } |
{ kind: "D" };
function f1(m: Message) {
if (m.kind === "A") {
m; // { kind: "A", x: string }
}
else if (m.kind === "D") {
m; // { kind: "D" }
}
else {
m; // { kind: "B" | "C", y: number }
}
}
function f2(m: Message) {
if (m.kind === "A") {
return;
}
m; // { kind: "B" | "C", y: number } | { kind: "D" }
}
function f3(m: Message) {
if (m.kind === "X") {
m; // never
}
}
function f4(m: Message, x: "A" | "D") {
if (m.kind == x) {
m; // { kind: "A", x: string } | { kind: "D" }
}
}
function f5(m: Message) {
switch (m.kind) {
case "A":
m; // { kind: "A", x: string }
break;
case "D":
m; // { kind: "D" }
break;
default:
m; // { kind: "B" | "C", y: number }
}
}
function f6(m: Message) {
switch (m.kind) {
case "A":
m; // { kind: "A", x: string }
case "D":
m; // { kind: "A", x: string } | { kind: "D" }
break;
default:
m; // { kind: "B" | "C", y: number }
}
}
function f7(m: Message) {
switch (m.kind) {
case "A":
case "B":
return;
}
m; // { kind: "B" | "C", y: number } | { kind: "D" }
}
function f8(m: Message) {
switch (m.kind) {
case "A":
return;
case "D":
throw new Error();
}
m; // { kind: "B" | "C", y: number }
}
//// [discriminatedUnionTypes1.js]
function area1(s) {
if (s.kind === "square") {
return s.size * s.size;
}
else if (s.kind === "circle") {
return Math.PI * s.radius * s.radius;
}
else if (s.kind === "rectangle") {
return s.width * s.height;
}
else {
return 0;
}
}
function area2(s) {
switch (s.kind) {
case "square": return s.size * s.size;
case "rectangle": return s.width * s.height;
case "circle": return Math.PI * s.radius * s.radius;
}
}
function assertNever(x) {
throw new Error("Unexpected object: " + x);
}
function area3(s) {
switch (s.kind) {
case "square": return s.size * s.size;
case "rectangle": return s.width * s.height;
case "circle": return Math.PI * s.radius * s.radius;
default: return assertNever(s);
}
}
function area4(s) {
switch (s.kind) {
case "square": return s.size * s.size;
case "rectangle": return s.width * s.height;
case "circle": return Math.PI * s.radius * s.radius;
}
return assertNever(s);
}
function f1(m) {
if (m.kind === "A") {
m; // { kind: "A", x: string }
}
else if (m.kind === "D") {
m; // { kind: "D" }
}
else {
m; // { kind: "B" | "C", y: number }
}
}
function f2(m) {
if (m.kind === "A") {
return;
}
m; // { kind: "B" | "C", y: number } | { kind: "D" }
}
function f3(m) {
if (m.kind === "X") {
m; // never
}
}
function f4(m, x) {
if (m.kind == x) {
m; // { kind: "A", x: string } | { kind: "D" }
}
}
function f5(m) {
switch (m.kind) {
case "A":
m; // { kind: "A", x: string }
break;
case "D":
m; // { kind: "D" }
break;
default:
m; // { kind: "B" | "C", y: number }
}
}
function f6(m) {
switch (m.kind) {
case "A":
m; // { kind: "A", x: string }
case "D":
m; // { kind: "A", x: string } | { kind: "D" }
break;
default:
m; // { kind: "B" | "C", y: number }
}
}
function f7(m) {
switch (m.kind) {
case "A":
case "B":
return;
}
m; // { kind: "B" | "C", y: number } | { kind: "D" }
}
function f8(m) {
switch (m.kind) {
case "A":
return;
case "D":
throw new Error();
}
m; // { kind: "B" | "C", y: number }
}

View file

@ -0,0 +1,402 @@
=== tests/cases/conformance/types/union/discriminatedUnionTypes1.ts ===
interface Square {
>Square : Symbol(Square, Decl(discriminatedUnionTypes1.ts, 0, 0))
kind: "square";
>kind : Symbol(Square.kind, Decl(discriminatedUnionTypes1.ts, 0, 18))
size: number;
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
}
interface Rectangle {
>Rectangle : Symbol(Rectangle, Decl(discriminatedUnionTypes1.ts, 3, 1))
kind: "rectangle";
>kind : Symbol(Rectangle.kind, Decl(discriminatedUnionTypes1.ts, 5, 21))
width: number;
>width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
height: number;
>height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
}
interface Circle {
>Circle : Symbol(Circle, Decl(discriminatedUnionTypes1.ts, 9, 1))
kind: "circle";
>kind : Symbol(Circle.kind, Decl(discriminatedUnionTypes1.ts, 11, 18))
radius: number;
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
}
type Shape = Square | Rectangle | Circle;
>Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1))
>Square : Symbol(Square, Decl(discriminatedUnionTypes1.ts, 0, 0))
>Rectangle : Symbol(Rectangle, Decl(discriminatedUnionTypes1.ts, 3, 1))
>Circle : Symbol(Circle, Decl(discriminatedUnionTypes1.ts, 9, 1))
function area1(s: Shape) {
>area1 : Symbol(area1, Decl(discriminatedUnionTypes1.ts, 16, 41))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
>Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1))
if (s.kind === "square") {
>s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
return s.size * s.size;
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
}
else if (s.kind === "circle") {
>s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
return Math.PI * s.radius * s.radius;
>Math.PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
}
else if (s.kind === "rectangle") {
>s.kind : Symbol(Rectangle.kind, Decl(discriminatedUnionTypes1.ts, 5, 21))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
>kind : Symbol(Rectangle.kind, Decl(discriminatedUnionTypes1.ts, 5, 21))
return s.width * s.height;
>s.width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
>width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
>s.height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15))
>height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
}
else {
return 0;
}
}
function area2(s: Shape) {
>area2 : Symbol(area2, Decl(discriminatedUnionTypes1.ts, 31, 1))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
>Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1))
switch (s.kind) {
>s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
case "square": return s.size * s.size;
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
case "rectangle": return s.width * s.height;
>s.width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
>width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
>s.height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
>height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
case "circle": return Math.PI * s.radius * s.radius;
>Math.PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15))
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
}
}
function assertNever(x: never): never {
>assertNever : Symbol(assertNever, Decl(discriminatedUnionTypes1.ts, 39, 1))
>x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 41, 21))
throw new Error("Unexpected object: " + x);
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 41, 21))
}
function area3(s: Shape) {
>area3 : Symbol(area3, Decl(discriminatedUnionTypes1.ts, 43, 1))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
>Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1))
switch (s.kind) {
>s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
case "square": return s.size * s.size;
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
case "rectangle": return s.width * s.height;
>s.width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
>width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
>s.height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
>height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
case "circle": return Math.PI * s.radius * s.radius;
>Math.PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
default: return assertNever(s);
>assertNever : Symbol(assertNever, Decl(discriminatedUnionTypes1.ts, 39, 1))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15))
}
}
function area4(s: Shape) {
>area4 : Symbol(area4, Decl(discriminatedUnionTypes1.ts, 52, 1))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
>Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1))
switch (s.kind) {
>s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18))
case "square": return s.size * s.size;
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
>s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
>size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19))
case "rectangle": return s.width * s.height;
>s.width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
>width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22))
>s.height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
>height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18))
case "circle": return Math.PI * s.radius * s.radius;
>Math.PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
>s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
>radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19))
}
return assertNever(s);
>assertNever : Symbol(assertNever, Decl(discriminatedUnionTypes1.ts, 39, 1))
>s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15))
}
type Message =
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
{ kind: "A", x: string } |
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5))
>x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 64, 16))
{ kind: "B" | "C", y: number } |
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 65, 5))
>y : Symbol(y, Decl(discriminatedUnionTypes1.ts, 65, 22))
{ kind: "D" };
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 66, 5))
function f1(m: Message) {
>f1 : Symbol(f1, Decl(discriminatedUnionTypes1.ts, 66, 18))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12))
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
if (m.kind === "A") {
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12))
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
m; // { kind: "A", x: string }
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12))
}
else if (m.kind === "D") {
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12))
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
m; // { kind: "D" }
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12))
}
else {
m; // { kind: "B" | "C", y: number }
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12))
}
}
function f2(m: Message) {
>f2 : Symbol(f2, Decl(discriminatedUnionTypes1.ts, 78, 1))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 80, 12))
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
if (m.kind === "A") {
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 80, 12))
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
return;
}
m; // { kind: "B" | "C", y: number } | { kind: "D" }
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 80, 12))
}
function f3(m: Message) {
>f3 : Symbol(f3, Decl(discriminatedUnionTypes1.ts, 85, 1))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 87, 12))
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
if (m.kind === "X") {
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 87, 12))
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
m; // never
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 87, 12))
}
}
function f4(m: Message, x: "A" | "D") {
>f4 : Symbol(f4, Decl(discriminatedUnionTypes1.ts, 91, 1))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 93, 12))
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
>x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 93, 23))
if (m.kind == x) {
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 93, 12))
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
>x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 93, 23))
m; // { kind: "A", x: string } | { kind: "D" }
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 93, 12))
}
}
function f5(m: Message) {
>f5 : Symbol(f5, Decl(discriminatedUnionTypes1.ts, 97, 1))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12))
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
switch (m.kind) {
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12))
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
case "A":
m; // { kind: "A", x: string }
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12))
break;
case "D":
m; // { kind: "D" }
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12))
break;
default:
m; // { kind: "B" | "C", y: number }
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12))
}
}
function f6(m: Message) {
>f6 : Symbol(f6, Decl(discriminatedUnionTypes1.ts, 110, 1))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12))
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
switch (m.kind) {
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12))
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
case "A":
m; // { kind: "A", x: string }
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12))
case "D":
m; // { kind: "A", x: string } | { kind: "D" }
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12))
break;
default:
m; // { kind: "B" | "C", y: number }
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12))
}
}
function f7(m: Message) {
>f7 : Symbol(f7, Decl(discriminatedUnionTypes1.ts, 122, 1))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 124, 12))
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
switch (m.kind) {
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 124, 12))
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
case "A":
case "B":
return;
}
m; // { kind: "B" | "C", y: number } | { kind: "D" }
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 124, 12))
}
function f8(m: Message) {
>f8 : Symbol(f8, Decl(discriminatedUnionTypes1.ts, 131, 1))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 133, 12))
>Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1))
switch (m.kind) {
>m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 133, 12))
>kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5))
case "A":
return;
case "D":
throw new Error();
>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
}
m; // { kind: "B" | "C", y: number }
>m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 133, 12))
}

View file

@ -0,0 +1,465 @@
=== tests/cases/conformance/types/union/discriminatedUnionTypes1.ts ===
interface Square {
>Square : Square
kind: "square";
>kind : "square"
size: number;
>size : number
}
interface Rectangle {
>Rectangle : Rectangle
kind: "rectangle";
>kind : "rectangle"
width: number;
>width : number
height: number;
>height : number
}
interface Circle {
>Circle : Circle
kind: "circle";
>kind : "circle"
radius: number;
>radius : number
}
type Shape = Square | Rectangle | Circle;
>Shape : Square | Rectangle | Circle
>Square : Square
>Rectangle : Rectangle
>Circle : Circle
function area1(s: Shape) {
>area1 : (s: Square | Rectangle | Circle) => number
>s : Square | Rectangle | Circle
>Shape : Square | Rectangle | Circle
if (s.kind === "square") {
>s.kind === "square" : boolean
>s.kind : "square" | "rectangle" | "circle"
>s : Square | Rectangle | Circle
>kind : "square" | "rectangle" | "circle"
>"square" : string
return s.size * s.size;
>s.size * s.size : number
>s.size : number
>s : Square
>size : number
>s.size : number
>s : Square
>size : number
}
else if (s.kind === "circle") {
>s.kind === "circle" : boolean
>s.kind : "rectangle" | "circle"
>s : Rectangle | Circle
>kind : "rectangle" | "circle"
>"circle" : string
return Math.PI * s.radius * s.radius;
>Math.PI * s.radius * s.radius : number
>Math.PI * s.radius : number
>Math.PI : number
>Math : Math
>PI : number
>s.radius : number
>s : Circle
>radius : number
>s.radius : number
>s : Circle
>radius : number
}
else if (s.kind === "rectangle") {
>s.kind === "rectangle" : boolean
>s.kind : "rectangle"
>s : Rectangle
>kind : "rectangle"
>"rectangle" : string
return s.width * s.height;
>s.width * s.height : number
>s.width : number
>s : Rectangle
>width : number
>s.height : number
>s : Rectangle
>height : number
}
else {
return 0;
>0 : number
}
}
function area2(s: Shape) {
>area2 : (s: Square | Rectangle | Circle) => number
>s : Square | Rectangle | Circle
>Shape : Square | Rectangle | Circle
switch (s.kind) {
>s.kind : "square" | "rectangle" | "circle"
>s : Square | Rectangle | Circle
>kind : "square" | "rectangle" | "circle"
case "square": return s.size * s.size;
>"square" : string
>s.size * s.size : number
>s.size : number
>s : Square
>size : number
>s.size : number
>s : Square
>size : number
case "rectangle": return s.width * s.height;
>"rectangle" : string
>s.width * s.height : number
>s.width : number
>s : Rectangle
>width : number
>s.height : number
>s : Rectangle
>height : number
case "circle": return Math.PI * s.radius * s.radius;
>"circle" : string
>Math.PI * s.radius * s.radius : number
>Math.PI * s.radius : number
>Math.PI : number
>Math : Math
>PI : number
>s.radius : number
>s : Circle
>radius : number
>s.radius : number
>s : Circle
>radius : number
}
}
function assertNever(x: never): never {
>assertNever : (x: never) => never
>x : never
throw new Error("Unexpected object: " + x);
>new Error("Unexpected object: " + x) : Error
>Error : ErrorConstructor
>"Unexpected object: " + x : string
>"Unexpected object: " : string
>x : never
}
function area3(s: Shape) {
>area3 : (s: Square | Rectangle | Circle) => number
>s : Square | Rectangle | Circle
>Shape : Square | Rectangle | Circle
switch (s.kind) {
>s.kind : "square" | "rectangle" | "circle"
>s : Square | Rectangle | Circle
>kind : "square" | "rectangle" | "circle"
case "square": return s.size * s.size;
>"square" : string
>s.size * s.size : number
>s.size : number
>s : Square
>size : number
>s.size : number
>s : Square
>size : number
case "rectangle": return s.width * s.height;
>"rectangle" : string
>s.width * s.height : number
>s.width : number
>s : Rectangle
>width : number
>s.height : number
>s : Rectangle
>height : number
case "circle": return Math.PI * s.radius * s.radius;
>"circle" : string
>Math.PI * s.radius * s.radius : number
>Math.PI * s.radius : number
>Math.PI : number
>Math : Math
>PI : number
>s.radius : number
>s : Circle
>radius : number
>s.radius : number
>s : Circle
>radius : number
default: return assertNever(s);
>assertNever(s) : never
>assertNever : (x: never) => never
>s : never
}
}
function area4(s: Shape) {
>area4 : (s: Square | Rectangle | Circle) => number
>s : Square | Rectangle | Circle
>Shape : Square | Rectangle | Circle
switch (s.kind) {
>s.kind : "square" | "rectangle" | "circle"
>s : Square | Rectangle | Circle
>kind : "square" | "rectangle" | "circle"
case "square": return s.size * s.size;
>"square" : string
>s.size * s.size : number
>s.size : number
>s : Square
>size : number
>s.size : number
>s : Square
>size : number
case "rectangle": return s.width * s.height;
>"rectangle" : string
>s.width * s.height : number
>s.width : number
>s : Rectangle
>width : number
>s.height : number
>s : Rectangle
>height : number
case "circle": return Math.PI * s.radius * s.radius;
>"circle" : string
>Math.PI * s.radius * s.radius : number
>Math.PI * s.radius : number
>Math.PI : number
>Math : Math
>PI : number
>s.radius : number
>s : Circle
>radius : number
>s.radius : number
>s : Circle
>radius : number
}
return assertNever(s);
>assertNever(s) : never
>assertNever : (x: never) => never
>s : never
}
type Message =
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
{ kind: "A", x: string } |
>kind : "A"
>x : string
{ kind: "B" | "C", y: number } |
>kind : "B" | "C"
>y : number
{ kind: "D" };
>kind : "D"
function f1(m: Message) {
>f1 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
if (m.kind === "A") {
>m.kind === "A" : boolean
>m.kind : "A" | "B" | "C" | "D"
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>kind : "A" | "B" | "C" | "D"
>"A" : string
m; // { kind: "A", x: string }
>m : { kind: "A"; x: string; }
}
else if (m.kind === "D") {
>m.kind === "D" : boolean
>m.kind : "B" | "C" | "D"
>m : { kind: "B" | "C"; y: number; } | { kind: "D"; }
>kind : "B" | "C" | "D"
>"D" : string
m; // { kind: "D" }
>m : { kind: "D"; }
}
else {
m; // { kind: "B" | "C", y: number }
>m : { kind: "B" | "C"; y: number; }
}
}
function f2(m: Message) {
>f2 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
if (m.kind === "A") {
>m.kind === "A" : boolean
>m.kind : "A" | "B" | "C" | "D"
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>kind : "A" | "B" | "C" | "D"
>"A" : string
return;
}
m; // { kind: "B" | "C", y: number } | { kind: "D" }
>m : { kind: "B" | "C"; y: number; } | { kind: "D"; }
}
function f3(m: Message) {
>f3 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
if (m.kind === "X") {
>m.kind === "X" : boolean
>m.kind : "A" | "B" | "C" | "D"
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>kind : "A" | "B" | "C" | "D"
>"X" : string
m; // never
>m : never
}
}
function f4(m: Message, x: "A" | "D") {
>f4 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }, x: "A" | "D") => void
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>x : "A" | "D"
if (m.kind == x) {
>m.kind == x : boolean
>m.kind : "A" | "B" | "C" | "D"
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>kind : "A" | "B" | "C" | "D"
>x : "A" | "D"
m; // { kind: "A", x: string } | { kind: "D" }
>m : { kind: "A"; x: string; } | { kind: "D"; }
}
}
function f5(m: Message) {
>f5 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
switch (m.kind) {
>m.kind : "A" | "B" | "C" | "D"
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>kind : "A" | "B" | "C" | "D"
case "A":
>"A" : string
m; // { kind: "A", x: string }
>m : { kind: "A"; x: string; }
break;
case "D":
>"D" : string
m; // { kind: "D" }
>m : { kind: "D"; }
break;
default:
m; // { kind: "B" | "C", y: number }
>m : { kind: "B" | "C"; y: number; }
}
}
function f6(m: Message) {
>f6 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
switch (m.kind) {
>m.kind : "A" | "B" | "C" | "D"
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>kind : "A" | "B" | "C" | "D"
case "A":
>"A" : string
m; // { kind: "A", x: string }
>m : { kind: "A"; x: string; }
case "D":
>"D" : string
m; // { kind: "A", x: string } | { kind: "D" }
>m : { kind: "D"; } | { kind: "A"; x: string; }
break;
default:
m; // { kind: "B" | "C", y: number }
>m : { kind: "B" | "C"; y: number; }
}
}
function f7(m: Message) {
>f7 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
switch (m.kind) {
>m.kind : "A" | "B" | "C" | "D"
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>kind : "A" | "B" | "C" | "D"
case "A":
>"A" : string
case "B":
>"B" : string
return;
}
m; // { kind: "B" | "C", y: number } | { kind: "D" }
>m : { kind: "B" | "C"; y: number; } | { kind: "D"; }
}
function f8(m: Message) {
>f8 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
switch (m.kind) {
>m.kind : "A" | "B" | "C" | "D"
>m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }
>kind : "A" | "B" | "C" | "D"
case "A":
>"A" : string
return;
case "D":
>"D" : string
throw new Error();
>new Error() : Error
>Error : ErrorConstructor
}
m; // { kind: "B" | "C", y: number }
>m : { kind: "B" | "C"; y: number; }
}

View file

@ -0,0 +1,11 @@
tests/cases/conformance/expressions/typeAssertions/duplicatePropertiesInTypeAssertions01.ts(2,11): error TS2300: Duplicate identifier 'a'.
tests/cases/conformance/expressions/typeAssertions/duplicatePropertiesInTypeAssertions01.ts(2,22): error TS2300: Duplicate identifier 'a'.
==== tests/cases/conformance/expressions/typeAssertions/duplicatePropertiesInTypeAssertions01.ts (2 errors) ====
let x = <{a: number; a: number}>{};
~
!!! error TS2300: Duplicate identifier 'a'.
~
!!! error TS2300: Duplicate identifier 'a'.

View file

@ -0,0 +1,12 @@
//// [duplicatePropertiesInTypeAssertions01.ts]
let x = <{a: number; a: number}>{};
//// [duplicatePropertiesInTypeAssertions01.js]
var x = {};
//// [duplicatePropertiesInTypeAssertions01.d.ts]
declare let x: {
a: number;
};

View file

@ -0,0 +1,11 @@
tests/cases/conformance/expressions/typeAssertions/duplicatePropertiesInTypeAssertions02.ts(2,16): error TS2300: Duplicate identifier 'a'.
tests/cases/conformance/expressions/typeAssertions/duplicatePropertiesInTypeAssertions02.ts(2,27): error TS2300: Duplicate identifier 'a'.
==== tests/cases/conformance/expressions/typeAssertions/duplicatePropertiesInTypeAssertions02.ts (2 errors) ====
let x = {} as {a: number; a: number};
~
!!! error TS2300: Duplicate identifier 'a'.
~
!!! error TS2300: Duplicate identifier 'a'.

View file

@ -0,0 +1,12 @@
//// [duplicatePropertiesInTypeAssertions02.ts]
let x = {} as {a: number; a: number};
//// [duplicatePropertiesInTypeAssertions02.js]
var x = {};
//// [duplicatePropertiesInTypeAssertions02.d.ts]
declare let x: {
a: number;
};

View file

@ -0,0 +1,80 @@
//// [emitDecoratorMetadata_restArgs.ts]
declare const MyClassDecorator: ClassDecorator;
declare const MyMethodDecorator: MethodDecorator;
@MyClassDecorator
class A {
constructor(...args) {}
@MyMethodDecorator
method(...args) {}
}
@MyClassDecorator
class B {
constructor(...args: number[]) {}
@MyMethodDecorator
method(...args: string[]) {}
}
//// [emitDecoratorMetadata_restArgs.js]
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var A = (function () {
function A() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
}
A.prototype.method = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
};
__decorate([
MyMethodDecorator,
__metadata('design:type', Function),
__metadata('design:paramtypes', [Object]),
__metadata('design:returntype', void 0)
], A.prototype, "method", null);
A = __decorate([
MyClassDecorator,
__metadata('design:paramtypes', [Object])
], A);
return A;
}());
var B = (function () {
function B() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
}
B.prototype.method = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
};
__decorate([
MyMethodDecorator,
__metadata('design:type', Function),
__metadata('design:paramtypes', [String]),
__metadata('design:returntype', void 0)
], B.prototype, "method", null);
B = __decorate([
MyClassDecorator,
__metadata('design:paramtypes', [Number])
], B);
return B;
}());

View file

@ -0,0 +1,44 @@
=== tests/cases/compiler/emitDecoratorMetadata_restArgs.ts ===
declare const MyClassDecorator: ClassDecorator;
>MyClassDecorator : Symbol(MyClassDecorator, Decl(emitDecoratorMetadata_restArgs.ts, 1, 13))
>ClassDecorator : Symbol(ClassDecorator, Decl(lib.d.ts, --, --))
declare const MyMethodDecorator: MethodDecorator;
>MyMethodDecorator : Symbol(MyMethodDecorator, Decl(emitDecoratorMetadata_restArgs.ts, 2, 13))
>MethodDecorator : Symbol(MethodDecorator, Decl(lib.d.ts, --, --))
@MyClassDecorator
>MyClassDecorator : Symbol(MyClassDecorator, Decl(emitDecoratorMetadata_restArgs.ts, 1, 13))
class A {
>A : Symbol(A, Decl(emitDecoratorMetadata_restArgs.ts, 2, 49))
constructor(...args) {}
>args : Symbol(args, Decl(emitDecoratorMetadata_restArgs.ts, 6, 16))
@MyMethodDecorator
>MyMethodDecorator : Symbol(MyMethodDecorator, Decl(emitDecoratorMetadata_restArgs.ts, 2, 13))
method(...args) {}
>method : Symbol(A.method, Decl(emitDecoratorMetadata_restArgs.ts, 6, 27))
>args : Symbol(args, Decl(emitDecoratorMetadata_restArgs.ts, 8, 11))
}
@MyClassDecorator
>MyClassDecorator : Symbol(MyClassDecorator, Decl(emitDecoratorMetadata_restArgs.ts, 1, 13))
class B {
>B : Symbol(B, Decl(emitDecoratorMetadata_restArgs.ts, 9, 1))
constructor(...args: number[]) {}
>args : Symbol(args, Decl(emitDecoratorMetadata_restArgs.ts, 13, 16))
@MyMethodDecorator
>MyMethodDecorator : Symbol(MyMethodDecorator, Decl(emitDecoratorMetadata_restArgs.ts, 2, 13))
method(...args: string[]) {}
>method : Symbol(B.method, Decl(emitDecoratorMetadata_restArgs.ts, 13, 37))
>args : Symbol(args, Decl(emitDecoratorMetadata_restArgs.ts, 15, 11))
}

View file

@ -0,0 +1,44 @@
=== tests/cases/compiler/emitDecoratorMetadata_restArgs.ts ===
declare const MyClassDecorator: ClassDecorator;
>MyClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
>ClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
declare const MyMethodDecorator: MethodDecorator;
>MyMethodDecorator : <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void
>MethodDecorator : <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void
@MyClassDecorator
>MyClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
class A {
>A : A
constructor(...args) {}
>args : any[]
@MyMethodDecorator
>MyMethodDecorator : <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void
method(...args) {}
>method : (...args: any[]) => void
>args : any[]
}
@MyClassDecorator
>MyClassDecorator : <TFunction extends Function>(target: TFunction) => TFunction | void
class B {
>B : B
constructor(...args: number[]) {}
>args : number[]
@MyMethodDecorator
>MyMethodDecorator : <T>(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void
method(...args: string[]) {}
>method : (...args: string[]) => void
>args : string[]
}

View file

@ -0,0 +1,9 @@
tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion01.ts(2,10): error TS1122: A tuple type element list cannot be empty.
==== tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion01.ts (1 errors) ====
let x = <[]>[];
~~
!!! error TS1122: A tuple type element list cannot be empty.
let y = x[0];

View file

@ -0,0 +1,13 @@
//// [emptyTuplesTypeAssertion01.ts]
let x = <[]>[];
let y = x[0];
//// [emptyTuplesTypeAssertion01.js]
var x = [];
var y = x[0];
//// [emptyTuplesTypeAssertion01.d.ts]
declare let x: [];
declare let y: never;

View file

@ -0,0 +1,9 @@
tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion02.ts(2,15): error TS1122: A tuple type element list cannot be empty.
==== tests/cases/conformance/types/tuple/emptyTuples/emptyTuplesTypeAssertion02.ts (1 errors) ====
let x = [] as [];
~~
!!! error TS1122: A tuple type element list cannot be empty.
let y = x[0];

View file

@ -0,0 +1,13 @@
//// [emptyTuplesTypeAssertion02.ts]
let x = [] as [];
let y = x[0];
//// [emptyTuplesTypeAssertion02.js]
var x = [];
var y = x[0];
//// [emptyTuplesTypeAssertion02.d.ts]
declare let x: [];
declare let y: never;

View file

@ -13,7 +13,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(18,23): error TS2314: Generic type 'I<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(18,27): error TS2314: Generic type 'I<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(18,38): error TS2314: Generic type 'I<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(20,17): error TS2304: Cannot find name 'I'.
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(20,17): error TS2689: Cannot extend an interface 'I'. Did you mean 'implements'?
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(23,21): error TS2314: Generic type 'I<T>' requires 1 type argument(s).
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(29,18): error TS2304: Cannot find name 'M'.
tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(30,24): error TS2314: Generic type 'E<T>' requires 1 type argument(s).
@ -76,7 +76,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc
class D extends I {
~
!!! error TS2304: Cannot find name 'I'.
!!! error TS2689: Cannot extend an interface 'I'. Did you mean 'implements'?
}
interface U extends I {}

View file

@ -1,10 +1,13 @@
error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
tests/cases/compiler/a.ts(2,1): error TS2448: Block-scoped variable 'a' used before its declaration.
!!! error TS5053: Option 'allowJs' cannot be specified with option 'declaration'.
==== tests/cases/compiler/a.ts (0 errors) ====
==== tests/cases/compiler/a.ts (1 errors) ====
let b = 30;
a = 10;
~
!!! error TS2448: Block-scoped variable 'a' used before its declaration.
==== tests/cases/compiler/b.js (0 errors) ====
let a = 10;
b = 30;

View file

@ -1,9 +0,0 @@
error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
tests/cases/compiler/a.js(1,11): error TS8014: 'property declarations' can only be used in a .ts file.
!!! error TS5055: Cannot write file 'tests/cases/compiler/a.js' because it would overwrite input file.
==== tests/cases/compiler/a.js (1 errors) ====
class C { v }
~
!!! error TS8014: 'property declarations' can only be used in a .ts file.

View file

@ -0,0 +1,11 @@
tests/cases/compiler/file1.ts(2,1): error TS2448: Block-scoped variable 'l' used before its declaration.
==== tests/cases/compiler/file1.ts (1 errors) ====
l;
~
!!! error TS2448: Block-scoped variable 'l' used before its declaration.
==== tests/cases/compiler/file2.ts (0 errors) ====
const l = 0;

View file

@ -86,8 +86,8 @@ const a8 = a && z;
>z : string | number | undefined
const s1 = s && a;
>s1 : number[] | string
>s && a : number[] | string
>s1 : number[]
>s && a : number[]
>s : string
>a : number[]
@ -98,32 +98,32 @@ const s2 = s && s;
>s : string
const s3 = s && x;
>s3 : number | string
>s && x : number | string
>s3 : number
>s && x : number
>s : string
>x : number
const s4 = s && b;
>s4 : boolean | string
>s && b : boolean | string
>s4 : boolean
>s && b : boolean
>s : string
>b : boolean
const s5 = s && v;
>s5 : void | string
>s && v : void | string
>s5 : void
>s && v : void
>s : string
>v : void
const s6 = s && u;
>s6 : string | undefined
>s && u : string | undefined
>s6 : undefined
>s && u : undefined
>s : string
>u : undefined
const s7 = s && n;
>s7 : string | null
>s && n : string | null
>s7 : null
>s && n : null
>s : string
>n : null
@ -134,14 +134,14 @@ const s8 = s && z;
>z : string | number | undefined
const x1 = x && a;
>x1 : number[] | number
>x && a : number[] | number
>x1 : number[]
>x && a : number[]
>x : number
>a : number[]
const x2 = x && s;
>x2 : string | number
>x && s : string | number
>x2 : string
>x && s : string
>x : number
>s : string
@ -152,26 +152,26 @@ const x3 = x && x;
>x : number
const x4 = x && b;
>x4 : boolean | number
>x && b : boolean | number
>x4 : boolean
>x && b : boolean
>x : number
>b : boolean
const x5 = x && v;
>x5 : void | number
>x && v : void | number
>x5 : void
>x && v : void
>x : number
>v : void
const x6 = x && u;
>x6 : number | undefined
>x && u : number | undefined
>x6 : undefined
>x && u : undefined
>x : number
>u : undefined
const x7 = x && n;
>x7 : number | null
>x && n : number | null
>x7 : null
>x && n : null
>x : number
>n : null
@ -182,20 +182,20 @@ const x8 = x && z;
>z : string | number | undefined
const b1 = b && a;
>b1 : number[] | boolean
>b && a : number[] | boolean
>b1 : number[]
>b && a : number[]
>b : boolean
>a : number[]
const b2 = b && s;
>b2 : string | boolean
>b && s : string | boolean
>b2 : string
>b && s : string
>b : boolean
>s : string
const b3 = b && x;
>b3 : number | boolean
>b && x : number | boolean
>b3 : number
>b && x : number
>b : boolean
>x : number
@ -206,26 +206,26 @@ const b4 = b && b;
>b : boolean
const b5 = b && v;
>b5 : void | boolean
>b && v : void | boolean
>b5 : void
>b && v : void
>b : boolean
>v : void
const b6 = b && u;
>b6 : boolean | undefined
>b && u : boolean | undefined
>b6 : undefined
>b && u : undefined
>b : boolean
>u : undefined
const b7 = b && n;
>b7 : boolean | null
>b && n : boolean | null
>b7 : null
>b && n : null
>b : boolean
>n : null
const b8 = b && z;
>b8 : string | number | boolean | undefined
>b && z : string | number | boolean | undefined
>b8 : string | number | undefined
>b && z : string | number | undefined
>b : boolean
>z : string | number | undefined
@ -374,44 +374,44 @@ const n8 = n && z;
>z : string | number | undefined
const z1 = z && a;
>z1 : number[] | string | number | undefined
>z && a : number[] | string | number | undefined
>z1 : number[] | undefined
>z && a : number[] | undefined
>z : string | number | undefined
>a : number[]
const z2 = z && s;
>z2 : string | number | undefined
>z && s : string | number | undefined
>z2 : string | undefined
>z && s : string | undefined
>z : string | number | undefined
>s : string
const z3 = z && x;
>z3 : number | string | undefined
>z && x : number | string | undefined
>z3 : number | undefined
>z && x : number | undefined
>z : string | number | undefined
>x : number
const z4 = z && b;
>z4 : boolean | string | number | undefined
>z && b : boolean | string | number | undefined
>z4 : boolean | undefined
>z && b : boolean | undefined
>z : string | number | undefined
>b : boolean
const z5 = z && v;
>z5 : void | string | number
>z && v : void | string | number
>z5 : void
>z && v : void
>z : string | number | undefined
>v : void
const z6 = z && u;
>z6 : string | number | undefined
>z && u : string | number | undefined
>z6 : undefined
>z && u : undefined
>z : string | number | undefined
>u : undefined
const z7 = z && n;
>z7 : string | number | null | undefined
>z && n : string | number | null | undefined
>z7 : null | undefined
>z && n : null | undefined
>z : string | number | undefined
>n : null

View file

@ -0,0 +1,140 @@
tests/cases/compiler/missingFunctionImplementation.ts(3,3): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(8,3): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(16,3): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(22,10): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(28,10): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(33,10): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(41,10): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(48,10): error TS2300: Duplicate identifier 'm'.
tests/cases/compiler/missingFunctionImplementation.ts(49,10): error TS2300: Duplicate identifier 'm'.
tests/cases/compiler/missingFunctionImplementation.ts(49,10): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(52,19): error TS2300: Duplicate identifier 'm'.
tests/cases/compiler/missingFunctionImplementation.ts(57,10): error TS2300: Duplicate identifier 'm'.
tests/cases/compiler/missingFunctionImplementation.ts(60,19): error TS2300: Duplicate identifier 'm'.
tests/cases/compiler/missingFunctionImplementation.ts(60,19): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(65,19): error TS2391: Function implementation is missing or not immediately following the declaration.
tests/cases/compiler/missingFunctionImplementation.ts(73,19): error TS2393: Duplicate function implementation.
tests/cases/compiler/missingFunctionImplementation.ts(74,19): error TS2393: Duplicate function implementation.
tests/cases/compiler/missingFunctionImplementation.ts(75,19): error TS2393: Duplicate function implementation.
tests/cases/compiler/missingFunctionImplementation.ts(78,19): error TS2393: Duplicate function implementation.
==== tests/cases/compiler/missingFunctionImplementation.ts (19 errors) ====
export class C1 {
m(): void;
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
// merged with a namespace
export class C2 {
m(): void;
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
export namespace C2 { }
// merged with a namespace, multiple overloads
class C3 {
m(a, b);
m(a);
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
namespace C3 { }
// static methods, multiple overloads
class C4 {
static m(a): void;
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
// static methods, multiple overloads
class C5 {
static m(a): void;
static m(): void;
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
// merged with namespace, static methods
class C6 {
static m(): void;
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
namespace C6 {
}
// merged with namespace, static methods, multiple overloads
class C7 {
static m(a): void;
static m(): void;
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
namespace C7 {
}
// merged with namespace, static methods, duplicate declarations
class C8 {
static m(a): void;
~
!!! error TS2300: Duplicate identifier 'm'.
static m(a, b): void;
~
!!! error TS2300: Duplicate identifier 'm'.
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
namespace C8 {
export function m(a?, b?): void { }
~
!!! error TS2300: Duplicate identifier 'm'.
}
// merged with namespace, static methods, duplicate declarations
class C9 {
static m(a): void { }
~
!!! error TS2300: Duplicate identifier 'm'.
}
namespace C9 {
export function m(a): void;
~
!!! error TS2300: Duplicate identifier 'm'.
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
// merged namespaces
namespace N10 {
export function m(a): void;
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
}
namespace N10 {
export function m(a): void { }
}
// merged namespaces, duplicate defintions
namespace N12 {
export function m(a): void;
~
!!! error TS2393: Duplicate function implementation.
export function m(): void;
~
!!! error TS2393: Duplicate function implementation.
export function m(a?): void { }
~
!!! error TS2393: Duplicate function implementation.
}
namespace N12 {
export function m(a): void { }
~
!!! error TS2393: Duplicate function implementation.
}

View file

@ -0,0 +1,168 @@
//// [missingFunctionImplementation.ts]
export class C1 {
m(): void;
}
// merged with a namespace
export class C2 {
m(): void;
}
export namespace C2 { }
// merged with a namespace, multiple overloads
class C3 {
m(a, b);
m(a);
}
namespace C3 { }
// static methods, multiple overloads
class C4 {
static m(a): void;
}
// static methods, multiple overloads
class C5 {
static m(a): void;
static m(): void;
}
// merged with namespace, static methods
class C6 {
static m(): void;
}
namespace C6 {
}
// merged with namespace, static methods, multiple overloads
class C7 {
static m(a): void;
static m(): void;
}
namespace C7 {
}
// merged with namespace, static methods, duplicate declarations
class C8 {
static m(a): void;
static m(a, b): void;
}
namespace C8 {
export function m(a?, b?): void { }
}
// merged with namespace, static methods, duplicate declarations
class C9 {
static m(a): void { }
}
namespace C9 {
export function m(a): void;
}
// merged namespaces
namespace N10 {
export function m(a): void;
}
namespace N10 {
export function m(a): void { }
}
// merged namespaces, duplicate defintions
namespace N12 {
export function m(a): void;
export function m(): void;
export function m(a?): void { }
}
namespace N12 {
export function m(a): void { }
}
//// [missingFunctionImplementation.js]
"use strict";
var C1 = (function () {
function C1() {
}
return C1;
}());
exports.C1 = C1;
// merged with a namespace
var C2 = (function () {
function C2() {
}
return C2;
}());
exports.C2 = C2;
// merged with a namespace, multiple overloads
var C3 = (function () {
function C3() {
}
return C3;
}());
// static methods, multiple overloads
var C4 = (function () {
function C4() {
}
return C4;
}());
// static methods, multiple overloads
var C5 = (function () {
function C5() {
}
return C5;
}());
// merged with namespace, static methods
var C6 = (function () {
function C6() {
}
return C6;
}());
// merged with namespace, static methods, multiple overloads
var C7 = (function () {
function C7() {
}
return C7;
}());
// merged with namespace, static methods, duplicate declarations
var C8 = (function () {
function C8() {
}
return C8;
}());
var C8;
(function (C8) {
function m(a, b) { }
C8.m = m;
})(C8 || (C8 = {}));
// merged with namespace, static methods, duplicate declarations
var C9 = (function () {
function C9() {
}
C9.m = function (a) { };
return C9;
}());
var C9;
(function (C9) {
})(C9 || (C9 = {}));
// merged namespaces
var N10;
(function (N10) {
})(N10 || (N10 = {}));
var N10;
(function (N10) {
function m(a) { }
N10.m = m;
})(N10 || (N10 = {}));
// merged namespaces, duplicate defintions
var N12;
(function (N12) {
function m(a) { }
N12.m = m;
})(N12 || (N12 = {}));
var N12;
(function (N12) {
function m(a) { }
N12.m = m;
})(N12 || (N12 = {}));

View file

@ -0,0 +1,16 @@
tests/cases/compiler/missingFunctionImplementation2_a.ts(3,19): error TS2384: Overload signatures must all be ambient or non-ambient.
tests/cases/compiler/missingFunctionImplementation2_b.ts(1,17): error TS2391: Function implementation is missing or not immediately following the declaration.
==== tests/cases/compiler/missingFunctionImplementation2_a.ts (1 errors) ====
export {};
declare module "./missingFunctionImplementation2_b.ts" {
export function f(a, b): void;
~
!!! error TS2384: Overload signatures must all be ambient or non-ambient.
}
==== tests/cases/compiler/missingFunctionImplementation2_b.ts (1 errors) ====
export function f(a?, b?);
~
!!! error TS2391: Function implementation is missing or not immediately following the declaration.

View file

@ -0,0 +1,15 @@
//// [tests/cases/compiler/missingFunctionImplementation2.ts] ////
//// [missingFunctionImplementation2_a.ts]
export {};
declare module "./missingFunctionImplementation2_b.ts" {
export function f(a, b): void;
}
//// [missingFunctionImplementation2_b.ts]
export function f(a?, b?);
//// [missingFunctionImplementation2_a.js]
"use strict";
//// [missingFunctionImplementation2_b.js]
"use strict";

View file

@ -0,0 +1,21 @@
//// [shorthandOfExportedEntity01_targetES2015_CommonJS.ts]
export const test = "test";
export function foo () {
const x = { test };
}
//// [shorthandOfExportedEntity01_targetES2015_CommonJS.js]
"use strict";
exports.test = "test";
function foo() {
const x = { test: exports.test };
}
exports.foo = foo;
//// [shorthandOfExportedEntity01_targetES2015_CommonJS.d.ts]
export declare const test: string;
export declare function foo(): void;

View file

@ -0,0 +1,13 @@
=== tests/cases/compiler/shorthandOfExportedEntity01_targetES2015_CommonJS.ts ===
export const test = "test";
>test : Symbol(test, Decl(shorthandOfExportedEntity01_targetES2015_CommonJS.ts, 1, 12))
export function foo () {
>foo : Symbol(foo, Decl(shorthandOfExportedEntity01_targetES2015_CommonJS.ts, 1, 27))
const x = { test };
>x : Symbol(x, Decl(shorthandOfExportedEntity01_targetES2015_CommonJS.ts, 4, 7))
>test : Symbol(test, Decl(shorthandOfExportedEntity01_targetES2015_CommonJS.ts, 4, 13))
}

View file

@ -0,0 +1,15 @@
=== tests/cases/compiler/shorthandOfExportedEntity01_targetES2015_CommonJS.ts ===
export const test = "test";
>test : string
>"test" : string
export function foo () {
>foo : () => void
const x = { test };
>x : { test: string; }
>{ test } : { test: string; }
>test : string
}

View file

@ -0,0 +1,21 @@
//// [shorthandOfExportedEntity02_targetES5_CommonJS.ts]
export const test = "test";
export function foo () {
const x = { test };
}
//// [shorthandOfExportedEntity02_targetES5_CommonJS.js]
"use strict";
exports.test = "test";
function foo() {
var x = { test: exports.test };
}
exports.foo = foo;
//// [shorthandOfExportedEntity02_targetES5_CommonJS.d.ts]
export declare const test: string;
export declare function foo(): void;

View file

@ -0,0 +1,13 @@
=== tests/cases/compiler/shorthandOfExportedEntity02_targetES5_CommonJS.ts ===
export const test = "test";
>test : Symbol(test, Decl(shorthandOfExportedEntity02_targetES5_CommonJS.ts, 1, 12))
export function foo () {
>foo : Symbol(foo, Decl(shorthandOfExportedEntity02_targetES5_CommonJS.ts, 1, 27))
const x = { test };
>x : Symbol(x, Decl(shorthandOfExportedEntity02_targetES5_CommonJS.ts, 4, 7))
>test : Symbol(test, Decl(shorthandOfExportedEntity02_targetES5_CommonJS.ts, 4, 13))
}

View file

@ -0,0 +1,15 @@
=== tests/cases/compiler/shorthandOfExportedEntity02_targetES5_CommonJS.ts ===
export const test = "test";
>test : string
>"test" : string
export function foo () {
>foo : () => void
const x = { test };
>x : { test: string; }
>{ test } : { test: string; }
>test : string
}

View file

@ -0,0 +1,26 @@
//// [strictNullLogicalAndOr.ts]
// Repro from #9113
let sinOrCos = Math.random() < .5;
let choice = sinOrCos && Math.sin || Math.cos;
choice(Math.PI);
function sq(n?: number): number {
const r = n !== undefined && n*n || 0;
return r;
}
sq(3);
//// [strictNullLogicalAndOr.js]
// Repro from #9113
var sinOrCos = Math.random() < .5;
var choice = sinOrCos && Math.sin || Math.cos;
choice(Math.PI);
function sq(n) {
var r = n !== undefined && n * n || 0;
return r;
}
sq(3);

View file

@ -0,0 +1,44 @@
=== tests/cases/compiler/strictNullLogicalAndOr.ts ===
// Repro from #9113
let sinOrCos = Math.random() < .5;
>sinOrCos : Symbol(sinOrCos, Decl(strictNullLogicalAndOr.ts, 3, 3))
>Math.random : Symbol(Math.random, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>random : Symbol(Math.random, Decl(lib.d.ts, --, --))
let choice = sinOrCos && Math.sin || Math.cos;
>choice : Symbol(choice, Decl(strictNullLogicalAndOr.ts, 4, 3))
>sinOrCos : Symbol(sinOrCos, Decl(strictNullLogicalAndOr.ts, 3, 3))
>Math.sin : Symbol(Math.sin, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>sin : Symbol(Math.sin, Decl(lib.d.ts, --, --))
>Math.cos : Symbol(Math.cos, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>cos : Symbol(Math.cos, Decl(lib.d.ts, --, --))
choice(Math.PI);
>choice : Symbol(choice, Decl(strictNullLogicalAndOr.ts, 4, 3))
>Math.PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
>PI : Symbol(Math.PI, Decl(lib.d.ts, --, --))
function sq(n?: number): number {
>sq : Symbol(sq, Decl(strictNullLogicalAndOr.ts, 6, 16))
>n : Symbol(n, Decl(strictNullLogicalAndOr.ts, 8, 12))
const r = n !== undefined && n*n || 0;
>r : Symbol(r, Decl(strictNullLogicalAndOr.ts, 9, 7))
>n : Symbol(n, Decl(strictNullLogicalAndOr.ts, 8, 12))
>undefined : Symbol(undefined)
>n : Symbol(n, Decl(strictNullLogicalAndOr.ts, 8, 12))
>n : Symbol(n, Decl(strictNullLogicalAndOr.ts, 8, 12))
return r;
>r : Symbol(r, Decl(strictNullLogicalAndOr.ts, 9, 7))
}
sq(3);
>sq : Symbol(sq, Decl(strictNullLogicalAndOr.ts, 6, 16))

View file

@ -0,0 +1,57 @@
=== tests/cases/compiler/strictNullLogicalAndOr.ts ===
// Repro from #9113
let sinOrCos = Math.random() < .5;
>sinOrCos : boolean
>Math.random() < .5 : boolean
>Math.random() : number
>Math.random : () => number
>Math : Math
>random : () => number
>.5 : number
let choice = sinOrCos && Math.sin || Math.cos;
>choice : (x: number) => number
>sinOrCos && Math.sin || Math.cos : (x: number) => number
>sinOrCos && Math.sin : (x: number) => number
>sinOrCos : boolean
>Math.sin : (x: number) => number
>Math : Math
>sin : (x: number) => number
>Math.cos : (x: number) => number
>Math : Math
>cos : (x: number) => number
choice(Math.PI);
>choice(Math.PI) : number
>choice : (x: number) => number
>Math.PI : number
>Math : Math
>PI : number
function sq(n?: number): number {
>sq : (n?: number | undefined) => number
>n : number | undefined
const r = n !== undefined && n*n || 0;
>r : number
>n !== undefined && n*n || 0 : number
>n !== undefined && n*n : number
>n !== undefined : boolean
>n : number | undefined
>undefined : undefined
>n*n : number
>n : number
>n : number
>0 : number
return r;
>r : number
}
sq(3);
>sq(3) : number
>sq : (n?: number | undefined) => number
>3 : number

View file

@ -0,0 +1,2 @@
export const x = 0;
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,3 @@
"use strict";
var x = 0;
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,7 @@
file.ts(1,3): error TS1005: ';' expected.
==== file.ts (1 errors) ====
a b
~
!!! error TS1005: ';' expected.

View file

@ -0,0 +1,4 @@
"use strict";
a;
b;
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,5 @@
define(["require", "exports"], function (require, exports) {
"use strict";
var x = 0;
});
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,4 @@
"use strict";
/// <reference path="file2.ts" />
var x = 0;
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,3 @@
"use strict";
var x = 0;
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,3 @@
"use strict";
var x = 0;
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,5 @@
define(["require", "exports", "SomeOtherName"], function (require, exports, SomeName_1) {
"use strict";
use(SomeName_1.foo);
});
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,15 @@
System.register(["SomeOtherName"], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var SomeName_1;
return {
setters:[
function (SomeName_1_1) {
SomeName_1 = SomeName_1_1;
}],
execute: function() {
use(SomeName_1.foo);
}
}
});
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,13 @@
(function (factory) {
if (typeof module === 'object' && typeof module.exports === 'object') {
var v = factory(require, exports); if (v !== undefined) module.exports = v;
}
else if (typeof define === 'function' && define.amd) {
define(["require", "exports", "SomeOtherName"], factory);
}
})(function (require, exports) {
"use strict";
var SomeName_1 = require("SomeOtherName");
use(SomeName_1.foo);
});
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,6 @@
error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
==== file.ts (0 errors) ====

View file

@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,6 @@
error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
==== file.ts (0 errors) ====

View file

@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,6 @@
error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
==== file.ts (0 errors) ====

View file

@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,6 @@
error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
!!! error TS6046: Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'
==== file.ts (0 errors) ====

View file

@ -0,0 +1,2 @@
"use strict";
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,12 @@
System.register("NamedModule", [], function(exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
var x;
return {
setters:[],
execute: function() {
var x = 1;
}
}
});
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,3 @@
"use strict";
var a = 10;
//# sourceMappingURL=input.js.map

View file

@ -0,0 +1,3 @@
"use strict";
var a = 10;
//# sourceMappingURL=input.js.map

View file

@ -0,0 +1,3 @@
"use strict";
var x;
//# sourceMappingURL=b.js.map

View file

@ -0,0 +1,3 @@
"use strict";
var x;
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,19 @@
"use strict";
var db_1 = require('./db');
function someDecorator(target) {
return target;
}
var MyClass = (function () {
function MyClass(db) {
this.db = db;
this.db.doSomething();
}
MyClass = __decorate([
someDecorator,
__metadata('design:paramtypes', [(typeof (_a = typeof db_1.db !== 'undefined' && db_1.db) === 'function' && _a) || Object])
], MyClass);
return MyClass;
var _a;
}());
exports.MyClass = MyClass;
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,3 @@
"use strict";
var x = 0;
//# sourceMappingURL=file.js.map

View file

@ -0,0 +1,3 @@
"use strict";
var a = 10;
//# sourceMappingURL=input.js.map

View file

@ -0,0 +1,3 @@
"use strict";
var x = React.createElement("div", null);
//# sourceMappingURL=file.js.map

View file

@ -1,7 +1,7 @@
interface Comparable {}
class A extends Comparable {}
class B implements Comparable {}
interface Comparable2<T> {}
class A2<T> extends Comparable2<T> {}
class B2<T> implements Comparable2<T> {}

View file

@ -0,0 +1,7 @@
interface A {}
function factory(a: any): {new(): Object} {
return null;
}
class C extends factory(A) {}

View file

@ -0,0 +1,14 @@
module M {
export interface I1 {}
export interface I2<T> {}
}
class C1 extends M.I1 {}
class C2<T> extends M.I2<T> {}
module Mod {
export namespace Nested {
export interface I {}
}
}
class D extends Mod.Nested.I {}

View file

@ -0,0 +1,14 @@
// @experimentaldecorators: true
// @emitdecoratormetadata: true
// @target: es6
declare const decorator: MethodDecorator;
class A {
@decorator
async foo() {}
@decorator
async bar(): Promise<number> { return 0; }
@decorator
baz(n: Promise<number>): Promise<number> { return n; }
}

View file

@ -0,0 +1,20 @@
// @experimentaldecorators: true
// @emitdecoratormetadata: true
// @target: ES5
declare const MyClassDecorator: ClassDecorator;
declare const MyMethodDecorator: MethodDecorator;
@MyClassDecorator
class A {
constructor(...args) {}
@MyMethodDecorator
method(...args) {}
}
@MyClassDecorator
class B {
constructor(...args: number[]) {}
@MyMethodDecorator
method(...args: string[]) {}
}

View file

@ -1,3 +0,0 @@
// @allowJs: true
// @filename: a.js
class C { v }

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