Merge branch 'master' into protectedMembers
This commit is contained in:
commit
08188b0142
51
bin/tsc.js
51
bin/tsc.js
|
@ -3458,14 +3458,21 @@ var ts;
|
||||||
node.initializer = parseInitializer(true);
|
node.initializer = parseInitializer(true);
|
||||||
return finishNode(node);
|
return finishNode(node);
|
||||||
}
|
}
|
||||||
function parseSignature(kind, returnToken) {
|
function parseSignature(kind, returnToken, returnTokenRequired) {
|
||||||
if (kind === 121 /* ConstructSignature */) {
|
if (kind === 121 /* ConstructSignature */) {
|
||||||
parseExpected(78 /* NewKeyword */);
|
parseExpected(78 /* NewKeyword */);
|
||||||
}
|
}
|
||||||
var typeParameters = parseTypeParameters();
|
var typeParameters = parseTypeParameters();
|
||||||
var parameters = parseParameterList(7 /* OpenParenToken */, 8 /* CloseParenToken */);
|
var parameters = parseParameterList(7 /* OpenParenToken */, 8 /* CloseParenToken */);
|
||||||
checkParameterList(parameters);
|
checkParameterList(parameters);
|
||||||
var type = parseOptional(returnToken) ? parseType() : undefined;
|
var type;
|
||||||
|
if (returnTokenRequired) {
|
||||||
|
parseExpected(returnToken);
|
||||||
|
type = parseType();
|
||||||
|
}
|
||||||
|
else if (parseOptional(returnToken)) {
|
||||||
|
type = parseType();
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
typeParameters: typeParameters,
|
typeParameters: typeParameters,
|
||||||
parameters: parameters,
|
parameters: parameters,
|
||||||
|
@ -3515,7 +3522,7 @@ var ts;
|
||||||
}
|
}
|
||||||
function parseSignatureMember(kind, returnToken) {
|
function parseSignatureMember(kind, returnToken) {
|
||||||
var node = createNode(kind);
|
var node = createNode(kind);
|
||||||
var sig = parseSignature(kind, returnToken);
|
var sig = parseSignature(kind, returnToken, false);
|
||||||
node.typeParameters = sig.typeParameters;
|
node.typeParameters = sig.typeParameters;
|
||||||
node.parameters = sig.parameters;
|
node.parameters = sig.parameters;
|
||||||
node.type = sig.type;
|
node.type = sig.type;
|
||||||
|
@ -3584,7 +3591,7 @@ var ts;
|
||||||
}
|
}
|
||||||
if (token === 7 /* OpenParenToken */ || token === 15 /* LessThanToken */) {
|
if (token === 7 /* OpenParenToken */ || token === 15 /* LessThanToken */) {
|
||||||
node.kind = 116 /* Method */;
|
node.kind = 116 /* Method */;
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
node.typeParameters = sig.typeParameters;
|
node.typeParameters = sig.typeParameters;
|
||||||
node.parameters = sig.parameters;
|
node.parameters = sig.parameters;
|
||||||
node.type = sig.type;
|
node.type = sig.type;
|
||||||
|
@ -3640,7 +3647,7 @@ var ts;
|
||||||
function parseFunctionType(signatureKind) {
|
function parseFunctionType(signatureKind) {
|
||||||
var node = createNode(125 /* TypeLiteral */);
|
var node = createNode(125 /* TypeLiteral */);
|
||||||
var member = createNode(signatureKind);
|
var member = createNode(signatureKind);
|
||||||
var sig = parseSignature(signatureKind, 23 /* EqualsGreaterThanToken */);
|
var sig = parseSignature(signatureKind, 23 /* EqualsGreaterThanToken */, true);
|
||||||
member.typeParameters = sig.typeParameters;
|
member.typeParameters = sig.typeParameters;
|
||||||
member.parameters = sig.parameters;
|
member.parameters = sig.parameters;
|
||||||
member.type = sig.type;
|
member.type = sig.type;
|
||||||
|
@ -3828,7 +3835,7 @@ var ts;
|
||||||
}
|
}
|
||||||
var pos = getNodePos();
|
var pos = getNodePos();
|
||||||
if (triState === 1 /* True */) {
|
if (triState === 1 /* True */) {
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
if (parseExpected(23 /* EqualsGreaterThanToken */) || token === 5 /* OpenBraceToken */) {
|
if (parseExpected(23 /* EqualsGreaterThanToken */) || token === 5 /* OpenBraceToken */) {
|
||||||
return parseArrowExpressionTail(pos, sig, false);
|
return parseArrowExpressionTail(pos, sig, false);
|
||||||
}
|
}
|
||||||
|
@ -3889,7 +3896,7 @@ var ts;
|
||||||
}
|
}
|
||||||
function tryParseSignatureIfArrowOrBraceFollows() {
|
function tryParseSignatureIfArrowOrBraceFollows() {
|
||||||
return tryParse(function () {
|
return tryParse(function () {
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
if (token === 23 /* EqualsGreaterThanToken */ || token === 5 /* OpenBraceToken */) {
|
if (token === 23 /* EqualsGreaterThanToken */ || token === 5 /* OpenBraceToken */) {
|
||||||
return sig;
|
return sig;
|
||||||
}
|
}
|
||||||
|
@ -4161,7 +4168,7 @@ var ts;
|
||||||
var node = createNode(129 /* PropertyAssignment */);
|
var node = createNode(129 /* PropertyAssignment */);
|
||||||
node.name = parsePropertyName();
|
node.name = parsePropertyName();
|
||||||
if (token === 7 /* OpenParenToken */ || token === 15 /* LessThanToken */) {
|
if (token === 7 /* OpenParenToken */ || token === 15 /* LessThanToken */) {
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
var body = parseBody(false);
|
var body = parseBody(false);
|
||||||
node.initializer = makeFunctionExpression(136 /* FunctionExpression */, node.pos, undefined, sig, body);
|
node.initializer = makeFunctionExpression(136 /* FunctionExpression */, node.pos, undefined, sig, body);
|
||||||
}
|
}
|
||||||
|
@ -4240,7 +4247,7 @@ var ts;
|
||||||
var pos = getNodePos();
|
var pos = getNodePos();
|
||||||
parseExpected(73 /* FunctionKeyword */);
|
parseExpected(73 /* FunctionKeyword */);
|
||||||
var name = isIdentifier() ? parseIdentifier() : undefined;
|
var name = isIdentifier() ? parseIdentifier() : undefined;
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
var body = parseBody(false);
|
var body = parseBody(false);
|
||||||
if (name && isInStrictMode && isEvalOrArgumentsIdentifier(name)) {
|
if (name && isInStrictMode && isEvalOrArgumentsIdentifier(name)) {
|
||||||
reportInvalidUseInStrictMode(name);
|
reportInvalidUseInStrictMode(name);
|
||||||
|
@ -4752,7 +4759,7 @@ var ts;
|
||||||
node.flags = flags;
|
node.flags = flags;
|
||||||
parseExpected(73 /* FunctionKeyword */);
|
parseExpected(73 /* FunctionKeyword */);
|
||||||
node.name = parseIdentifier();
|
node.name = parseIdentifier();
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
node.typeParameters = sig.typeParameters;
|
node.typeParameters = sig.typeParameters;
|
||||||
node.parameters = sig.parameters;
|
node.parameters = sig.parameters;
|
||||||
node.type = sig.type;
|
node.type = sig.type;
|
||||||
|
@ -4766,7 +4773,7 @@ var ts;
|
||||||
var node = createNode(117 /* Constructor */, pos);
|
var node = createNode(117 /* Constructor */, pos);
|
||||||
node.flags = flags;
|
node.flags = flags;
|
||||||
parseExpected(103 /* ConstructorKeyword */);
|
parseExpected(103 /* ConstructorKeyword */);
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
node.typeParameters = sig.typeParameters;
|
node.typeParameters = sig.typeParameters;
|
||||||
node.parameters = sig.parameters;
|
node.parameters = sig.parameters;
|
||||||
node.type = sig.type;
|
node.type = sig.type;
|
||||||
|
@ -4790,7 +4797,7 @@ var ts;
|
||||||
var method = createNode(116 /* Method */, pos);
|
var method = createNode(116 /* Method */, pos);
|
||||||
method.flags = flags;
|
method.flags = flags;
|
||||||
method.name = name;
|
method.name = name;
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
method.typeParameters = sig.typeParameters;
|
method.typeParameters = sig.typeParameters;
|
||||||
method.parameters = sig.parameters;
|
method.parameters = sig.parameters;
|
||||||
method.type = sig.type;
|
method.type = sig.type;
|
||||||
|
@ -4858,7 +4865,7 @@ var ts;
|
||||||
var node = createNode(kind, pos);
|
var node = createNode(kind, pos);
|
||||||
node.flags = flags;
|
node.flags = flags;
|
||||||
node.name = parsePropertyName();
|
node.name = parsePropertyName();
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
node.typeParameters = sig.typeParameters;
|
node.typeParameters = sig.typeParameters;
|
||||||
node.parameters = sig.parameters;
|
node.parameters = sig.parameters;
|
||||||
node.type = sig.type;
|
node.type = sig.type;
|
||||||
|
@ -5421,17 +5428,27 @@ var ts;
|
||||||
var start = refPos;
|
var start = refPos;
|
||||||
var length = refEnd - refPos;
|
var length = refEnd - refPos;
|
||||||
}
|
}
|
||||||
|
var diagnostic;
|
||||||
if (hasExtension(filename)) {
|
if (hasExtension(filename)) {
|
||||||
if (!ts.fileExtensionIs(filename, ".ts")) {
|
if (!ts.fileExtensionIs(filename, ".ts")) {
|
||||||
errors.push(ts.createFileDiagnostic(refFile, start, length, ts.Diagnostics.File_0_must_have_extension_ts_or_d_ts, filename));
|
diagnostic = ts.Diagnostics.File_0_must_have_extension_ts_or_d_ts;
|
||||||
}
|
}
|
||||||
else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {
|
else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {
|
||||||
errors.push(ts.createFileDiagnostic(refFile, start, length, ts.Diagnostics.File_0_not_found, filename));
|
diagnostic = ts.Diagnostics.File_0_not_found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) {
|
if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) {
|
||||||
errors.push(ts.createFileDiagnostic(refFile, start, length, ts.Diagnostics.File_0_not_found, filename + ".ts"));
|
diagnostic = ts.Diagnostics.File_0_not_found;
|
||||||
|
filename += ".ts";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (diagnostic) {
|
||||||
|
if (refFile) {
|
||||||
|
errors.push(ts.createFileDiagnostic(refFile, start, length, diagnostic, filename));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errors.push(ts.createCompilerDiagnostic(diagnostic, filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10897,11 +10914,13 @@ var ts;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (getDeclarationFlagsFromSymbol(sourceProp) & 32 /* Private */ || getDeclarationFlagsFromSymbol(targetProp) & 32 /* Private */) {
|
if (getDeclarationFlagsFromSymbol(sourceProp) & 32 /* Private */ || getDeclarationFlagsFromSymbol(targetProp) & 32 /* Private */) {
|
||||||
|
if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) {
|
||||||
if (reportErrors) {
|
if (reportErrors) {
|
||||||
reportError(ts.Diagnostics.Private_property_0_cannot_be_reimplemented, symbolToString(targetProp));
|
reportError(ts.Diagnostics.Private_property_0_cannot_be_reimplemented, symbolToString(targetProp));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors)) {
|
if (!isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors)) {
|
||||||
if (reportErrors) {
|
if (reportErrors) {
|
||||||
reportError(ts.Diagnostics.Types_of_property_0_are_incompatible_Colon, symbolToString(targetProp));
|
reportError(ts.Diagnostics.Types_of_property_0_are_incompatible_Colon, symbolToString(targetProp));
|
||||||
|
|
|
@ -3263,14 +3263,21 @@ var ts;
|
||||||
node.initializer = parseInitializer(true);
|
node.initializer = parseInitializer(true);
|
||||||
return finishNode(node);
|
return finishNode(node);
|
||||||
}
|
}
|
||||||
function parseSignature(kind, returnToken) {
|
function parseSignature(kind, returnToken, returnTokenRequired) {
|
||||||
if (kind === 121 /* ConstructSignature */) {
|
if (kind === 121 /* ConstructSignature */) {
|
||||||
parseExpected(78 /* NewKeyword */);
|
parseExpected(78 /* NewKeyword */);
|
||||||
}
|
}
|
||||||
var typeParameters = parseTypeParameters();
|
var typeParameters = parseTypeParameters();
|
||||||
var parameters = parseParameterList(7 /* OpenParenToken */, 8 /* CloseParenToken */);
|
var parameters = parseParameterList(7 /* OpenParenToken */, 8 /* CloseParenToken */);
|
||||||
checkParameterList(parameters);
|
checkParameterList(parameters);
|
||||||
var type = parseOptional(returnToken) ? parseType() : undefined;
|
var type;
|
||||||
|
if (returnTokenRequired) {
|
||||||
|
parseExpected(returnToken);
|
||||||
|
type = parseType();
|
||||||
|
}
|
||||||
|
else if (parseOptional(returnToken)) {
|
||||||
|
type = parseType();
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
typeParameters: typeParameters,
|
typeParameters: typeParameters,
|
||||||
parameters: parameters,
|
parameters: parameters,
|
||||||
|
@ -3320,7 +3327,7 @@ var ts;
|
||||||
}
|
}
|
||||||
function parseSignatureMember(kind, returnToken) {
|
function parseSignatureMember(kind, returnToken) {
|
||||||
var node = createNode(kind);
|
var node = createNode(kind);
|
||||||
var sig = parseSignature(kind, returnToken);
|
var sig = parseSignature(kind, returnToken, false);
|
||||||
node.typeParameters = sig.typeParameters;
|
node.typeParameters = sig.typeParameters;
|
||||||
node.parameters = sig.parameters;
|
node.parameters = sig.parameters;
|
||||||
node.type = sig.type;
|
node.type = sig.type;
|
||||||
|
@ -3389,7 +3396,7 @@ var ts;
|
||||||
}
|
}
|
||||||
if (token === 7 /* OpenParenToken */ || token === 15 /* LessThanToken */) {
|
if (token === 7 /* OpenParenToken */ || token === 15 /* LessThanToken */) {
|
||||||
node.kind = 116 /* Method */;
|
node.kind = 116 /* Method */;
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
node.typeParameters = sig.typeParameters;
|
node.typeParameters = sig.typeParameters;
|
||||||
node.parameters = sig.parameters;
|
node.parameters = sig.parameters;
|
||||||
node.type = sig.type;
|
node.type = sig.type;
|
||||||
|
@ -3445,7 +3452,7 @@ var ts;
|
||||||
function parseFunctionType(signatureKind) {
|
function parseFunctionType(signatureKind) {
|
||||||
var node = createNode(125 /* TypeLiteral */);
|
var node = createNode(125 /* TypeLiteral */);
|
||||||
var member = createNode(signatureKind);
|
var member = createNode(signatureKind);
|
||||||
var sig = parseSignature(signatureKind, 23 /* EqualsGreaterThanToken */);
|
var sig = parseSignature(signatureKind, 23 /* EqualsGreaterThanToken */, true);
|
||||||
member.typeParameters = sig.typeParameters;
|
member.typeParameters = sig.typeParameters;
|
||||||
member.parameters = sig.parameters;
|
member.parameters = sig.parameters;
|
||||||
member.type = sig.type;
|
member.type = sig.type;
|
||||||
|
@ -3633,7 +3640,7 @@ var ts;
|
||||||
}
|
}
|
||||||
var pos = getNodePos();
|
var pos = getNodePos();
|
||||||
if (triState === 1 /* True */) {
|
if (triState === 1 /* True */) {
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
if (parseExpected(23 /* EqualsGreaterThanToken */) || token === 5 /* OpenBraceToken */) {
|
if (parseExpected(23 /* EqualsGreaterThanToken */) || token === 5 /* OpenBraceToken */) {
|
||||||
return parseArrowExpressionTail(pos, sig, false);
|
return parseArrowExpressionTail(pos, sig, false);
|
||||||
}
|
}
|
||||||
|
@ -3694,7 +3701,7 @@ var ts;
|
||||||
}
|
}
|
||||||
function tryParseSignatureIfArrowOrBraceFollows() {
|
function tryParseSignatureIfArrowOrBraceFollows() {
|
||||||
return tryParse(function () {
|
return tryParse(function () {
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
if (token === 23 /* EqualsGreaterThanToken */ || token === 5 /* OpenBraceToken */) {
|
if (token === 23 /* EqualsGreaterThanToken */ || token === 5 /* OpenBraceToken */) {
|
||||||
return sig;
|
return sig;
|
||||||
}
|
}
|
||||||
|
@ -3966,7 +3973,7 @@ var ts;
|
||||||
var node = createNode(129 /* PropertyAssignment */);
|
var node = createNode(129 /* PropertyAssignment */);
|
||||||
node.name = parsePropertyName();
|
node.name = parsePropertyName();
|
||||||
if (token === 7 /* OpenParenToken */ || token === 15 /* LessThanToken */) {
|
if (token === 7 /* OpenParenToken */ || token === 15 /* LessThanToken */) {
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
var body = parseBody(false);
|
var body = parseBody(false);
|
||||||
node.initializer = makeFunctionExpression(136 /* FunctionExpression */, node.pos, undefined, sig, body);
|
node.initializer = makeFunctionExpression(136 /* FunctionExpression */, node.pos, undefined, sig, body);
|
||||||
}
|
}
|
||||||
|
@ -4045,7 +4052,7 @@ var ts;
|
||||||
var pos = getNodePos();
|
var pos = getNodePos();
|
||||||
parseExpected(73 /* FunctionKeyword */);
|
parseExpected(73 /* FunctionKeyword */);
|
||||||
var name = isIdentifier() ? parseIdentifier() : undefined;
|
var name = isIdentifier() ? parseIdentifier() : undefined;
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
var body = parseBody(false);
|
var body = parseBody(false);
|
||||||
if (name && isInStrictMode && isEvalOrArgumentsIdentifier(name)) {
|
if (name && isInStrictMode && isEvalOrArgumentsIdentifier(name)) {
|
||||||
reportInvalidUseInStrictMode(name);
|
reportInvalidUseInStrictMode(name);
|
||||||
|
@ -4557,7 +4564,7 @@ var ts;
|
||||||
node.flags = flags;
|
node.flags = flags;
|
||||||
parseExpected(73 /* FunctionKeyword */);
|
parseExpected(73 /* FunctionKeyword */);
|
||||||
node.name = parseIdentifier();
|
node.name = parseIdentifier();
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
node.typeParameters = sig.typeParameters;
|
node.typeParameters = sig.typeParameters;
|
||||||
node.parameters = sig.parameters;
|
node.parameters = sig.parameters;
|
||||||
node.type = sig.type;
|
node.type = sig.type;
|
||||||
|
@ -4571,7 +4578,7 @@ var ts;
|
||||||
var node = createNode(117 /* Constructor */, pos);
|
var node = createNode(117 /* Constructor */, pos);
|
||||||
node.flags = flags;
|
node.flags = flags;
|
||||||
parseExpected(103 /* ConstructorKeyword */);
|
parseExpected(103 /* ConstructorKeyword */);
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
node.typeParameters = sig.typeParameters;
|
node.typeParameters = sig.typeParameters;
|
||||||
node.parameters = sig.parameters;
|
node.parameters = sig.parameters;
|
||||||
node.type = sig.type;
|
node.type = sig.type;
|
||||||
|
@ -4595,7 +4602,7 @@ var ts;
|
||||||
var method = createNode(116 /* Method */, pos);
|
var method = createNode(116 /* Method */, pos);
|
||||||
method.flags = flags;
|
method.flags = flags;
|
||||||
method.name = name;
|
method.name = name;
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
method.typeParameters = sig.typeParameters;
|
method.typeParameters = sig.typeParameters;
|
||||||
method.parameters = sig.parameters;
|
method.parameters = sig.parameters;
|
||||||
method.type = sig.type;
|
method.type = sig.type;
|
||||||
|
@ -4663,7 +4670,7 @@ var ts;
|
||||||
var node = createNode(kind, pos);
|
var node = createNode(kind, pos);
|
||||||
node.flags = flags;
|
node.flags = flags;
|
||||||
node.name = parsePropertyName();
|
node.name = parsePropertyName();
|
||||||
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */);
|
var sig = parseSignature(120 /* CallSignature */, 42 /* ColonToken */, false);
|
||||||
node.typeParameters = sig.typeParameters;
|
node.typeParameters = sig.typeParameters;
|
||||||
node.parameters = sig.parameters;
|
node.parameters = sig.parameters;
|
||||||
node.type = sig.type;
|
node.type = sig.type;
|
||||||
|
@ -5226,17 +5233,27 @@ var ts;
|
||||||
var start = refPos;
|
var start = refPos;
|
||||||
var length = refEnd - refPos;
|
var length = refEnd - refPos;
|
||||||
}
|
}
|
||||||
|
var diagnostic;
|
||||||
if (hasExtension(filename)) {
|
if (hasExtension(filename)) {
|
||||||
if (!ts.fileExtensionIs(filename, ".ts")) {
|
if (!ts.fileExtensionIs(filename, ".ts")) {
|
||||||
errors.push(ts.createFileDiagnostic(refFile, start, length, ts.Diagnostics.File_0_must_have_extension_ts_or_d_ts, filename));
|
diagnostic = ts.Diagnostics.File_0_must_have_extension_ts_or_d_ts;
|
||||||
}
|
}
|
||||||
else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {
|
else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {
|
||||||
errors.push(ts.createFileDiagnostic(refFile, start, length, ts.Diagnostics.File_0_not_found, filename));
|
diagnostic = ts.Diagnostics.File_0_not_found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) {
|
if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) {
|
||||||
errors.push(ts.createFileDiagnostic(refFile, start, length, ts.Diagnostics.File_0_not_found, filename + ".ts"));
|
diagnostic = ts.Diagnostics.File_0_not_found;
|
||||||
|
filename += ".ts";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (diagnostic) {
|
||||||
|
if (refFile) {
|
||||||
|
errors.push(ts.createFileDiagnostic(refFile, start, length, diagnostic, filename));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errors.push(ts.createCompilerDiagnostic(diagnostic, filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10702,11 +10719,13 @@ var ts;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (getDeclarationFlagsFromSymbol(sourceProp) & 32 /* Private */ || getDeclarationFlagsFromSymbol(targetProp) & 32 /* Private */) {
|
if (getDeclarationFlagsFromSymbol(sourceProp) & 32 /* Private */ || getDeclarationFlagsFromSymbol(targetProp) & 32 /* Private */) {
|
||||||
|
if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) {
|
||||||
if (reportErrors) {
|
if (reportErrors) {
|
||||||
reportError(ts.Diagnostics.Private_property_0_cannot_be_reimplemented, symbolToString(targetProp));
|
reportError(ts.Diagnostics.Private_property_0_cannot_be_reimplemented, symbolToString(targetProp));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors)) {
|
if (!isRelatedTo(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp), reportErrors)) {
|
||||||
if (reportErrors) {
|
if (reportErrors) {
|
||||||
reportError(ts.Diagnostics.Types_of_property_0_are_incompatible_Colon, symbolToString(targetProp));
|
reportError(ts.Diagnostics.Types_of_property_0_are_incompatible_Colon, symbolToString(targetProp));
|
||||||
|
|
|
@ -65,7 +65,8 @@ module ts {
|
||||||
symbolToString: symbolToString,
|
symbolToString: symbolToString,
|
||||||
getAugmentedPropertiesOfApparentType: getAugmentedPropertiesOfApparentType,
|
getAugmentedPropertiesOfApparentType: getAugmentedPropertiesOfApparentType,
|
||||||
getRootSymbol: getRootSymbol,
|
getRootSymbol: getRootSymbol,
|
||||||
getContextualType: getContextualType
|
getContextualType: getContextualType,
|
||||||
|
getFullyQualifiedName: getFullyQualifiedName
|
||||||
};
|
};
|
||||||
|
|
||||||
var undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined");
|
var undefinedSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "undefined");
|
||||||
|
@ -2951,6 +2952,7 @@ module ts {
|
||||||
var sourceFlags = getDeclarationFlagsFromSymbol(sourceProp);
|
var sourceFlags = getDeclarationFlagsFromSymbol(sourceProp);
|
||||||
var targetFlags = getDeclarationFlagsFromSymbol(targetProp);
|
var targetFlags = getDeclarationFlagsFromSymbol(targetProp);
|
||||||
if (sourceFlags & NodeFlags.Private || targetFlags & NodeFlags.Private) {
|
if (sourceFlags & NodeFlags.Private || targetFlags & NodeFlags.Private) {
|
||||||
|
if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) {
|
||||||
if (reportErrors) {
|
if (reportErrors) {
|
||||||
if (sourceFlags & NodeFlags.Private && targetFlags & NodeFlags.Private) {
|
if (sourceFlags & NodeFlags.Private && targetFlags & NodeFlags.Private) {
|
||||||
reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp));
|
reportError(Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp));
|
||||||
|
@ -2963,7 +2965,8 @@ module ts {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (targetFlags & NodeFlags.Protected) {
|
}
|
||||||
|
else if (targetFlags & NodeFlags.Protected) {
|
||||||
var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & SymbolFlags.Class;
|
var sourceDeclaredInClass = sourceProp.parent && sourceProp.parent.flags & SymbolFlags.Class;
|
||||||
var sourceClass = sourceDeclaredInClass ? <InterfaceType>getDeclaredTypeOfSymbol(sourceProp.parent) : undefined;
|
var sourceClass = sourceDeclaredInClass ? <InterfaceType>getDeclaredTypeOfSymbol(sourceProp.parent) : undefined;
|
||||||
var targetClass = <InterfaceType>getDeclaredTypeOfSymbol(targetProp.parent);
|
var targetClass = <InterfaceType>getDeclaredTypeOfSymbol(targetProp.parent);
|
||||||
|
@ -5254,8 +5257,7 @@ module ts {
|
||||||
var otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor;
|
var otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor;
|
||||||
var otherAccessor = <AccessorDeclaration>getDeclarationOfKind(node.symbol, otherKind);
|
var otherAccessor = <AccessorDeclaration>getDeclarationOfKind(node.symbol, otherKind);
|
||||||
if (otherAccessor) {
|
if (otherAccessor) {
|
||||||
var visibilityFlags = NodeFlags.Private | NodeFlags.Public | NodeFlags.Protected;
|
if (((node.flags & NodeFlags.AccessibilityModifier) !== (otherAccessor.flags & NodeFlags.AccessibilityModifier))) {
|
||||||
if (((node.flags & visibilityFlags) !== (otherAccessor.flags & visibilityFlags))) {
|
|
||||||
error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
|
error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6020,7 +6022,7 @@ module ts {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkLabelledStatement(node: LabelledStatement) {
|
function checkLabeledStatement(node: LabeledStatement) {
|
||||||
checkSourceElement(node.statement);
|
checkSourceElement(node.statement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6590,8 +6592,8 @@ module ts {
|
||||||
return checkWithStatement(<WithStatement>node);
|
return checkWithStatement(<WithStatement>node);
|
||||||
case SyntaxKind.SwitchStatement:
|
case SyntaxKind.SwitchStatement:
|
||||||
return checkSwitchStatement(<SwitchStatement>node);
|
return checkSwitchStatement(<SwitchStatement>node);
|
||||||
case SyntaxKind.LabelledStatement:
|
case SyntaxKind.LabeledStatement:
|
||||||
return checkLabelledStatement(<LabelledStatement>node);
|
return checkLabeledStatement(<LabeledStatement>node);
|
||||||
case SyntaxKind.ThrowStatement:
|
case SyntaxKind.ThrowStatement:
|
||||||
return checkThrowStatement(<ThrowStatement>node);
|
return checkThrowStatement(<ThrowStatement>node);
|
||||||
case SyntaxKind.TryStatement:
|
case SyntaxKind.TryStatement:
|
||||||
|
@ -6670,7 +6672,7 @@ module ts {
|
||||||
case SyntaxKind.SwitchStatement:
|
case SyntaxKind.SwitchStatement:
|
||||||
case SyntaxKind.CaseClause:
|
case SyntaxKind.CaseClause:
|
||||||
case SyntaxKind.DefaultClause:
|
case SyntaxKind.DefaultClause:
|
||||||
case SyntaxKind.LabelledStatement:
|
case SyntaxKind.LabeledStatement:
|
||||||
case SyntaxKind.ThrowStatement:
|
case SyntaxKind.ThrowStatement:
|
||||||
case SyntaxKind.TryStatement:
|
case SyntaxKind.TryStatement:
|
||||||
case SyntaxKind.TryBlock:
|
case SyntaxKind.TryBlock:
|
||||||
|
@ -7282,12 +7284,9 @@ module ts {
|
||||||
return target !== unknownSymbol && ((target.flags & SymbolFlags.Value) !== 0);
|
return target !== unknownSymbol && ((target.flags & SymbolFlags.Value) !== 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldEmitDeclarations() {
|
function hasSemanticErrors() {
|
||||||
// If the declaration emit and there are no errors being reported in program or by checker
|
// Return true if there is any semantic error in a file or globally
|
||||||
// declarations can be emitted
|
return getDiagnostics().length > 0 || getGlobalDiagnostics().length > 0;
|
||||||
return compilerOptions.declaration &&
|
|
||||||
!program.getDiagnostics().length &&
|
|
||||||
!getDiagnostics().length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isReferencedImportDeclaration(node: ImportDeclaration): boolean {
|
function isReferencedImportDeclaration(node: ImportDeclaration): boolean {
|
||||||
|
@ -7348,7 +7347,7 @@ module ts {
|
||||||
writeTypeToTextWriter(getReturnTypeOfSignature(signature), enclosingDeclaration, flags , writer);
|
writeTypeToTextWriter(getReturnTypeOfSignature(signature), enclosingDeclaration, flags , writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
function invokeEmitter() {
|
function invokeEmitter(targetSourceFile?: SourceFile) {
|
||||||
var resolver: EmitResolver = {
|
var resolver: EmitResolver = {
|
||||||
getProgram: () => program,
|
getProgram: () => program,
|
||||||
getLocalNameOfContainer: getLocalNameOfContainer,
|
getLocalNameOfContainer: getLocalNameOfContainer,
|
||||||
|
@ -7359,7 +7358,7 @@ module ts {
|
||||||
getNodeCheckFlags: getNodeCheckFlags,
|
getNodeCheckFlags: getNodeCheckFlags,
|
||||||
getEnumMemberValue: getEnumMemberValue,
|
getEnumMemberValue: getEnumMemberValue,
|
||||||
isTopLevelValueImportedViaEntityName: isTopLevelValueImportedViaEntityName,
|
isTopLevelValueImportedViaEntityName: isTopLevelValueImportedViaEntityName,
|
||||||
shouldEmitDeclarations: shouldEmitDeclarations,
|
hasSemanticErrors: hasSemanticErrors,
|
||||||
isDeclarationVisible: isDeclarationVisible,
|
isDeclarationVisible: isDeclarationVisible,
|
||||||
isImplementationOfOverload: isImplementationOfOverload,
|
isImplementationOfOverload: isImplementationOfOverload,
|
||||||
writeTypeAtLocation: writeTypeAtLocation,
|
writeTypeAtLocation: writeTypeAtLocation,
|
||||||
|
@ -7369,7 +7368,7 @@ module ts {
|
||||||
isImportDeclarationEntityNameReferenceDeclarationVisibile: isImportDeclarationEntityNameReferenceDeclarationVisibile
|
isImportDeclarationEntityNameReferenceDeclarationVisibile: isImportDeclarationEntityNameReferenceDeclarationVisibile
|
||||||
};
|
};
|
||||||
checkProgram();
|
checkProgram();
|
||||||
return emitFiles(resolver);
|
return emitFiles(resolver, targetSourceFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializeTypeChecker() {
|
function initializeTypeChecker() {
|
||||||
|
|
|
@ -407,7 +407,7 @@ module ts {
|
||||||
return normalizedPathComponents(path, rootLength);
|
return normalizedPathComponents(path, rootLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getNormalizedPathFromPathCompoments(pathComponents: string[]) {
|
export function getNormalizedPathFromPathComponents(pathComponents: string[]) {
|
||||||
if (pathComponents && pathComponents.length) {
|
if (pathComponents && pathComponents.length) {
|
||||||
return pathComponents[0] + pathComponents.slice(1).join(directorySeparator);
|
return pathComponents[0] + pathComponents.slice(1).join(directorySeparator);
|
||||||
}
|
}
|
||||||
|
@ -468,7 +468,7 @@ module ts {
|
||||||
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
|
var pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory);
|
||||||
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
|
var directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory);
|
||||||
if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") {
|
if (directoryComponents.length > 1 && directoryComponents[directoryComponents.length - 1] === "") {
|
||||||
// If the directory path given was of type test/cases/ then we really need components of directry to be only till its name
|
// If the directory path given was of type test/cases/ then we really need components of directory to be only till its name
|
||||||
// that is ["test", "cases", ""] needs to be actually ["test", "cases"]
|
// that is ["test", "cases", ""] needs to be actually ["test", "cases"]
|
||||||
directoryComponents.length--;
|
directoryComponents.length--;
|
||||||
}
|
}
|
||||||
|
@ -494,7 +494,7 @@ module ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cant find the relative path, get the absolute path
|
// Cant find the relative path, get the absolute path
|
||||||
var absolutePath = getNormalizedPathFromPathCompoments(pathComponents);
|
var absolutePath = getNormalizedPathFromPathComponents(pathComponents);
|
||||||
if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) {
|
if (isAbsolutePathAnUrl && isRootedDiskPath(absolutePath)) {
|
||||||
absolutePath = "file:///" + absolutePath;
|
absolutePath = "file:///" + absolutePath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,22 @@ module ts {
|
||||||
return indentStrings[1].length;
|
return indentStrings[1].length;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function emitFiles(resolver: EmitResolver): EmitResult {
|
export function shouldEmitToOwnFile(sourceFile: SourceFile, compilerOptions: CompilerOptions): boolean {
|
||||||
|
if (!(sourceFile.flags & NodeFlags.DeclarationFile)) {
|
||||||
|
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !fileExtensionIs(sourceFile.filename, ".js")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isExternalModuleOrDeclarationFile(sourceFile: SourceFile) {
|
||||||
|
return isExternalModule(sourceFile) || (sourceFile.flags & NodeFlags.DeclarationFile) !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// targetSourceFile is when users only want one file in entire project to be emitted. This is used in compilerOnSave feature
|
||||||
|
export function emitFiles(resolver: EmitResolver, targetSourceFile?: SourceFile): EmitResult {
|
||||||
var program = resolver.getProgram();
|
var program = resolver.getProgram();
|
||||||
var compilerHost = program.getCompilerHost();
|
var compilerHost = program.getCompilerHost();
|
||||||
var compilerOptions = program.getCompilerOptions();
|
var compilerOptions = program.getCompilerOptions();
|
||||||
|
@ -34,22 +49,14 @@ module ts {
|
||||||
var newLine = program.getCompilerHost().getNewLine();
|
var newLine = program.getCompilerHost().getNewLine();
|
||||||
|
|
||||||
function getSourceFilePathInNewDir(newDirPath: string, sourceFile: SourceFile) {
|
function getSourceFilePathInNewDir(newDirPath: string, sourceFile: SourceFile) {
|
||||||
var sourceFilePath = getNormalizedPathFromPathCompoments(getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory()));
|
var sourceFilePath = getNormalizedPathFromPathComponents(getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory()));
|
||||||
sourceFilePath = sourceFilePath.replace(program.getCommonSourceDirectory(), "");
|
sourceFilePath = sourceFilePath.replace(program.getCommonSourceDirectory(), "");
|
||||||
return combinePaths(newDirPath, sourceFilePath);
|
return combinePaths(newDirPath, sourceFilePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldEmitToOwnFile(sourceFile: SourceFile) {
|
|
||||||
if (!(sourceFile.flags & NodeFlags.DeclarationFile)) {
|
|
||||||
if ((isExternalModule(sourceFile) || !compilerOptions.out) && !fileExtensionIs(sourceFile.filename, ".js")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getOwnEmitOutputFilePath(sourceFile: SourceFile, extension: string) {
|
function getOwnEmitOutputFilePath(sourceFile: SourceFile, extension: string) {
|
||||||
if (program.getCompilerOptions().outDir) {
|
if (compilerOptions.outDir) {
|
||||||
var emitOutputFilePathWithoutExtension = getModuleNameFromFilename(getSourceFilePathInNewDir(program.getCompilerOptions().outDir, sourceFile));
|
var emitOutputFilePathWithoutExtension = getModuleNameFromFilename(getSourceFilePathInNewDir(compilerOptions.outDir, sourceFile));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var emitOutputFilePathWithoutExtension = getModuleNameFromFilename(sourceFile.filename);
|
var emitOutputFilePathWithoutExtension = getModuleNameFromFilename(sourceFile.filename);
|
||||||
|
@ -58,10 +65,6 @@ module ts {
|
||||||
return emitOutputFilePathWithoutExtension + extension;
|
return emitOutputFilePathWithoutExtension + extension;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isExternalModuleOrDeclarationFile(sourceFile: SourceFile) {
|
|
||||||
return isExternalModule(sourceFile) || (sourceFile.flags & NodeFlags.DeclarationFile) !== 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFirstConstructorWithBody(node: ClassDeclaration): ConstructorDeclaration {
|
function getFirstConstructorWithBody(node: ClassDeclaration): ConstructorDeclaration {
|
||||||
return forEach(node.members, member => {
|
return forEach(node.members, member => {
|
||||||
if (member.kind === SyntaxKind.Constructor && (<ConstructorDeclaration>member).body) {
|
if (member.kind === SyntaxKind.Constructor && (<ConstructorDeclaration>member).body) {
|
||||||
|
@ -781,8 +784,8 @@ module ts {
|
||||||
case SyntaxKind.ContinueStatement:
|
case SyntaxKind.ContinueStatement:
|
||||||
case SyntaxKind.ExportAssignment:
|
case SyntaxKind.ExportAssignment:
|
||||||
return false;
|
return false;
|
||||||
case SyntaxKind.LabelledStatement:
|
case SyntaxKind.LabeledStatement:
|
||||||
return (<LabelledStatement>node.parent).label === node;
|
return (<LabeledStatement>node.parent).label === node;
|
||||||
case SyntaxKind.CatchBlock:
|
case SyntaxKind.CatchBlock:
|
||||||
return (<CatchBlock>node.parent).variable === node;
|
return (<CatchBlock>node.parent).variable === node;
|
||||||
}
|
}
|
||||||
|
@ -1200,7 +1203,7 @@ module ts {
|
||||||
write(";");
|
write(";");
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitLabelledStatement(node: LabelledStatement) {
|
function emitLabelledStatement(node: LabeledStatement) {
|
||||||
emit(node.label);
|
emit(node.label);
|
||||||
write(": ");
|
write(": ");
|
||||||
emit(node.statement);
|
emit(node.statement);
|
||||||
|
@ -1431,7 +1434,7 @@ module ts {
|
||||||
|
|
||||||
function emitParameterPropertyAssignments(node: ConstructorDeclaration) {
|
function emitParameterPropertyAssignments(node: ConstructorDeclaration) {
|
||||||
forEach(node.parameters, param => {
|
forEach(node.parameters, param => {
|
||||||
if (param.flags & (NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected)) {
|
if (param.flags & NodeFlags.AccessibilityModifier) {
|
||||||
writeLine();
|
writeLine();
|
||||||
emitStart(param);
|
emitStart(param);
|
||||||
emitStart(param.name);
|
emitStart(param.name);
|
||||||
|
@ -2071,8 +2074,8 @@ module ts {
|
||||||
case SyntaxKind.CaseClause:
|
case SyntaxKind.CaseClause:
|
||||||
case SyntaxKind.DefaultClause:
|
case SyntaxKind.DefaultClause:
|
||||||
return emitCaseOrDefaultClause(<CaseOrDefaultClause>node);
|
return emitCaseOrDefaultClause(<CaseOrDefaultClause>node);
|
||||||
case SyntaxKind.LabelledStatement:
|
case SyntaxKind.LabeledStatement:
|
||||||
return emitLabelledStatement(<LabelledStatement>node);
|
return emitLabelledStatement(<LabeledStatement>node);
|
||||||
case SyntaxKind.ThrowStatement:
|
case SyntaxKind.ThrowStatement:
|
||||||
return emitThrowStatement(<ThrowStatement>node);
|
return emitThrowStatement(<ThrowStatement>node);
|
||||||
case SyntaxKind.TryStatement:
|
case SyntaxKind.TryStatement:
|
||||||
|
@ -2636,7 +2639,7 @@ module ts {
|
||||||
function emitParameterProperties(constructorDeclaration: ConstructorDeclaration) {
|
function emitParameterProperties(constructorDeclaration: ConstructorDeclaration) {
|
||||||
if (constructorDeclaration) {
|
if (constructorDeclaration) {
|
||||||
forEach(constructorDeclaration.parameters, param => {
|
forEach(constructorDeclaration.parameters, param => {
|
||||||
if (param.flags & (NodeFlags.Public | NodeFlags.Private | NodeFlags.Protected)) {
|
if (param.flags & NodeFlags.AccessibilityModifier) {
|
||||||
emitPropertyDeclaration(param);
|
emitPropertyDeclaration(param);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -3088,7 +3091,7 @@ module ts {
|
||||||
function writeReferencePath(referencedFile: SourceFile) {
|
function writeReferencePath(referencedFile: SourceFile) {
|
||||||
var declFileName = referencedFile.flags & NodeFlags.DeclarationFile
|
var declFileName = referencedFile.flags & NodeFlags.DeclarationFile
|
||||||
? referencedFile.filename // Declaration file, use declaration file name
|
? referencedFile.filename // Declaration file, use declaration file name
|
||||||
: shouldEmitToOwnFile(referencedFile)
|
: shouldEmitToOwnFile(referencedFile, compilerOptions)
|
||||||
? getOwnEmitOutputFilePath(referencedFile, ".d.ts") // Own output file so get the .d.ts file
|
? getOwnEmitOutputFilePath(referencedFile, ".d.ts") // Own output file so get the .d.ts file
|
||||||
: getModuleNameFromFilename(compilerOptions.out) + ".d.ts";// Global out file
|
: getModuleNameFromFilename(compilerOptions.out) + ".d.ts";// Global out file
|
||||||
|
|
||||||
|
@ -3110,7 +3113,7 @@ module ts {
|
||||||
|
|
||||||
// All the references that are not going to be part of same file
|
// All the references that are not going to be part of same file
|
||||||
if ((referencedFile.flags & NodeFlags.DeclarationFile) || // This is a declare file reference
|
if ((referencedFile.flags & NodeFlags.DeclarationFile) || // This is a declare file reference
|
||||||
shouldEmitToOwnFile(referencedFile) || // This is referenced file is emitting its own js file
|
shouldEmitToOwnFile(referencedFile, compilerOptions) || // This is referenced file is emitting its own js file
|
||||||
!addedGlobalFileReference) { // Or the global out file corresponding to this reference was not added
|
!addedGlobalFileReference) { // Or the global out file corresponding to this reference was not added
|
||||||
|
|
||||||
writeReferencePath(referencedFile);
|
writeReferencePath(referencedFile);
|
||||||
|
@ -3167,20 +3170,29 @@ module ts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var shouldEmitDeclarations = resolver.shouldEmitDeclarations();
|
var hasSemanticErrors = resolver.hasSemanticErrors();
|
||||||
|
|
||||||
function emitFile(jsFilePath: string, sourceFile?: SourceFile) {
|
function emitFile(jsFilePath: string, sourceFile?: SourceFile) {
|
||||||
emitJavaScript(jsFilePath, sourceFile);
|
emitJavaScript(jsFilePath, sourceFile);
|
||||||
if (shouldEmitDeclarations) {
|
if (!hasSemanticErrors && compilerOptions.declaration) {
|
||||||
emitDeclarations(jsFilePath, sourceFile);
|
emitDeclarations(jsFilePath, sourceFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (targetSourceFile === undefined) {
|
||||||
forEach(program.getSourceFiles(), sourceFile => {
|
forEach(program.getSourceFiles(), sourceFile => {
|
||||||
if (shouldEmitToOwnFile(sourceFile)) {
|
if (shouldEmitToOwnFile(sourceFile, compilerOptions)) {
|
||||||
var jsFilePath = getOwnEmitOutputFilePath(sourceFile, ".js");
|
var jsFilePath = getOwnEmitOutputFilePath(sourceFile, ".js");
|
||||||
emitFile(jsFilePath, sourceFile);
|
emitFile(jsFilePath, sourceFile);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Emit only one file specified in targetFilename. This is mainly used in compilerOnSave feature
|
||||||
|
var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, ".js");
|
||||||
|
emitFile(jsFilePath, targetSourceFile);
|
||||||
|
}
|
||||||
|
|
||||||
if (compilerOptions.out) {
|
if (compilerOptions.out) {
|
||||||
emitFile(compilerOptions.out);
|
emitFile(compilerOptions.out);
|
||||||
}
|
}
|
||||||
|
@ -3189,7 +3201,23 @@ module ts {
|
||||||
diagnostics.sort(compareDiagnostics);
|
diagnostics.sort(compareDiagnostics);
|
||||||
diagnostics = deduplicateSortedDiagnostics(diagnostics);
|
diagnostics = deduplicateSortedDiagnostics(diagnostics);
|
||||||
|
|
||||||
|
// Update returnCode if there is any EmitterError
|
||||||
|
var hasEmitterError = forEach(diagnostics, diagnostic => diagnostic.category === DiagnosticCategory.Error);
|
||||||
|
|
||||||
|
// Check and update returnCode for syntactic and semantic
|
||||||
|
var returnCode: EmitReturnStatus;
|
||||||
|
if (hasEmitterError) {
|
||||||
|
returnCode = EmitReturnStatus.EmitErrorsEncountered;
|
||||||
|
} else if (hasSemanticErrors && compilerOptions.declaration) {
|
||||||
|
returnCode = EmitReturnStatus.DeclarationGenerationSkipped;
|
||||||
|
} else if (hasSemanticErrors && !compilerOptions.declaration) {
|
||||||
|
returnCode = EmitReturnStatus.JSGeneratedWithSemanticErrors;
|
||||||
|
} else {
|
||||||
|
returnCode = EmitReturnStatus.Succeeded;
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
emitResultStatus: returnCode,
|
||||||
errors: diagnostics,
|
errors: diagnostics,
|
||||||
sourceMaps: sourceMapDataList
|
sourceMaps: sourceMapDataList
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,8 +50,8 @@ module ts {
|
||||||
return node.pos;
|
return node.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getTokenPosOfNode(node: Node): number {
|
export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile): number {
|
||||||
return skipTrivia(getSourceFileOfNode(node).text, node.pos);
|
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getSourceTextOfNodeFromSourceText(sourceText: string, node: Node): string {
|
export function getSourceTextOfNodeFromSourceText(sourceText: string, node: Node): string {
|
||||||
|
@ -307,9 +307,9 @@ module ts {
|
||||||
case SyntaxKind.DefaultClause:
|
case SyntaxKind.DefaultClause:
|
||||||
return child((<CaseOrDefaultClause>node).expression) ||
|
return child((<CaseOrDefaultClause>node).expression) ||
|
||||||
children((<CaseOrDefaultClause>node).statements);
|
children((<CaseOrDefaultClause>node).statements);
|
||||||
case SyntaxKind.LabelledStatement:
|
case SyntaxKind.LabeledStatement:
|
||||||
return child((<LabelledStatement>node).label) ||
|
return child((<LabeledStatement>node).label) ||
|
||||||
child((<LabelledStatement>node).statement);
|
child((<LabeledStatement>node).statement);
|
||||||
case SyntaxKind.ThrowStatement:
|
case SyntaxKind.ThrowStatement:
|
||||||
return child((<ThrowStatement>node).expression);
|
return child((<ThrowStatement>node).expression);
|
||||||
case SyntaxKind.TryStatement:
|
case SyntaxKind.TryStatement:
|
||||||
|
@ -373,7 +373,7 @@ module ts {
|
||||||
case SyntaxKind.SwitchStatement:
|
case SyntaxKind.SwitchStatement:
|
||||||
case SyntaxKind.CaseClause:
|
case SyntaxKind.CaseClause:
|
||||||
case SyntaxKind.DefaultClause:
|
case SyntaxKind.DefaultClause:
|
||||||
case SyntaxKind.LabelledStatement:
|
case SyntaxKind.LabeledStatement:
|
||||||
case SyntaxKind.TryStatement:
|
case SyntaxKind.TryStatement:
|
||||||
case SyntaxKind.TryBlock:
|
case SyntaxKind.TryBlock:
|
||||||
case SyntaxKind.CatchBlock:
|
case SyntaxKind.CatchBlock:
|
||||||
|
@ -487,6 +487,32 @@ module ts {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isStatement(n: Node): boolean {
|
||||||
|
switch(n.kind) {
|
||||||
|
case SyntaxKind.BreakStatement:
|
||||||
|
case SyntaxKind.ContinueStatement:
|
||||||
|
case SyntaxKind.DebuggerStatement:
|
||||||
|
case SyntaxKind.DoStatement:
|
||||||
|
case SyntaxKind.ExpressionStatement:
|
||||||
|
case SyntaxKind.EmptyStatement:
|
||||||
|
case SyntaxKind.ForInStatement:
|
||||||
|
case SyntaxKind.ForStatement:
|
||||||
|
case SyntaxKind.IfStatement:
|
||||||
|
case SyntaxKind.LabeledStatement:
|
||||||
|
case SyntaxKind.ReturnStatement:
|
||||||
|
case SyntaxKind.SwitchStatement:
|
||||||
|
case SyntaxKind.ThrowKeyword:
|
||||||
|
case SyntaxKind.TryStatement:
|
||||||
|
case SyntaxKind.VariableStatement:
|
||||||
|
case SyntaxKind.WhileStatement:
|
||||||
|
case SyntaxKind.WithStatement:
|
||||||
|
case SyntaxKind.ExportAssignment:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// True if the given identifier, string literal, or number literal is the name of a declaration node
|
// True if the given identifier, string literal, or number literal is the name of a declaration node
|
||||||
export function isDeclarationOrFunctionExpressionOrCatchVariableName(name: Node): boolean {
|
export function isDeclarationOrFunctionExpressionOrCatchVariableName(name: Node): boolean {
|
||||||
if (name.kind !== SyntaxKind.Identifier && name.kind !== SyntaxKind.StringLiteral && name.kind !== SyntaxKind.NumericLiteral) {
|
if (name.kind !== SyntaxKind.Identifier && name.kind !== SyntaxKind.StringLiteral && name.kind !== SyntaxKind.NumericLiteral) {
|
||||||
|
@ -1375,14 +1401,25 @@ module ts {
|
||||||
return finishNode(node);
|
return finishNode(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseSignature(kind: SyntaxKind, returnToken: SyntaxKind): ParsedSignature {
|
function parseSignature(kind: SyntaxKind, returnToken: SyntaxKind, returnTokenRequired: boolean): ParsedSignature {
|
||||||
if (kind === SyntaxKind.ConstructSignature) {
|
if (kind === SyntaxKind.ConstructSignature) {
|
||||||
parseExpected(SyntaxKind.NewKeyword);
|
parseExpected(SyntaxKind.NewKeyword);
|
||||||
}
|
}
|
||||||
var typeParameters = parseTypeParameters();
|
var typeParameters = parseTypeParameters();
|
||||||
var parameters = parseParameterList(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken);
|
var parameters = parseParameterList(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken);
|
||||||
checkParameterList(parameters);
|
checkParameterList(parameters);
|
||||||
var type = parseOptional(returnToken) ? parseType() : undefined;
|
|
||||||
|
var type: TypeNode;
|
||||||
|
|
||||||
|
if (returnTokenRequired) {
|
||||||
|
parseExpected(returnToken);
|
||||||
|
type = parseType();
|
||||||
|
}
|
||||||
|
else if (parseOptional(returnToken))
|
||||||
|
{
|
||||||
|
type = parseType();
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
typeParameters: typeParameters,
|
typeParameters: typeParameters,
|
||||||
parameters: parameters,
|
parameters: parameters,
|
||||||
|
@ -1446,7 +1483,7 @@ module ts {
|
||||||
|
|
||||||
function parseSignatureMember(kind: SyntaxKind, returnToken: SyntaxKind): SignatureDeclaration {
|
function parseSignatureMember(kind: SyntaxKind, returnToken: SyntaxKind): SignatureDeclaration {
|
||||||
var node = <SignatureDeclaration>createNode(kind);
|
var node = <SignatureDeclaration>createNode(kind);
|
||||||
var sig = parseSignature(kind, returnToken);
|
var sig = parseSignature(kind, returnToken, /* returnTokenRequired */ false);
|
||||||
node.typeParameters = sig.typeParameters;
|
node.typeParameters = sig.typeParameters;
|
||||||
node.parameters = sig.parameters;
|
node.parameters = sig.parameters;
|
||||||
node.type = sig.type;
|
node.type = sig.type;
|
||||||
|
@ -1519,7 +1556,7 @@ module ts {
|
||||||
}
|
}
|
||||||
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
|
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
|
||||||
node.kind = SyntaxKind.Method;
|
node.kind = SyntaxKind.Method;
|
||||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||||
(<MethodDeclaration>node).typeParameters = sig.typeParameters;
|
(<MethodDeclaration>node).typeParameters = sig.typeParameters;
|
||||||
(<MethodDeclaration>node).parameters = sig.parameters;
|
(<MethodDeclaration>node).parameters = sig.parameters;
|
||||||
(<MethodDeclaration>node).type = sig.type;
|
(<MethodDeclaration>node).type = sig.type;
|
||||||
|
@ -1591,7 +1628,7 @@ module ts {
|
||||||
function parseFunctionType(signatureKind: SyntaxKind): TypeLiteralNode {
|
function parseFunctionType(signatureKind: SyntaxKind): TypeLiteralNode {
|
||||||
var node = <TypeLiteralNode>createNode(SyntaxKind.TypeLiteral);
|
var node = <TypeLiteralNode>createNode(SyntaxKind.TypeLiteral);
|
||||||
var member = <SignatureDeclaration>createNode(signatureKind);
|
var member = <SignatureDeclaration>createNode(signatureKind);
|
||||||
var sig = parseSignature(signatureKind, SyntaxKind.EqualsGreaterThanToken);
|
var sig = parseSignature(signatureKind, SyntaxKind.EqualsGreaterThanToken, /* returnTokenRequired */ true);
|
||||||
member.typeParameters = sig.typeParameters;
|
member.typeParameters = sig.typeParameters;
|
||||||
member.parameters = sig.parameters;
|
member.parameters = sig.parameters;
|
||||||
member.type = sig.type;
|
member.type = sig.type;
|
||||||
|
@ -1850,7 +1887,7 @@ module ts {
|
||||||
var pos = getNodePos();
|
var pos = getNodePos();
|
||||||
|
|
||||||
if (triState === Tristate.True) {
|
if (triState === Tristate.True) {
|
||||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||||
|
|
||||||
// If we have an arrow, then try to parse the body.
|
// If we have an arrow, then try to parse the body.
|
||||||
// Even if not, try to parse if we have an opening brace, just in case we're in an error state.
|
// Even if not, try to parse if we have an opening brace, just in case we're in an error state.
|
||||||
|
@ -1953,7 +1990,7 @@ module ts {
|
||||||
|
|
||||||
function tryParseSignatureIfArrowOrBraceFollows(): ParsedSignature {
|
function tryParseSignatureIfArrowOrBraceFollows(): ParsedSignature {
|
||||||
return tryParse(() => {
|
return tryParse(() => {
|
||||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||||
|
|
||||||
// Parsing a signature isn't enough.
|
// Parsing a signature isn't enough.
|
||||||
// Parenthesized arrow signatures often look like other valid expressions.
|
// Parenthesized arrow signatures often look like other valid expressions.
|
||||||
|
@ -2295,7 +2332,7 @@ module ts {
|
||||||
var node = <PropertyDeclaration>createNode(SyntaxKind.PropertyAssignment);
|
var node = <PropertyDeclaration>createNode(SyntaxKind.PropertyAssignment);
|
||||||
node.name = parsePropertyName();
|
node.name = parsePropertyName();
|
||||||
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
|
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
|
||||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||||
var body = parseBody(/* ignoreMissingOpenBrace */ false);
|
var body = parseBody(/* ignoreMissingOpenBrace */ false);
|
||||||
// do not propagate property name as name for function expression
|
// do not propagate property name as name for function expression
|
||||||
// for scenarios like
|
// for scenarios like
|
||||||
|
@ -2395,7 +2432,7 @@ module ts {
|
||||||
var pos = getNodePos();
|
var pos = getNodePos();
|
||||||
parseExpected(SyntaxKind.FunctionKeyword);
|
parseExpected(SyntaxKind.FunctionKeyword);
|
||||||
var name = isIdentifier() ? parseIdentifier() : undefined;
|
var name = isIdentifier() ? parseIdentifier() : undefined;
|
||||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||||
var body = parseBody(/* ignoreMissingOpenBrace */ false);
|
var body = parseBody(/* ignoreMissingOpenBrace */ false);
|
||||||
if (name && isInStrictMode && isEvalOrArgumentsIdentifier(name)) {
|
if (name && isInStrictMode && isEvalOrArgumentsIdentifier(name)) {
|
||||||
// It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the
|
// It is a SyntaxError to use within strict mode code the identifiers eval or arguments as the
|
||||||
|
@ -2820,8 +2857,8 @@ module ts {
|
||||||
return isIdentifier() && lookAhead(() => nextToken() === SyntaxKind.ColonToken);
|
return isIdentifier() && lookAhead(() => nextToken() === SyntaxKind.ColonToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseLabelledStatement(): LabelledStatement {
|
function parseLabelledStatement(): LabeledStatement {
|
||||||
var node = <LabelledStatement>createNode(SyntaxKind.LabelledStatement);
|
var node = <LabeledStatement>createNode(SyntaxKind.LabeledStatement);
|
||||||
node.label = parseIdentifier();
|
node.label = parseIdentifier();
|
||||||
parseExpected(SyntaxKind.ColonToken);
|
parseExpected(SyntaxKind.ColonToken);
|
||||||
|
|
||||||
|
@ -3011,7 +3048,7 @@ module ts {
|
||||||
if (flags) node.flags = flags;
|
if (flags) node.flags = flags;
|
||||||
parseExpected(SyntaxKind.FunctionKeyword);
|
parseExpected(SyntaxKind.FunctionKeyword);
|
||||||
node.name = parseIdentifier();
|
node.name = parseIdentifier();
|
||||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||||
node.typeParameters = sig.typeParameters;
|
node.typeParameters = sig.typeParameters;
|
||||||
node.parameters = sig.parameters;
|
node.parameters = sig.parameters;
|
||||||
node.type = sig.type;
|
node.type = sig.type;
|
||||||
|
@ -3028,7 +3065,7 @@ module ts {
|
||||||
var node = <ConstructorDeclaration>createNode(SyntaxKind.Constructor, pos);
|
var node = <ConstructorDeclaration>createNode(SyntaxKind.Constructor, pos);
|
||||||
node.flags = flags;
|
node.flags = flags;
|
||||||
parseExpected(SyntaxKind.ConstructorKeyword);
|
parseExpected(SyntaxKind.ConstructorKeyword);
|
||||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||||
node.typeParameters = sig.typeParameters;
|
node.typeParameters = sig.typeParameters;
|
||||||
node.parameters = sig.parameters;
|
node.parameters = sig.parameters;
|
||||||
node.type = sig.type;
|
node.type = sig.type;
|
||||||
|
@ -3055,7 +3092,7 @@ module ts {
|
||||||
var method = <MethodDeclaration>createNode(SyntaxKind.Method, pos);
|
var method = <MethodDeclaration>createNode(SyntaxKind.Method, pos);
|
||||||
method.flags = flags;
|
method.flags = flags;
|
||||||
method.name = name;
|
method.name = name;
|
||||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||||
method.typeParameters = sig.typeParameters;
|
method.typeParameters = sig.typeParameters;
|
||||||
method.parameters = sig.parameters;
|
method.parameters = sig.parameters;
|
||||||
method.type = sig.type;
|
method.type = sig.type;
|
||||||
|
@ -3128,7 +3165,7 @@ module ts {
|
||||||
var node = <MethodDeclaration>createNode(kind, pos);
|
var node = <MethodDeclaration>createNode(kind, pos);
|
||||||
node.flags = flags;
|
node.flags = flags;
|
||||||
node.name = parsePropertyName();
|
node.name = parsePropertyName();
|
||||||
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
|
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken, /* returnTokenRequired */ false);
|
||||||
node.typeParameters = sig.typeParameters;
|
node.typeParameters = sig.typeParameters;
|
||||||
node.parameters = sig.parameters;
|
node.parameters = sig.parameters;
|
||||||
node.type = sig.type;
|
node.type = sig.type;
|
||||||
|
@ -3217,7 +3254,7 @@ module ts {
|
||||||
|
|
||||||
switch (modifierToken) {
|
switch (modifierToken) {
|
||||||
case SyntaxKind.PublicKeyword:
|
case SyntaxKind.PublicKeyword:
|
||||||
if (flags & NodeFlags.Public || flags & NodeFlags.Private || flags & NodeFlags.Protected) {
|
if (flags & NodeFlags.AccessibilityModifier) {
|
||||||
grammarErrorAtPos(modifierStart, modifierLength, Diagnostics.Accessibility_modifier_already_seen);
|
grammarErrorAtPos(modifierStart, modifierLength, Diagnostics.Accessibility_modifier_already_seen);
|
||||||
}
|
}
|
||||||
else if (flags & NodeFlags.Static) {
|
else if (flags & NodeFlags.Static) {
|
||||||
|
@ -3230,7 +3267,7 @@ module ts {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SyntaxKind.PrivateKeyword:
|
case SyntaxKind.PrivateKeyword:
|
||||||
if (flags & NodeFlags.Public || flags & NodeFlags.Private || flags & NodeFlags.Protected) {
|
if (flags & NodeFlags.AccessibilityModifier) {
|
||||||
grammarErrorAtPos(modifierStart, modifierLength, Diagnostics.Accessibility_modifier_already_seen);
|
grammarErrorAtPos(modifierStart, modifierLength, Diagnostics.Accessibility_modifier_already_seen);
|
||||||
}
|
}
|
||||||
else if (flags & NodeFlags.Static) {
|
else if (flags & NodeFlags.Static) {
|
||||||
|
@ -3819,17 +3856,28 @@ module ts {
|
||||||
var start = refPos;
|
var start = refPos;
|
||||||
var length = refEnd - refPos;
|
var length = refEnd - refPos;
|
||||||
}
|
}
|
||||||
|
var diagnostic: DiagnosticMessage;
|
||||||
if (hasExtension(filename)) {
|
if (hasExtension(filename)) {
|
||||||
if (!fileExtensionIs(filename, ".ts")) {
|
if (!fileExtensionIs(filename, ".ts")) {
|
||||||
errors.push(createFileDiagnostic(refFile, start, length, Diagnostics.File_0_must_have_extension_ts_or_d_ts, filename));
|
diagnostic = Diagnostics.File_0_must_have_extension_ts_or_d_ts;
|
||||||
}
|
}
|
||||||
else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {
|
else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {
|
||||||
errors.push(createFileDiagnostic(refFile, start, length, Diagnostics.File_0_not_found, filename));
|
diagnostic = Diagnostics.File_0_not_found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) {
|
if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) {
|
||||||
errors.push(createFileDiagnostic(refFile, start, length, Diagnostics.File_0_not_found, filename + ".ts"));
|
diagnostic = Diagnostics.File_0_not_found;
|
||||||
|
filename += ".ts";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diagnostic) {
|
||||||
|
if (refFile) {
|
||||||
|
errors.push(createFileDiagnostic(refFile, start, length, diagnostic, filename));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errors.push(createCompilerDiagnostic(diagnostic, filename));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3962,11 +4010,11 @@ module ts {
|
||||||
// Each file contributes into common source file path
|
// Each file contributes into common source file path
|
||||||
if (!(sourceFile.flags & NodeFlags.DeclarationFile)
|
if (!(sourceFile.flags & NodeFlags.DeclarationFile)
|
||||||
&& !fileExtensionIs(sourceFile.filename, ".js")) {
|
&& !fileExtensionIs(sourceFile.filename, ".js")) {
|
||||||
var sourcePathCompoments = getNormalizedPathComponents(sourceFile.filename, host.getCurrentDirectory());
|
var sourcePathComponents = getNormalizedPathComponents(sourceFile.filename, host.getCurrentDirectory());
|
||||||
sourcePathCompoments.pop(); // FileName is not part of directory
|
sourcePathComponents.pop(); // FileName is not part of directory
|
||||||
if (commonPathComponents) {
|
if (commonPathComponents) {
|
||||||
for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathCompoments.length); i++) {
|
for (var i = 0; i < Math.min(commonPathComponents.length, sourcePathComponents.length); i++) {
|
||||||
if (commonPathComponents[i] !== sourcePathCompoments[i]) {
|
if (commonPathComponents[i] !== sourcePathComponents[i]) {
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
errors.push(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
|
errors.push(createCompilerDiagnostic(Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files));
|
||||||
return;
|
return;
|
||||||
|
@ -3979,18 +4027,18 @@ module ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the fileComponent path completely matched and less than already found update the length
|
// If the fileComponent path completely matched and less than already found update the length
|
||||||
if (sourcePathCompoments.length < commonPathComponents.length) {
|
if (sourcePathComponents.length < commonPathComponents.length) {
|
||||||
commonPathComponents.length = sourcePathCompoments.length;
|
commonPathComponents.length = sourcePathComponents.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// first file
|
// first file
|
||||||
commonPathComponents = sourcePathCompoments;
|
commonPathComponents = sourcePathComponents;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
commonSourceDirectory = getNormalizedPathFromPathCompoments(commonPathComponents);
|
commonSourceDirectory = getNormalizedPathFromPathComponents(commonPathComponents);
|
||||||
if (commonSourceDirectory) {
|
if (commonSourceDirectory) {
|
||||||
// Make sure directory path ends with directory separator so this string can directly
|
// Make sure directory path ends with directory separator so this string can directly
|
||||||
// used to replace with "" to get the relative path of the source file and the relative path doesn't
|
// used to replace with "" to get the relative path of the source file and the relative path doesn't
|
||||||
|
|
|
@ -184,7 +184,7 @@ module ts {
|
||||||
SwitchStatement,
|
SwitchStatement,
|
||||||
CaseClause,
|
CaseClause,
|
||||||
DefaultClause,
|
DefaultClause,
|
||||||
LabelledStatement,
|
LabeledStatement,
|
||||||
ThrowStatement,
|
ThrowStatement,
|
||||||
TryStatement,
|
TryStatement,
|
||||||
TryBlock,
|
TryBlock,
|
||||||
|
@ -222,7 +222,9 @@ module ts {
|
||||||
FirstTypeNode = TypeReference,
|
FirstTypeNode = TypeReference,
|
||||||
LastTypeNode = TupleType,
|
LastTypeNode = TupleType,
|
||||||
FirstPunctuation = OpenBraceToken,
|
FirstPunctuation = OpenBraceToken,
|
||||||
LastPunctuation = CaretEqualsToken
|
LastPunctuation = CaretEqualsToken,
|
||||||
|
FirstToken = EndOfFileToken,
|
||||||
|
LastToken = StringKeyword
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum NodeFlags {
|
export enum NodeFlags {
|
||||||
|
@ -238,7 +240,8 @@ module ts {
|
||||||
Synthetic = 0x00000200, // Synthetic node (for full fidelity)
|
Synthetic = 0x00000200, // Synthetic node (for full fidelity)
|
||||||
DeclarationFile = 0x00000400, // Node is a .d.ts file
|
DeclarationFile = 0x00000400, // Node is a .d.ts file
|
||||||
|
|
||||||
Modifier = Export | Ambient | Public | Private | Protected | Static
|
Modifier = Export | Ambient | Public | Private | Protected | Static,
|
||||||
|
AccessibilityModifier = Public | Private | Protected
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Node extends TextRange {
|
export interface Node extends TextRange {
|
||||||
|
@ -465,7 +468,7 @@ module ts {
|
||||||
statements: NodeArray<Statement>;
|
statements: NodeArray<Statement>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LabelledStatement extends Statement {
|
export interface LabeledStatement extends Statement {
|
||||||
label: Identifier;
|
label: Identifier;
|
||||||
statement: Statement;
|
statement: Statement;
|
||||||
}
|
}
|
||||||
|
@ -575,7 +578,7 @@ module ts {
|
||||||
export interface SourceMapData {
|
export interface SourceMapData {
|
||||||
/** Where the sourcemap file is written */
|
/** Where the sourcemap file is written */
|
||||||
sourceMapFilePath: string;
|
sourceMapFilePath: string;
|
||||||
/** source map url written in the js file */
|
/** source map URL written in the js file */
|
||||||
jsSourceMappingURL: string;
|
jsSourceMappingURL: string;
|
||||||
/** Source map's file field - js file name*/
|
/** Source map's file field - js file name*/
|
||||||
sourceMapFile: string;
|
sourceMapFile: string;
|
||||||
|
@ -594,7 +597,17 @@ module ts {
|
||||||
sourceMapDecodedMappings: SourceMapSpan[];
|
sourceMapDecodedMappings: SourceMapSpan[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return code used by getEmitOutput function to indicate status of the function
|
||||||
|
export enum EmitReturnStatus {
|
||||||
|
Succeeded = 0, // All outputs generated as requested (.js, .map, .d.ts), no errors reported
|
||||||
|
AllOutputGenerationSkipped = 1, // No .js generated because of syntax errors, or compiler options errors, nothing generated
|
||||||
|
JSGeneratedWithSemanticErrors = 2, // .js and .map generated with semantic errors
|
||||||
|
DeclarationGenerationSkipped = 3, // .d.ts generation skipped because of semantic errors or declaration emitter specific errors; Output .js with semantic errors
|
||||||
|
EmitErrorsEncountered = 4 // Emitter errors occurred during emitting process
|
||||||
|
}
|
||||||
|
|
||||||
export interface EmitResult {
|
export interface EmitResult {
|
||||||
|
emitResultStatus: EmitReturnStatus;
|
||||||
errors: Diagnostic[];
|
errors: Diagnostic[];
|
||||||
sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps
|
sourceMaps: SourceMapData[]; // Array of sourceMapData if compiler emitted sourcemaps
|
||||||
}
|
}
|
||||||
|
@ -608,7 +621,7 @@ module ts {
|
||||||
getSymbolCount(): number;
|
getSymbolCount(): number;
|
||||||
getTypeCount(): number;
|
getTypeCount(): number;
|
||||||
checkProgram(): void;
|
checkProgram(): void;
|
||||||
emitFiles(): EmitResult;
|
emitFiles(targetSourceFile?: SourceFile): EmitResult;
|
||||||
getParentOfSymbol(symbol: Symbol): Symbol;
|
getParentOfSymbol(symbol: Symbol): Symbol;
|
||||||
getTypeOfSymbol(symbol: Symbol): Type;
|
getTypeOfSymbol(symbol: Symbol): Type;
|
||||||
getPropertiesOfType(type: Type): Symbol[];
|
getPropertiesOfType(type: Type): Symbol[];
|
||||||
|
@ -622,6 +635,7 @@ module ts {
|
||||||
getApparentType(type: Type): ApparentType;
|
getApparentType(type: Type): ApparentType;
|
||||||
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
|
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
|
||||||
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
|
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
|
||||||
|
getFullyQualifiedName(symbol: Symbol): string;
|
||||||
getAugmentedPropertiesOfApparentType(type: Type): Symbol[];
|
getAugmentedPropertiesOfApparentType(type: Type): Symbol[];
|
||||||
getRootSymbol(symbol: Symbol): Symbol;
|
getRootSymbol(symbol: Symbol): Symbol;
|
||||||
getContextualType(node: Node): Type;
|
getContextualType(node: Node): Type;
|
||||||
|
@ -666,7 +680,7 @@ module ts {
|
||||||
isTopLevelValueImportedViaEntityName(node: ImportDeclaration): boolean;
|
isTopLevelValueImportedViaEntityName(node: ImportDeclaration): boolean;
|
||||||
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
getNodeCheckFlags(node: Node): NodeCheckFlags;
|
||||||
getEnumMemberValue(node: EnumMember): number;
|
getEnumMemberValue(node: EnumMember): number;
|
||||||
shouldEmitDeclarations(): boolean;
|
hasSemanticErrors(): boolean;
|
||||||
isDeclarationVisible(node: Declaration): boolean;
|
isDeclarationVisible(node: Declaration): boolean;
|
||||||
isImplementationOfOverload(node: FunctionDeclaration): boolean;
|
isImplementationOfOverload(node: FunctionDeclaration): boolean;
|
||||||
writeTypeAtLocation(location: Node, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter): void;
|
writeTypeAtLocation(location: Node, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: TextWriter): void;
|
||||||
|
@ -989,6 +1003,15 @@ module ts {
|
||||||
AMD,
|
AMD,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface LineAndCharacter {
|
||||||
|
line: number;
|
||||||
|
/*
|
||||||
|
* This value denotes the character position in line and is different from the 'column' because of tab characters.
|
||||||
|
*/
|
||||||
|
character: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
export enum ScriptTarget {
|
export enum ScriptTarget {
|
||||||
ES3,
|
ES3,
|
||||||
ES5,
|
ES5,
|
||||||
|
|
|
@ -156,10 +156,7 @@ class CompilerBaselineRunner extends RunnerBase {
|
||||||
return file.writeByteOrderMark ? "\u00EF\u00BB\u00BF" : "";
|
return file.writeByteOrderMark ? "\u00EF\u00BB\u00BF" : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getErrorBaseline(toBeCompiled: { unitName: string; content: string }[],
|
function getErrorBaseline(toBeCompiled: { unitName: string; content: string }[], otherFiles: { unitName: string; content: string }[], result: Harness.Compiler.CompilerResult) {
|
||||||
otherFiles: { unitName: string; content: string }[],
|
|
||||||
result: Harness.Compiler.CompilerResult
|
|
||||||
) {
|
|
||||||
return Harness.Compiler.getErrorBaseline(toBeCompiled.concat(otherFiles), result.errors);
|
return Harness.Compiler.getErrorBaseline(toBeCompiled.concat(otherFiles), result.errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -122,9 +122,71 @@ module FourSlash {
|
||||||
return s.replace(/[&<>"'\/]/g, ch => entityMap[ch]);
|
return s.replace(/[&<>"'\/]/g, ch => entityMap[ch]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name of testcase metadata including ts.CompilerOptions properties that will be used by globalOptions
|
||||||
|
// To add additional option, add property into the testOptMetadataNames, refer the property in either globalMetadataNames or fileMetadataNames
|
||||||
|
// Add cases into convertGlobalOptionsToCompilationsSettings function for the compiler to acknowledge such option from meta data
|
||||||
|
var testOptMetadataNames = {
|
||||||
|
baselineFile: 'BaselineFile',
|
||||||
|
declaration: 'declaration',
|
||||||
|
emitThisFile: 'emitThisFile', // This flag is used for testing getEmitOutput feature. It allows test-cases to indicate what file to be output in multiple files project
|
||||||
|
filename: 'Filename',
|
||||||
|
mapRoot: 'mapRoot',
|
||||||
|
module: 'module',
|
||||||
|
out: 'out',
|
||||||
|
outDir: 'outDir',
|
||||||
|
sourceMap: 'sourceMap',
|
||||||
|
sourceRoot: 'sourceRoot',
|
||||||
|
};
|
||||||
|
|
||||||
// List of allowed metadata names
|
// List of allowed metadata names
|
||||||
var fileMetadataNames = ['Filename'];
|
var fileMetadataNames = [testOptMetadataNames.filename, testOptMetadataNames.emitThisFile];
|
||||||
var globalMetadataNames = ['Module', 'Target', 'BaselineFile']; // Note: Only BaselineFile is actually supported at the moment
|
var globalMetadataNames = [testOptMetadataNames.baselineFile, testOptMetadataNames.declaration,
|
||||||
|
testOptMetadataNames.mapRoot, testOptMetadataNames.module, testOptMetadataNames.out,
|
||||||
|
testOptMetadataNames.outDir, testOptMetadataNames.sourceMap, testOptMetadataNames.sourceRoot]
|
||||||
|
|
||||||
|
function convertGlobalOptionsToCompilationSettings(globalOptions: { [idx: string]: string }): ts.CompilationSettings {
|
||||||
|
var settings: ts.CompilationSettings = {};
|
||||||
|
// Convert all property in globalOptions into ts.CompilationSettings
|
||||||
|
for (var prop in globalOptions) {
|
||||||
|
if (globalOptions.hasOwnProperty(prop)) {
|
||||||
|
switch (prop) {
|
||||||
|
case testOptMetadataNames.declaration:
|
||||||
|
settings.generateDeclarationFiles = true;
|
||||||
|
break;
|
||||||
|
case testOptMetadataNames.mapRoot:
|
||||||
|
settings.mapRoot = globalOptions[prop];
|
||||||
|
break;
|
||||||
|
case testOptMetadataNames.module:
|
||||||
|
// create appropriate external module target for CompilationSettings
|
||||||
|
switch (globalOptions[prop]) {
|
||||||
|
case "AMD":
|
||||||
|
settings.moduleGenTarget = ts.ModuleGenTarget.Asynchronous;
|
||||||
|
break;
|
||||||
|
case "CommonJS":
|
||||||
|
settings.moduleGenTarget = ts.ModuleGenTarget.Synchronous;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
settings.moduleGenTarget = ts.ModuleGenTarget.Unspecified;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case testOptMetadataNames.out:
|
||||||
|
settings.outFileOption = globalOptions[prop];
|
||||||
|
break;
|
||||||
|
case testOptMetadataNames.outDir:
|
||||||
|
settings.outDirOption = globalOptions[prop];
|
||||||
|
break;
|
||||||
|
case testOptMetadataNames.sourceMap:
|
||||||
|
settings.mapSourceFiles = true;
|
||||||
|
break;
|
||||||
|
case testOptMetadataNames.sourceRoot:
|
||||||
|
settings.sourceRoot = globalOptions[prop];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
export var currentTestState: TestState = null;
|
export var currentTestState: TestState = null;
|
||||||
|
|
||||||
|
@ -199,11 +261,15 @@ module FourSlash {
|
||||||
private scenarioActions: string[] = [];
|
private scenarioActions: string[] = [];
|
||||||
private taoInvalidReason: string = null;
|
private taoInvalidReason: string = null;
|
||||||
|
|
||||||
|
|
||||||
constructor(public testData: FourSlashData) {
|
constructor(public testData: FourSlashData) {
|
||||||
// Initialize the language service with all the scripts
|
// Initialize the language service with all the scripts
|
||||||
this.cancellationToken = new TestCancellationToken();
|
this.cancellationToken = new TestCancellationToken();
|
||||||
this.languageServiceShimHost = new Harness.LanguageService.TypeScriptLS(this.cancellationToken);
|
this.languageServiceShimHost = new Harness.LanguageService.TypeScriptLS(this.cancellationToken);
|
||||||
|
|
||||||
|
var compilationSettings = convertGlobalOptionsToCompilationSettings(this.testData.globalOptions);
|
||||||
|
this.languageServiceShimHost.setCompilationSettings(compilationSettings);
|
||||||
|
|
||||||
var inputFiles: { unitName: string; content: string }[] = [];
|
var inputFiles: { unitName: string; content: string }[] = [];
|
||||||
|
|
||||||
testData.files.forEach(file => {
|
testData.files.forEach(file => {
|
||||||
|
@ -832,6 +898,44 @@ module FourSlash {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private validate(name: string, expected: string, actual: string) {
|
||||||
|
if (expected && expected !== actual) {
|
||||||
|
throw new Error("Expected " + name + " '" + expected + "'. Got '" + actual + "' instead.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public verifyRenameInfoSucceeded(displayName?: string, fullDisplayName?: string, kind?: string, kindModifiers?: string) {
|
||||||
|
var renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition);
|
||||||
|
if (!renameInfo.canRename) {
|
||||||
|
throw new Error("Rename did not succeed");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.validate("displayName", displayName, renameInfo.displayName);
|
||||||
|
this.validate("fullDisplayName", fullDisplayName, renameInfo.fullDisplayName);
|
||||||
|
this.validate("kind", kind, renameInfo.kind);
|
||||||
|
this.validate("kindModifiers", kindModifiers, renameInfo.kindModifiers);
|
||||||
|
|
||||||
|
if (this.getRanges().length !== 1) {
|
||||||
|
throw new Error("Expected a single range to be selected in the test file.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var expectedRange = this.getRanges()[0];
|
||||||
|
if (renameInfo.triggerSpan.start() !== expectedRange.start ||
|
||||||
|
renameInfo.triggerSpan.end() !== expectedRange.end) {
|
||||||
|
throw new Error("Expected triggerSpan [" + expectedRange.start + "," + expectedRange.end + "). Got [" +
|
||||||
|
renameInfo.triggerSpan.start() + "," + renameInfo.triggerSpan.end() + ") instead.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public verifyRenameInfoFailed(message?: string) {
|
||||||
|
var renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition);
|
||||||
|
if (renameInfo.canRename) {
|
||||||
|
throw new Error("Rename was expected to fail");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.validate("error", message, renameInfo.localizedErrorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
//private getFormalParameter() {
|
//private getFormalParameter() {
|
||||||
// var help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition);
|
// var help = this.languageService.getSignatureHelpItems(this.activeFile.fileName, this.currentCaretPosition);
|
||||||
// return help.formal;
|
// return help.formal;
|
||||||
|
@ -876,7 +980,7 @@ module FourSlash {
|
||||||
|
|
||||||
Harness.Baseline.runBaseline(
|
Harness.Baseline.runBaseline(
|
||||||
"Breakpoint Locations for " + this.activeFile.fileName,
|
"Breakpoint Locations for " + this.activeFile.fileName,
|
||||||
this.testData.globalOptions['BaselineFile'],
|
this.testData.globalOptions[testOptMetadataNames.baselineFile],
|
||||||
() => {
|
() => {
|
||||||
var fileLength = this.languageServiceShimHost.getScriptSnapshot(this.activeFile.fileName).getLength();
|
var fileLength = this.languageServiceShimHost.getScriptSnapshot(this.activeFile.fileName).getLength();
|
||||||
var resultString = "";
|
var resultString = "";
|
||||||
|
@ -888,6 +992,48 @@ module FourSlash {
|
||||||
true /* run immediately */);
|
true /* run immediately */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public baselineGetEmitOutput() {
|
||||||
|
this.taoInvalidReason = 'baselineGetEmitOutput impossible';
|
||||||
|
// Find file to be emitted
|
||||||
|
var emitFiles: FourSlashFile[] = []; // List of FourSlashFile that has emitThisFile flag on
|
||||||
|
|
||||||
|
var allFourSlashFiles = this.testData.files;
|
||||||
|
for (var idx = 0; idx < allFourSlashFiles.length; ++idx) {
|
||||||
|
var file = allFourSlashFiles[idx];
|
||||||
|
if (file.fileOptions[testOptMetadataNames.emitThisFile]) {
|
||||||
|
// Find a file with the flag emitThisFile turned on
|
||||||
|
emitFiles.push(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there is not emiThisFile flag specified in the test file, throw an error
|
||||||
|
if (emitFiles.length === 0) {
|
||||||
|
throw new Error("No emitThisFile is specified in the test file");
|
||||||
|
}
|
||||||
|
|
||||||
|
Harness.Baseline.runBaseline(
|
||||||
|
"Generate getEmitOutput baseline : " + emitFiles.join(" "),
|
||||||
|
this.testData.globalOptions[testOptMetadataNames.baselineFile],
|
||||||
|
() => {
|
||||||
|
var resultString = "";
|
||||||
|
// Loop through all the emittedFiles and emit them one by one
|
||||||
|
emitFiles.forEach(emitFile => {
|
||||||
|
var emitOutput = this.languageService.getEmitOutput(emitFile.fileName);
|
||||||
|
var emitOutputStatus = emitOutput.emitOutputStatus;
|
||||||
|
// Print emitOutputStatus in readable format
|
||||||
|
resultString += "EmitOutputStatus : " + ts.EmitReturnStatus[emitOutputStatus];
|
||||||
|
resultString += "\n";
|
||||||
|
emitOutput.outputFiles.forEach((outputFile, idx, array) => {
|
||||||
|
var filename = "Filename : " + outputFile.name + "\n";
|
||||||
|
resultString = resultString + filename + outputFile.text;
|
||||||
|
});
|
||||||
|
resultString += "\n";
|
||||||
|
});
|
||||||
|
return resultString;
|
||||||
|
},
|
||||||
|
true /* run immediately */);
|
||||||
|
}
|
||||||
|
|
||||||
public printBreakpointLocation(pos: number) {
|
public printBreakpointLocation(pos: number) {
|
||||||
Harness.IO.log(this.getBreakpointStatementLocation(pos));
|
Harness.IO.log(this.getBreakpointStatementLocation(pos));
|
||||||
}
|
}
|
||||||
|
@ -1198,7 +1344,7 @@ module FourSlash {
|
||||||
|
|
||||||
private applyEdits(fileName: string, edits: ts.TextChange[], isFormattingEdit = false): number {
|
private applyEdits(fileName: string, edits: ts.TextChange[], isFormattingEdit = false): number {
|
||||||
// We get back a set of edits, but langSvc.editScript only accepts one at a time. Use this to keep track
|
// We get back a set of edits, but langSvc.editScript only accepts one at a time. Use this to keep track
|
||||||
// of the incremental offest from each edit to the next. Assumption is that these edit ranges don't overlap
|
// of the incremental offset from each edit to the next. Assumption is that these edit ranges don't overlap
|
||||||
var runningOffset = 0;
|
var runningOffset = 0;
|
||||||
edits = edits.sort((a, b) => a.span.start() - b.span.start());
|
edits = edits.sort((a, b) => a.span.start() - b.span.start());
|
||||||
// Get a snapshot of the content of the file so we can make sure any formatting edits didn't destroy non-whitespace characters
|
// Get a snapshot of the content of the file so we can make sure any formatting edits didn't destroy non-whitespace characters
|
||||||
|
@ -1275,7 +1421,7 @@ module FourSlash {
|
||||||
|
|
||||||
var definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
var definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||||
if (!definitions || !definitions.length) {
|
if (!definitions || !definitions.length) {
|
||||||
throw new Error('goToDefinition failed - expected to at least one defintion location but got 0');
|
throw new Error('goToDefinition failed - expected to at least one definition location but got 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (definitionIndex >= definitions.length) {
|
if (definitionIndex >= definitions.length) {
|
||||||
|
@ -1295,10 +1441,10 @@ module FourSlash {
|
||||||
var foundDefinitions = definitions && definitions.length;
|
var foundDefinitions = definitions && definitions.length;
|
||||||
|
|
||||||
if (foundDefinitions && negative) {
|
if (foundDefinitions && negative) {
|
||||||
throw new Error('goToDefinition - expected to 0 defintion locations but got ' + definitions.length);
|
throw new Error('goToDefinition - expected to 0 definition locations but got ' + definitions.length);
|
||||||
}
|
}
|
||||||
else if (!foundDefinitions && !negative) {
|
else if (!foundDefinitions && !negative) {
|
||||||
throw new Error('goToDefinition - expected to at least one defintion location but got 0');
|
throw new Error('goToDefinition - expected to at least one definition location but got 0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1412,7 +1558,7 @@ module FourSlash {
|
||||||
|
|
||||||
Harness.Baseline.runBaseline(
|
Harness.Baseline.runBaseline(
|
||||||
"Name OrDottedNameSpans for " + this.activeFile.fileName,
|
"Name OrDottedNameSpans for " + this.activeFile.fileName,
|
||||||
this.testData.globalOptions['BaselineFile'],
|
this.testData.globalOptions[testOptMetadataNames.baselineFile],
|
||||||
() => {
|
() => {
|
||||||
var fileLength = this.languageServiceShimHost.getScriptSnapshot(this.activeFile.fileName).getLength();
|
var fileLength = this.languageServiceShimHost.getScriptSnapshot(this.activeFile.fileName).getLength();
|
||||||
var resultString = "";
|
var resultString = "";
|
||||||
|
@ -1428,6 +1574,46 @@ module FourSlash {
|
||||||
Harness.IO.log(this.getNameOrDottedNameSpan(pos));
|
Harness.IO.log(this.getNameOrDottedNameSpan(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private verifyClassifications(expected: { classificationType: string; text: string }[], actual: ts.ClassifiedSpan[]) {
|
||||||
|
if (actual.length !== expected.length) {
|
||||||
|
throw new Error('verifySyntacticClassification failed - expected total classifications to be ' + expected.length + ', but was ' + actual.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < expected.length; i++) {
|
||||||
|
var expectedClassification = expected[i];
|
||||||
|
var actualClassification = actual[i];
|
||||||
|
|
||||||
|
var expectedType: string = (<any>ts.ClassificationTypeNames)[expectedClassification.classificationType];
|
||||||
|
if (expectedType !== actualClassification.classificationType) {
|
||||||
|
throw new Error('verifySyntacticClassification failed - expected classifications type to be ' +
|
||||||
|
expectedType + ', but was ' +
|
||||||
|
actualClassification.classificationType);
|
||||||
|
}
|
||||||
|
|
||||||
|
var actualSpan = actualClassification.textSpan;
|
||||||
|
var actualText = this.activeFile.content.substr(actualSpan.start(), actualSpan.length());
|
||||||
|
if (expectedClassification.text !== actualText) {
|
||||||
|
throw new Error('verifySyntacticClassification failed - expected classificatied text to be ' +
|
||||||
|
expectedClassification.text + ', but was ' +
|
||||||
|
actualText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public verifySemanticClassifications(expected: { classificationType: string; text: string }[]) {
|
||||||
|
var actual = this.languageService.getSemanticClassifications(this.activeFile.fileName,
|
||||||
|
new TypeScript.TextSpan(0, this.activeFile.content.length));
|
||||||
|
|
||||||
|
this.verifyClassifications(expected, actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
public verifySyntacticClassifications(expected: { classificationType: string; text: string }[]) {
|
||||||
|
var actual = this.languageService.getSyntacticClassifications(this.activeFile.fileName,
|
||||||
|
new TypeScript.TextSpan(0, this.activeFile.content.length));
|
||||||
|
|
||||||
|
this.verifyClassifications(expected, actual);
|
||||||
|
}
|
||||||
|
|
||||||
public verifyOutliningSpans(spans: TextSpan[]) {
|
public verifyOutliningSpans(spans: TextSpan[]) {
|
||||||
this.taoInvalidReason = 'verifyOutliningSpans NYI';
|
this.taoInvalidReason = 'verifyOutliningSpans NYI';
|
||||||
|
|
||||||
|
@ -2013,12 +2199,12 @@ module FourSlash {
|
||||||
// Comment line, check for global/file @options and record them
|
// Comment line, check for global/file @options and record them
|
||||||
var match = optionRegex.exec(line.substr(2));
|
var match = optionRegex.exec(line.substr(2));
|
||||||
if (match) {
|
if (match) {
|
||||||
var globalNameIndex = globalMetadataNames.indexOf(match[1]);
|
var globalMetadataNamesIndex = globalMetadataNames.indexOf(match[1]);
|
||||||
var fileNameIndex = fileMetadataNames.indexOf(match[1]);
|
var fileMetadataNamesIndex = fileMetadataNames.indexOf(match[1]);
|
||||||
if (globalNameIndex === -1) {
|
if (globalMetadataNamesIndex === -1) {
|
||||||
if (fileNameIndex === -1) {
|
if (fileMetadataNamesIndex === -1) {
|
||||||
throw new Error('Unrecognized metadata name "' + match[1] + '". Available global metadata names are: ' + globalMetadataNames.join(', ') + '; file metadata names are: ' + fileMetadataNames.join(', '));
|
throw new Error('Unrecognized metadata name "' + match[1] + '". Available global metadata names are: ' + globalMetadataNames.join(', ') + '; file metadata names are: ' + fileMetadataNames.join(', '));
|
||||||
} else {
|
} else if (fileMetadataNamesIndex === fileMetadataNames.indexOf(testOptMetadataNames.filename)) {
|
||||||
// Found an @Filename directive, if this is not the first then create a new subfile
|
// Found an @Filename directive, if this is not the first then create a new subfile
|
||||||
if (currentFileContent) {
|
if (currentFileContent) {
|
||||||
var file = parseFileContent(currentFileContent, currentFileName, markerMap, markers, ranges);
|
var file = parseFileContent(currentFileContent, currentFileName, markerMap, markers, ranges);
|
||||||
|
@ -2035,8 +2221,15 @@ module FourSlash {
|
||||||
|
|
||||||
currentFileName = 'tests/cases/fourslash/' + match[2];
|
currentFileName = 'tests/cases/fourslash/' + match[2];
|
||||||
currentFileOptions[match[1]] = match[2];
|
currentFileOptions[match[1]] = match[2];
|
||||||
|
} else {
|
||||||
|
// Add other fileMetadata flag
|
||||||
|
currentFileOptions[match[1]] = match[2];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Check if the match is already existed in the global options
|
||||||
|
if (opts[match[1]] !== undefined) {
|
||||||
|
throw new Error("Global Option : '" + match[1] + "' is already existed");
|
||||||
|
}
|
||||||
opts[match[1]] = match[2];
|
opts[match[1]] = match[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -807,9 +807,7 @@ module Harness {
|
||||||
return errorOutput;
|
return errorOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[],
|
export function getErrorBaseline(inputFiles: { unitName: string; content: string }[], diagnostics: HarnessDiagnostic[]) {
|
||||||
diagnostics: HarnessDiagnostic[]
|
|
||||||
) {
|
|
||||||
|
|
||||||
var outputLines: string[] = [];
|
var outputLines: string[] = [];
|
||||||
// Count up all the errors we find so we don't miss any
|
// Count up all the errors we find so we don't miss any
|
||||||
|
@ -820,13 +818,13 @@ module Harness {
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.map(s => s.length > 0 && s.charAt(s.length - 1) === '\r' ? s.substr(0, s.length - 1) : s)
|
.map(s => s.length > 0 && s.charAt(s.length - 1) === '\r' ? s.substr(0, s.length - 1) : s)
|
||||||
.filter(s => s.length > 0)
|
.filter(s => s.length > 0)
|
||||||
.map(s => '!!! ' + s);
|
.map(s => '!!! ' + error.category + " TS" + error.code + ": " + s);
|
||||||
errLines.forEach(e => outputLines.push(e));
|
errLines.forEach(e => outputLines.push(e));
|
||||||
|
|
||||||
totalErrorsReported++;
|
totalErrorsReported++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report glovbal errors:
|
// Report global errors
|
||||||
var globalErrors = diagnostics.filter(err => !err.filename);
|
var globalErrors = diagnostics.filter(err => !err.filename);
|
||||||
globalErrors.forEach(err => outputErrorText(err));
|
globalErrors.forEach(err => outputErrorText(err));
|
||||||
|
|
||||||
|
@ -896,7 +894,8 @@ module Harness {
|
||||||
// Verify we didn't miss any errors in total
|
// Verify we didn't miss any errors in total
|
||||||
assert.equal(totalErrorsReported, diagnostics.length, 'total number of errors');
|
assert.equal(totalErrorsReported, diagnostics.length, 'total number of errors');
|
||||||
|
|
||||||
return outputLines.join('\r\n');
|
return minimalDiagnosticsToString(diagnostics) +
|
||||||
|
sys.newLine + sys.newLine + outputLines.join('\r\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Delete?
|
/* TODO: Delete?
|
||||||
|
@ -1016,7 +1015,7 @@ module Harness {
|
||||||
}
|
}
|
||||||
|
|
||||||
export module TestCaseParser {
|
export module TestCaseParser {
|
||||||
/** all the necesarry information to set the right compiler settings */
|
/** all the necessary information to set the right compiler settings */
|
||||||
export interface CompilerSetting {
|
export interface CompilerSetting {
|
||||||
flag: string;
|
flag: string;
|
||||||
value: string;
|
value: string;
|
||||||
|
|
|
@ -134,6 +134,7 @@ module Harness.LanguageService {
|
||||||
private ls: ts.LanguageServiceShim = null;
|
private ls: ts.LanguageServiceShim = null;
|
||||||
|
|
||||||
private fileNameToScript: ts.Map<ScriptInfo> = {};
|
private fileNameToScript: ts.Map<ScriptInfo> = {};
|
||||||
|
private settings: ts.CompilationSettings = {};
|
||||||
|
|
||||||
constructor(private cancellationToken: ts.CancellationToken = CancellationToken.None) {
|
constructor(private cancellationToken: ts.CancellationToken = CancellationToken.None) {
|
||||||
}
|
}
|
||||||
|
@ -199,13 +200,21 @@ module Harness.LanguageService {
|
||||||
|
|
||||||
/// Returns json for Tools.CompilationSettings
|
/// Returns json for Tools.CompilationSettings
|
||||||
public getCompilationSettings(): string {
|
public getCompilationSettings(): string {
|
||||||
return JSON.stringify({}); // i.e. default settings
|
return JSON.stringify(this.settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCancellationToken(): ts.CancellationToken {
|
public getCancellationToken(): ts.CancellationToken {
|
||||||
return this.cancellationToken;
|
return this.cancellationToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getCurrentDirectory(): string {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public getDefaultLibFilename(): string {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
public getScriptFileNames(): string {
|
public getScriptFileNames(): string {
|
||||||
var fileNames: string[] = [];
|
var fileNames: string[] = [];
|
||||||
ts.forEachKey(this.fileNameToScript, (fileName) => { fileNames.push(fileName); });
|
ts.forEachKey(this.fileNameToScript, (fileName) => { fileNames.push(fileName); });
|
||||||
|
@ -236,6 +245,14 @@ module Harness.LanguageService {
|
||||||
return this.ls;
|
return this.ls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setCompilationSettings(settings: ts.CompilationSettings) {
|
||||||
|
for (var key in settings) {
|
||||||
|
if (settings.hasOwnProperty(key)) {
|
||||||
|
this.settings[key] = settings[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Return a new instance of the classifier service shim */
|
/** Return a new instance of the classifier service shim */
|
||||||
public getClassifier(): ts.ClassifierShim {
|
public getClassifier(): ts.ClassifierShim {
|
||||||
return new TypeScript.Services.TypeScriptServicesFactory().createClassifierShim(this);
|
return new TypeScript.Services.TypeScriptServicesFactory().createClassifierShim(this);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
// Test case is json of below type in tests/cases/project/
|
// Test case is json of below type in tests/cases/project/
|
||||||
interface ProjectRunnerTestCase {
|
interface ProjectRunnerTestCase {
|
||||||
scenario: string;
|
scenario: string;
|
||||||
projectRoot: string; // project where it lives - this also is the current dictory when compiling
|
projectRoot: string; // project where it lives - this also is the current directory when compiling
|
||||||
inputFiles: string[]; // list of input files to be given to program
|
inputFiles: string[]; // list of input files to be given to program
|
||||||
out?: string; // --out
|
out?: string; // --out
|
||||||
outDir?: string; // --outDir
|
outDir?: string; // --outDir
|
||||||
|
@ -22,7 +22,7 @@ interface ProjectRunnerTestCase {
|
||||||
interface ProjectRunnerTestCaseResolutionInfo extends ProjectRunnerTestCase {
|
interface ProjectRunnerTestCaseResolutionInfo extends ProjectRunnerTestCase {
|
||||||
// Apart from actual test case the results of the resolution
|
// Apart from actual test case the results of the resolution
|
||||||
resolvedInputFiles: string[]; // List of files that were asked to read by compiler
|
resolvedInputFiles: string[]; // List of files that were asked to read by compiler
|
||||||
emittedFiles: string[]; // List of files that wre emitted by the compiler
|
emittedFiles: string[]; // List of files that were emitted by the compiler
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BatchCompileProjectTestCaseEmittedFile extends Harness.Compiler.GeneratedFile {
|
interface BatchCompileProjectTestCaseEmittedFile extends Harness.Compiler.GeneratedFile {
|
||||||
|
@ -69,7 +69,7 @@ class ProjectRunner extends RunnerBase {
|
||||||
testCase = <ProjectRunnerTestCase>JSON.parse(testFileText);
|
testCase = <ProjectRunnerTestCase>JSON.parse(testFileText);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
assert(false, "Testcase: " + testCaseFileName + " doesnt not contain valid json format: " + e.message);
|
assert(false, "Testcase: " + testCaseFileName + " does not contain valid json format: " + e.message);
|
||||||
}
|
}
|
||||||
var testCaseJustName = testCaseFileName.replace(/^.*[\\\/]/, '').replace(/\.json/, "");
|
var testCaseJustName = testCaseFileName.replace(/^.*[\\\/]/, '').replace(/\.json/, "");
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ class ProjectRunner extends RunnerBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
// When test case output goes to tests/baselines/local/projectOutput/testCaseName/moduleKind/
|
// When test case output goes to tests/baselines/local/projectOutput/testCaseName/moduleKind/
|
||||||
// We have these two separate locations because when compairing baselines the baseline verifier will delete the existing file
|
// We have these two separate locations because when comparing baselines the baseline verifier will delete the existing file
|
||||||
// so even if it was created by compiler in that location, the file will be deleted by verified before we can read it
|
// so even if it was created by compiler in that location, the file will be deleted by verified before we can read it
|
||||||
// so lets keep these two locations separate
|
// so lets keep these two locations separate
|
||||||
function getProjectOutputFolder(filename: string, moduleKind: ts.ModuleKind) {
|
function getProjectOutputFolder(filename: string, moduleKind: ts.ModuleKind) {
|
||||||
|
@ -228,7 +228,7 @@ class ProjectRunner extends RunnerBase {
|
||||||
|
|
||||||
var diskRelativeName = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, diskFileName, getCurrentDirectory(), false);
|
var diskRelativeName = ts.getRelativePathToDirectoryOrUrl(testCase.projectRoot, diskFileName, getCurrentDirectory(), false);
|
||||||
if (ts.isRootedDiskPath(diskRelativeName) || diskRelativeName.substr(0, 3) === "../") {
|
if (ts.isRootedDiskPath(diskRelativeName) || diskRelativeName.substr(0, 3) === "../") {
|
||||||
// If the generated output file recides in the parent folder or is rooted path,
|
// If the generated output file resides in the parent folder or is rooted path,
|
||||||
// we need to instead create files that can live in the project reference folder
|
// we need to instead create files that can live in the project reference folder
|
||||||
// but make sure extension of these files matches with the filename the compiler asked to write
|
// but make sure extension of these files matches with the filename the compiler asked to write
|
||||||
diskRelativeName = "diskFile" + nonSubfolderDiskFiles++ +
|
diskRelativeName = "diskFile" + nonSubfolderDiskFiles++ +
|
||||||
|
@ -299,10 +299,8 @@ class ProjectRunner extends RunnerBase {
|
||||||
return { unitName: sourceFile.filename, content: sourceFile.text };
|
return { unitName: sourceFile.filename, content: sourceFile.text };
|
||||||
});
|
});
|
||||||
var diagnostics = ts.map(compilerResult.errors, error => Harness.Compiler.getMinimalDiagnostic(error));
|
var diagnostics = ts.map(compilerResult.errors, error => Harness.Compiler.getMinimalDiagnostic(error));
|
||||||
var errors = Harness.Compiler.minimalDiagnosticsToString(diagnostics);
|
|
||||||
errors += sys.newLine + sys.newLine + Harness.Compiler.getErrorBaseline(inputFiles, diagnostics);
|
|
||||||
|
|
||||||
return errors;
|
return Harness.Compiler.getErrorBaseline(inputFiles, diagnostics);
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName, () => {
|
describe('Compiling project for ' + testCase.scenario + ': testcase ' + testCaseFileName, () => {
|
||||||
|
|
|
@ -152,9 +152,7 @@ module RWC {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Harness.Compiler.minimalDiagnosticsToString(compilerResult.errors) +
|
return Harness.Compiler.getErrorBaseline(inputFiles.concat(otherFiles), compilerResult.errors);
|
||||||
sys.newLine + sys.newLine +
|
|
||||||
Harness.Compiler.getErrorBaseline(inputFiles.concat(otherFiles), compilerResult.errors);
|
|
||||||
}, false, baselineOpts);
|
}, false, baselineOpts);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,8 @@ class TypeWriterWalker {
|
||||||
case ts.SyntaxKind.ContinueStatement:
|
case ts.SyntaxKind.ContinueStatement:
|
||||||
case ts.SyntaxKind.BreakStatement:
|
case ts.SyntaxKind.BreakStatement:
|
||||||
return (<ts.BreakOrContinueStatement>parent).label === identifier;
|
return (<ts.BreakOrContinueStatement>parent).label === identifier;
|
||||||
case ts.SyntaxKind.LabelledStatement:
|
case ts.SyntaxKind.LabeledStatement:
|
||||||
return (<ts.LabelledStatement>parent).label === identifier;
|
return (<ts.LabeledStatement>parent).label === identifier;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -798,7 +798,6 @@ module TypeScript.Services.Breakpoints {
|
||||||
var container = Syntax.containingNode(varDeclarationNode);
|
var container = Syntax.containingNode(varDeclarationNode);
|
||||||
var varDeclarationSyntax = <TypeScript.VariableDeclarationSyntax>varDeclarationNode;
|
var varDeclarationSyntax = <TypeScript.VariableDeclarationSyntax>varDeclarationNode;
|
||||||
var varDeclarators = varDeclarationSyntax.variableDeclarators;
|
var varDeclarators = varDeclarationSyntax.variableDeclarators;
|
||||||
var varDeclaratorsCount = childCount(varDeclarators); // varDeclarators has to be non null because its checked in canHaveBreakpoint
|
|
||||||
|
|
||||||
if (container && container.kind() == TypeScript.SyntaxKind.VariableStatement) {
|
if (container && container.kind() == TypeScript.SyntaxKind.VariableStatement) {
|
||||||
return this.breakpointSpanOfVariableStatement(container);
|
return this.breakpointSpanOfVariableStatement(container);
|
||||||
|
|
|
@ -36,5 +36,4 @@
|
||||||
///<reference path='indentationNodeContextPool.ts' />
|
///<reference path='indentationNodeContextPool.ts' />
|
||||||
///<reference path='indentationTrackingWalker.ts' />
|
///<reference path='indentationTrackingWalker.ts' />
|
||||||
///<reference path='multipleTokenIndenter.ts' />
|
///<reference path='multipleTokenIndenter.ts' />
|
||||||
///<reference path='singleTokenIndenter.ts' />
|
|
||||||
///<reference path='formatter.ts' />
|
///<reference path='formatter.ts' />
|
|
@ -1,46 +0,0 @@
|
||||||
//
|
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
|
|
||||||
///<reference path='formatting.ts' />
|
|
||||||
|
|
||||||
module TypeScript.Services.Formatting {
|
|
||||||
export class SingleTokenIndenter extends IndentationTrackingWalker {
|
|
||||||
private indentationAmount: number = null;
|
|
||||||
private indentationPosition: number;
|
|
||||||
|
|
||||||
constructor(indentationPosition: number, sourceUnit: SourceUnitSyntax, snapshot: ITextSnapshot, indentFirstToken: boolean, options: FormattingOptions) {
|
|
||||||
super(new TextSpan(indentationPosition, 1), sourceUnit, snapshot, indentFirstToken, options);
|
|
||||||
|
|
||||||
this.indentationPosition = indentationPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static getIndentationAmount(position: number, sourceUnit: SourceUnitSyntax, snapshot: ITextSnapshot, options: FormattingOptions): number {
|
|
||||||
var walker = new SingleTokenIndenter(position, sourceUnit, snapshot, true, options);
|
|
||||||
visitNodeOrToken(walker, sourceUnit);
|
|
||||||
return walker.indentationAmount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public indentToken(token: ISyntaxToken, indentationAmount: number, commentIndentationAmount: number): void {
|
|
||||||
// Compute an indentation string for this token
|
|
||||||
if (token.fullWidth() === 0 || (this.indentationPosition - this.position() < token.leadingTriviaWidth())) {
|
|
||||||
// The position is in the leading trivia, use comment indentation
|
|
||||||
this.indentationAmount = commentIndentationAmount;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.indentationAmount = indentationAmount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
522
src/services/formatting/smartIndenter.ts
Normal file
522
src/services/formatting/smartIndenter.ts
Normal file
|
@ -0,0 +1,522 @@
|
||||||
|
///<reference path='..\services.ts' />
|
||||||
|
|
||||||
|
module ts.formatting {
|
||||||
|
export module SmartIndenter {
|
||||||
|
|
||||||
|
export function getIndentation(position: number, sourceFile: SourceFile, options: TypeScript.FormattingOptions): number {
|
||||||
|
if (position > sourceFile.text.length) {
|
||||||
|
return 0; // past EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
var precedingToken = findPrecedingToken(position, sourceFile);
|
||||||
|
if (!precedingToken) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// no indentation in string \regex literals
|
||||||
|
if ((precedingToken.kind === SyntaxKind.StringLiteral || precedingToken.kind === SyntaxKind.RegularExpressionLiteral) &&
|
||||||
|
precedingToken.getStart(sourceFile) <= position &&
|
||||||
|
precedingToken.end > position) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
var lineAtPosition = sourceFile.getLineAndCharacterFromPosition(position).line;
|
||||||
|
|
||||||
|
if (precedingToken.kind === SyntaxKind.CommaToken && precedingToken.parent.kind !== SyntaxKind.BinaryExpression) {
|
||||||
|
// previous token is comma that separates items in list - find the previous item and try to derive indentation from it
|
||||||
|
var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options);
|
||||||
|
if (actualIndentation !== -1) {
|
||||||
|
return actualIndentation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// try to find node that can contribute to indentation and includes 'position' starting from 'precedingToken'
|
||||||
|
// if such node is found - compute initial indentation for 'position' inside this node
|
||||||
|
var previous: Node;
|
||||||
|
var current = precedingToken;
|
||||||
|
var currentStart: LineAndCharacter;
|
||||||
|
var indentationDelta: number;
|
||||||
|
|
||||||
|
while (current) {
|
||||||
|
if (positionBelongsToNode(current, position, sourceFile) && nodeContentIsIndented(current, previous)) {
|
||||||
|
currentStart = getStartLineAndCharacterForNode(current, sourceFile);
|
||||||
|
|
||||||
|
if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) {
|
||||||
|
indentationDelta = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
indentationDelta = lineAtPosition !== currentStart.line ? options.indentSpaces : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if current node is a list item - if yes, take indentation from it
|
||||||
|
var actualIndentation = getActualIndentationForListItem(current, sourceFile, options);
|
||||||
|
if (actualIndentation !== -1) {
|
||||||
|
return actualIndentation;
|
||||||
|
}
|
||||||
|
|
||||||
|
previous = current;
|
||||||
|
current = current.parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!current) {
|
||||||
|
// no parent was found - return 0 to be indented on the level of SourceFile
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var parent: Node = current.parent;
|
||||||
|
var parentStart: LineAndCharacter;
|
||||||
|
|
||||||
|
// walk upwards and collect indentations for pairs of parent-child nodes
|
||||||
|
// indentation is not added if parent and child nodes start on the same line or if parent is IfStatement and child starts on the same line with 'else clause'
|
||||||
|
while (parent) {
|
||||||
|
// check if current node is a list item - if yes, take indentation from it
|
||||||
|
var actualIndentation = getActualIndentationForListItem(current, sourceFile, options);
|
||||||
|
if (actualIndentation !== -1) {
|
||||||
|
return actualIndentation + indentationDelta;
|
||||||
|
}
|
||||||
|
|
||||||
|
parentStart = sourceFile.getLineAndCharacterFromPosition(parent.getStart(sourceFile));
|
||||||
|
var parentAndChildShareLine =
|
||||||
|
parentStart.line === currentStart.line ||
|
||||||
|
childStartsOnTheSameLineWithElseInIfStatement(parent, current, currentStart.line, sourceFile);
|
||||||
|
|
||||||
|
// try to fetch actual indentation for current node from source text
|
||||||
|
var actualIndentation = getActualIndentationForNode(current, parent, currentStart, parentAndChildShareLine, sourceFile, options);
|
||||||
|
if (actualIndentation !== -1) {
|
||||||
|
return actualIndentation + indentationDelta;
|
||||||
|
}
|
||||||
|
|
||||||
|
// increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line
|
||||||
|
if (nodeContentIsIndented(parent, current) && !parentAndChildShareLine) {
|
||||||
|
indentationDelta += options.indentSpaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
current = parent;
|
||||||
|
currentStart = parentStart;
|
||||||
|
parent = current.parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return indentationDelta;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function returns -1 if indentation cannot be determined
|
||||||
|
*/
|
||||||
|
function getActualIndentationForListItemBeforeComma(commaToken: Node, sourceFile: SourceFile, options: TypeScript.FormattingOptions): number {
|
||||||
|
// previous token is comma that separates items in list - find the previous item and try to derive indentation from it
|
||||||
|
var itemInfo = findPrecedingListItem(commaToken);
|
||||||
|
return deriveActualIndentationFromList(itemInfo.list.getChildren(), itemInfo.listItemIndex, sourceFile, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Function returns -1 if actual indentation for node should not be used (i.e because node is nested expression)
|
||||||
|
*/
|
||||||
|
function getActualIndentationForNode(current: Node,
|
||||||
|
parent: Node,
|
||||||
|
currentLineAndChar: LineAndCharacter,
|
||||||
|
parentAndChildShareLine: boolean,
|
||||||
|
sourceFile: SourceFile,
|
||||||
|
options: TypeScript.FormattingOptions): number {
|
||||||
|
|
||||||
|
// actual indentation is used for statements\declarations if one of cases below is true:
|
||||||
|
// - parent is SourceFile - by default immediate children of SourceFile are not indented except when user indents them manually
|
||||||
|
// - parent and child are not on the same line
|
||||||
|
var useActualIndentation =
|
||||||
|
(isDeclaration(current) || isStatement(current)) &&
|
||||||
|
(parent.kind === SyntaxKind.SourceFile || !parentAndChildShareLine);
|
||||||
|
|
||||||
|
if (!useActualIndentation) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken: Node, current: Node, lineAtPosition: number, sourceFile: SourceFile): boolean {
|
||||||
|
var nextToken = findNextToken(precedingToken, current);
|
||||||
|
if (!nextToken) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nextToken.kind === SyntaxKind.OpenBraceToken) {
|
||||||
|
// open braces are always indented at the parent level
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (nextToken.kind === SyntaxKind.CloseBraceToken) {
|
||||||
|
// close braces are indented at the parent level if they are located on the same line with cursor
|
||||||
|
// this means that if new line will be added at $ position, this case will be indented
|
||||||
|
// class A {
|
||||||
|
// $
|
||||||
|
// }
|
||||||
|
/// and this one - not
|
||||||
|
// class A {
|
||||||
|
// $}
|
||||||
|
|
||||||
|
var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line;
|
||||||
|
return lineAtPosition === nextTokenStartLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getStartLineAndCharacterForNode(n: Node, sourceFile: SourceFile): LineAndCharacter {
|
||||||
|
return sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile));
|
||||||
|
}
|
||||||
|
|
||||||
|
function findPrecedingListItem(commaToken: Node): { listItemIndex: number; list: Node } {
|
||||||
|
// CommaToken node is synthetic and thus will be stored in SyntaxList, however parent of the CommaToken points to the container of the SyntaxList skipping the list.
|
||||||
|
// In order to find the preceding list item we first need to locate SyntaxList itself and then search for the position of CommaToken
|
||||||
|
var syntaxList = forEach(commaToken.parent.getChildren(), c => {
|
||||||
|
// find syntax list that covers the span of CommaToken
|
||||||
|
if (c.kind == SyntaxKind.SyntaxList && c.pos <= commaToken.end && c.end >= commaToken.end) {
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Debug.assert(syntaxList);
|
||||||
|
|
||||||
|
var children = syntaxList.getChildren();
|
||||||
|
var commaIndex = indexOf(children, commaToken);
|
||||||
|
Debug.assert(commaIndex !== -1 && commaIndex !== 0);
|
||||||
|
|
||||||
|
return {
|
||||||
|
listItemIndex: commaIndex - 1,
|
||||||
|
list: syntaxList
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean {
|
||||||
|
return candidate.end > position || !isCompletedNode(candidate, sourceFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
function childStartsOnTheSameLineWithElseInIfStatement(parent: Node, child: Node, childStartLine: number, sourceFile: SourceFile): boolean {
|
||||||
|
if (parent.kind === SyntaxKind.IfStatement && (<IfStatement>parent).elseStatement === child) {
|
||||||
|
var elseKeyword = forEach(parent.getChildren(), c => c.kind === SyntaxKind.ElseKeyword && c);
|
||||||
|
Debug.assert(elseKeyword);
|
||||||
|
|
||||||
|
var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line;
|
||||||
|
return elseKeywordStartLine === childStartLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getActualIndentationForListItem(node: Node, sourceFile: SourceFile, options: TypeScript.FormattingOptions): number {
|
||||||
|
if (node.parent) {
|
||||||
|
switch (node.parent.kind) {
|
||||||
|
case SyntaxKind.TypeReference:
|
||||||
|
if ((<TypeReferenceNode>node.parent).typeArguments) {
|
||||||
|
return getActualIndentationFromList((<TypeReferenceNode>node.parent).typeArguments);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SyntaxKind.ObjectLiteral:
|
||||||
|
return getActualIndentationFromList((<ObjectLiteral>node.parent).properties);
|
||||||
|
case SyntaxKind.TypeLiteral:
|
||||||
|
return getActualIndentationFromList((<TypeLiteralNode>node.parent).members);
|
||||||
|
case SyntaxKind.ArrayLiteral:
|
||||||
|
return getActualIndentationFromList((<ArrayLiteral>node.parent).elements);
|
||||||
|
case SyntaxKind.FunctionDeclaration:
|
||||||
|
case SyntaxKind.FunctionExpression:
|
||||||
|
case SyntaxKind.ArrowFunction:
|
||||||
|
case SyntaxKind.Method:
|
||||||
|
case SyntaxKind.CallSignature:
|
||||||
|
case SyntaxKind.ConstructSignature:
|
||||||
|
if ((<SignatureDeclaration>node.parent).typeParameters && node.end < (<SignatureDeclaration>node.parent).typeParameters.end) {
|
||||||
|
return getActualIndentationFromList((<SignatureDeclaration>node.parent).typeParameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getActualIndentationFromList((<SignatureDeclaration>node.parent).parameters);
|
||||||
|
case SyntaxKind.NewExpression:
|
||||||
|
case SyntaxKind.CallExpression:
|
||||||
|
if ((<CallExpression>node.parent).typeArguments && node.end < (<CallExpression>node.parent).typeArguments.end) {
|
||||||
|
return getActualIndentationFromList((<CallExpression>node.parent).typeArguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getActualIndentationFromList((<CallExpression>node.parent).arguments);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
function getActualIndentationFromList(list: Node[]): number {
|
||||||
|
var index = indexOf(list, node);
|
||||||
|
return index !== -1 ? deriveActualIndentationFromList(list, index, sourceFile, options) : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function deriveActualIndentationFromList(list: Node[], index: number, sourceFile: SourceFile, options: TypeScript.FormattingOptions): number {
|
||||||
|
Debug.assert(index >= 0 && index < list.length);
|
||||||
|
var node = list[index];
|
||||||
|
|
||||||
|
// walk toward the start of the list starting from current node and check if the line is the same for all items.
|
||||||
|
// if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i]
|
||||||
|
var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile);
|
||||||
|
for (var i = index - 1; i >= 0; --i) {
|
||||||
|
if (list[i].kind === SyntaxKind.CommaToken) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// skip list items that ends on the same line with the current list element
|
||||||
|
var prevEndLine = sourceFile.getLineAndCharacterFromPosition(list[i].end).line;
|
||||||
|
if (prevEndLine !== lineAndCharacter.line) {
|
||||||
|
return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
lineAndCharacter = getStartLineAndCharacterForNode(list[i], sourceFile);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter: LineAndCharacter, sourceFile: SourceFile, options: TypeScript.FormattingOptions): number {
|
||||||
|
var lineStart = sourceFile.getPositionFromLineAndCharacter(lineAndCharacter.line, 1);
|
||||||
|
var column = 0;
|
||||||
|
for (var i = 0; i < lineAndCharacter.character; ++i) {
|
||||||
|
var charCode = sourceFile.text.charCodeAt(lineStart + i);
|
||||||
|
if (!isWhiteSpace(charCode)) {
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (charCode === CharacterCodes.tab) {
|
||||||
|
column += options.spacesPerTab;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
column++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
function findNextToken(previousToken: Node, parent: Node): Node {
|
||||||
|
return find(parent);
|
||||||
|
|
||||||
|
function find(n: Node): Node {
|
||||||
|
if (isToken(n) && n.pos === previousToken.end) {
|
||||||
|
// this is token that starts at the end of previous token - return it
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
var children = n.getChildren();
|
||||||
|
for (var i = 0, len = children.length; i < len; ++i) {
|
||||||
|
var child = children[i];
|
||||||
|
var shouldDiveInChildNode =
|
||||||
|
// previous token is enclosed somewhere in the child
|
||||||
|
(child.pos <= previousToken.pos && child.end > previousToken.end) ||
|
||||||
|
// previous token ends exactly at the beginning of child
|
||||||
|
(child.pos === previousToken.end);
|
||||||
|
|
||||||
|
if (shouldDiveInChildNode && nodeHasTokens(child)) {
|
||||||
|
return find(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function findPrecedingToken(position: number, sourceFile: SourceFile): Node {
|
||||||
|
return find(sourceFile);
|
||||||
|
|
||||||
|
function findRightmostToken(n: Node): Node {
|
||||||
|
if (isToken(n)) {
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
var children = n.getChildren();
|
||||||
|
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length);
|
||||||
|
return candidate && findRightmostToken(candidate);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function find(n: Node): Node {
|
||||||
|
if (isToken(n)) {
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
var children = n.getChildren();
|
||||||
|
for (var i = 0, len = children.length; i < len; ++i) {
|
||||||
|
var child = children[i];
|
||||||
|
if (nodeHasTokens(child)) {
|
||||||
|
if (position < child.end) {
|
||||||
|
if (child.getStart(sourceFile) >= position) {
|
||||||
|
// actual start of the node is past the position - previous token should be at the end of previous child
|
||||||
|
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i);
|
||||||
|
return candidate && findRightmostToken(candidate)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// candidate should be in this node
|
||||||
|
return find(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.assert(n.kind === SyntaxKind.SourceFile);
|
||||||
|
|
||||||
|
// Here we know that none of child token nodes embrace the position,
|
||||||
|
// the only known case is when position is at the end of the file.
|
||||||
|
// Try to find the rightmost token in the file without filtering.
|
||||||
|
// Namely we are skipping the check: 'position < node.end'
|
||||||
|
if (children.length) {
|
||||||
|
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length);
|
||||||
|
return candidate && findRightmostToken(candidate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// finds last node that is considered as candidate for search (isCandidate(node) === true) starting from 'exclusiveStartPosition'
|
||||||
|
function findRightmostChildNodeWithTokens(children: Node[], exclusiveStartPosition: number): Node {
|
||||||
|
for (var i = exclusiveStartPosition - 1; i >= 0; --i) {
|
||||||
|
if (nodeHasTokens(children[i])) {
|
||||||
|
return children[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Checks if node is something that can contain tokens (except EOF) - filters out EOF tokens, Missing\Omitted expressions, empty SyntaxLists and expression statements that wrap any of listed nodes.
|
||||||
|
*/
|
||||||
|
function nodeHasTokens(n: Node): boolean {
|
||||||
|
if (n.kind === SyntaxKind.ExpressionStatement) {
|
||||||
|
return nodeHasTokens((<ExpressionStatement>n).expression);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (n.kind === SyntaxKind.EndOfFileToken || n.kind === SyntaxKind.OmittedExpression || n.kind === SyntaxKind.Missing) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SyntaxList is already realized so getChildCount should be fast and non-expensive
|
||||||
|
return n.kind !== SyntaxKind.SyntaxList || n.getChildCount() !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isToken(n: Node): boolean {
|
||||||
|
return n.kind >= SyntaxKind.FirstToken && n.kind <= SyntaxKind.LastToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
function nodeContentIsIndented(parent: Node, child: Node): boolean {
|
||||||
|
switch (parent.kind) {
|
||||||
|
case SyntaxKind.ClassDeclaration:
|
||||||
|
case SyntaxKind.InterfaceDeclaration:
|
||||||
|
case SyntaxKind.EnumDeclaration:
|
||||||
|
return true;
|
||||||
|
case SyntaxKind.ModuleDeclaration:
|
||||||
|
// ModuleBlock should take care of indentation
|
||||||
|
return false;
|
||||||
|
case SyntaxKind.FunctionDeclaration:
|
||||||
|
case SyntaxKind.Method:
|
||||||
|
case SyntaxKind.FunctionExpression:
|
||||||
|
case SyntaxKind.GetAccessor:
|
||||||
|
case SyntaxKind.SetAccessor:
|
||||||
|
case SyntaxKind.Constructor:
|
||||||
|
// FunctionBlock should take care of indentation
|
||||||
|
return false;
|
||||||
|
case SyntaxKind.DoStatement:
|
||||||
|
case SyntaxKind.WhileStatement:
|
||||||
|
case SyntaxKind.ForInStatement:
|
||||||
|
case SyntaxKind.ForStatement:
|
||||||
|
return child && child.kind !== SyntaxKind.Block;
|
||||||
|
case SyntaxKind.IfStatement:
|
||||||
|
return child && child.kind !== SyntaxKind.Block;
|
||||||
|
case SyntaxKind.TryStatement:
|
||||||
|
// TryBlock\CatchBlock\FinallyBlock should take care of indentation
|
||||||
|
return false;
|
||||||
|
case SyntaxKind.ArrayLiteral:
|
||||||
|
case SyntaxKind.Block:
|
||||||
|
case SyntaxKind.FunctionBlock:
|
||||||
|
case SyntaxKind.TryBlock:
|
||||||
|
case SyntaxKind.CatchBlock:
|
||||||
|
case SyntaxKind.FinallyBlock:
|
||||||
|
case SyntaxKind.ModuleBlock:
|
||||||
|
case SyntaxKind.ObjectLiteral:
|
||||||
|
case SyntaxKind.TypeLiteral:
|
||||||
|
case SyntaxKind.SwitchStatement:
|
||||||
|
case SyntaxKind.DefaultClause:
|
||||||
|
case SyntaxKind.CaseClause:
|
||||||
|
case SyntaxKind.ParenExpression:
|
||||||
|
case SyntaxKind.CallExpression:
|
||||||
|
case SyntaxKind.NewExpression:
|
||||||
|
case SyntaxKind.VariableStatement:
|
||||||
|
case SyntaxKind.VariableDeclaration:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Checks if node ends with 'expectedLastToken'.
|
||||||
|
* If child at position 'length - 1' is 'SemicolonToken' it is skipped and 'expectedLastToken' is compared with child at position 'length - 2'.
|
||||||
|
*/
|
||||||
|
function nodeEndsWith(n: Node, expectedLastToken: SyntaxKind, sourceFile: SourceFile): boolean {
|
||||||
|
var children = n.getChildren(sourceFile);
|
||||||
|
if (children.length) {
|
||||||
|
var last = children[children.length - 1];
|
||||||
|
if (last.kind === expectedLastToken) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (last.kind === SyntaxKind.SemicolonToken && children.length !== 1) {
|
||||||
|
return children[children.length - 2].kind === expectedLastToken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function is always called when position of the cursor is located after the node
|
||||||
|
*/
|
||||||
|
function isCompletedNode(n: Node, sourceFile: SourceFile): boolean {
|
||||||
|
switch (n.kind) {
|
||||||
|
case SyntaxKind.ClassDeclaration:
|
||||||
|
case SyntaxKind.InterfaceDeclaration:
|
||||||
|
case SyntaxKind.EnumDeclaration:
|
||||||
|
case SyntaxKind.ObjectLiteral:
|
||||||
|
case SyntaxKind.Block:
|
||||||
|
case SyntaxKind.CatchBlock:
|
||||||
|
case SyntaxKind.FinallyBlock:
|
||||||
|
case SyntaxKind.FunctionBlock:
|
||||||
|
case SyntaxKind.ModuleBlock:
|
||||||
|
case SyntaxKind.SwitchStatement:
|
||||||
|
return nodeEndsWith(n, SyntaxKind.CloseBraceToken, sourceFile);
|
||||||
|
case SyntaxKind.ParenExpression:
|
||||||
|
case SyntaxKind.CallSignature:
|
||||||
|
case SyntaxKind.CallExpression:
|
||||||
|
case SyntaxKind.ConstructSignature:
|
||||||
|
return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile);
|
||||||
|
case SyntaxKind.FunctionDeclaration:
|
||||||
|
case SyntaxKind.FunctionExpression:
|
||||||
|
case SyntaxKind.Method:
|
||||||
|
case SyntaxKind.ArrowFunction:
|
||||||
|
return !(<FunctionDeclaration>n).body || isCompletedNode((<FunctionDeclaration>n).body, sourceFile);
|
||||||
|
case SyntaxKind.ModuleDeclaration:
|
||||||
|
return (<ModuleDeclaration>n).body && isCompletedNode((<ModuleDeclaration>n).body, sourceFile);
|
||||||
|
case SyntaxKind.IfStatement:
|
||||||
|
if ((<IfStatement>n).elseStatement) {
|
||||||
|
return isCompletedNode((<IfStatement>n).elseStatement, sourceFile);
|
||||||
|
}
|
||||||
|
return isCompletedNode((<IfStatement>n).thenStatement, sourceFile);
|
||||||
|
case SyntaxKind.ExpressionStatement:
|
||||||
|
return isCompletedNode((<ExpressionStatement>n).expression, sourceFile);
|
||||||
|
case SyntaxKind.ArrayLiteral:
|
||||||
|
return nodeEndsWith(n, SyntaxKind.CloseBracketToken, sourceFile);
|
||||||
|
case SyntaxKind.Missing:
|
||||||
|
return false;
|
||||||
|
case SyntaxKind.CaseClause:
|
||||||
|
case SyntaxKind.DefaultClause:
|
||||||
|
// there is no such thing as terminator token for CaseClause\DefaultClause so for simplicitly always consider them non-completed
|
||||||
|
return false;
|
||||||
|
case SyntaxKind.WhileStatement:
|
||||||
|
return isCompletedNode((<WhileStatement>n).statement, sourceFile);
|
||||||
|
case SyntaxKind.DoStatement:
|
||||||
|
// rough approximation: if DoStatement has While keyword - then if node is completed is checking the presence of ')';
|
||||||
|
var hasWhileKeyword = forEach(n.getChildren(), c => c.kind === SyntaxKind.WhileKeyword && c);
|
||||||
|
if(hasWhileKeyword) {
|
||||||
|
return nodeEndsWith(n, SyntaxKind.CloseParenToken, sourceFile);
|
||||||
|
}
|
||||||
|
return isCompletedNode((<DoStatement>n).statement, sourceFile);
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load diff
|
@ -53,6 +53,8 @@ module ts {
|
||||||
getScriptSnapshot(fileName: string): ScriptSnapshotShim;
|
getScriptSnapshot(fileName: string): ScriptSnapshotShim;
|
||||||
getLocalizedDiagnosticMessages(): string;
|
getLocalizedDiagnosticMessages(): string;
|
||||||
getCancellationToken(): CancellationToken;
|
getCancellationToken(): CancellationToken;
|
||||||
|
getCurrentDirectory(): string;
|
||||||
|
getDefaultLibFilename(): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -80,6 +82,8 @@ module ts {
|
||||||
getSemanticDiagnostics(fileName: string): string;
|
getSemanticDiagnostics(fileName: string): string;
|
||||||
getCompilerOptionsDiagnostics(): string;
|
getCompilerOptionsDiagnostics(): string;
|
||||||
|
|
||||||
|
getSyntacticClassifications(fileName: string, start: number, length: number): string;
|
||||||
|
|
||||||
getCompletionsAtPosition(fileName: string, position: number, isMemberCompletion: boolean): string;
|
getCompletionsAtPosition(fileName: string, position: number, isMemberCompletion: boolean): string;
|
||||||
getCompletionEntryDetails(fileName: string, position: number, entryName: string): string;
|
getCompletionEntryDetails(fileName: string, position: number, entryName: string): string;
|
||||||
|
|
||||||
|
@ -145,19 +149,19 @@ module ts {
|
||||||
getDefaultCompilationSettings(): string;
|
getDefaultCompilationSettings(): string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TODO: delete this, it is only needed untill the VS interface is updated
|
/// TODO: delete this, it is only needed until the VS interface is updated
|
||||||
enum LanguageVersion {
|
enum LanguageVersion {
|
||||||
EcmaScript3 = 0,
|
EcmaScript3 = 0,
|
||||||
EcmaScript5 = 1,
|
EcmaScript5 = 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ModuleGenTarget {
|
export enum ModuleGenTarget {
|
||||||
Unspecified = 0,
|
Unspecified = 0,
|
||||||
Synchronous = 1,
|
Synchronous = 1,
|
||||||
Asynchronous = 2,
|
Asynchronous = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CompilationSettings {
|
export interface CompilationSettings {
|
||||||
propagateEnumConstants?: boolean;
|
propagateEnumConstants?: boolean;
|
||||||
removeComments?: boolean;
|
removeComments?: boolean;
|
||||||
watch?: boolean;
|
watch?: boolean;
|
||||||
|
@ -177,15 +181,18 @@ module ts {
|
||||||
gatherDiagnostics?: boolean;
|
gatherDiagnostics?: boolean;
|
||||||
codepage?: number;
|
codepage?: number;
|
||||||
emitBOM?: boolean;
|
emitBOM?: boolean;
|
||||||
|
|
||||||
|
// Declare indexer signature
|
||||||
|
[index: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
function languageVersionToScriptTarget(languageVersion: LanguageVersion): ScriptTarget {
|
function languageVersionToScriptTarget(languageVersion: LanguageVersion): ScriptTarget {
|
||||||
if (typeof languageVersion === "undefined") return undefined;
|
if (typeof languageVersion === "undefined") return undefined;
|
||||||
|
|
||||||
switch (languageVersion) {
|
switch (languageVersion) {
|
||||||
case LanguageVersion.EcmaScript3: return ScriptTarget.ES3;
|
case LanguageVersion.EcmaScript3: return ScriptTarget.ES3
|
||||||
case LanguageVersion.EcmaScript5: return ScriptTarget.ES5;
|
case LanguageVersion.EcmaScript5: return ScriptTarget.ES5;
|
||||||
default: throw Error("unsuported LanguageVersion value: " + languageVersion);
|
default: throw Error("unsupported LanguageVersion value: " + languageVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,7 +203,7 @@ module ts {
|
||||||
case ModuleGenTarget.Asynchronous: return ModuleKind.AMD;
|
case ModuleGenTarget.Asynchronous: return ModuleKind.AMD;
|
||||||
case ModuleGenTarget.Synchronous: return ModuleKind.CommonJS;
|
case ModuleGenTarget.Synchronous: return ModuleKind.CommonJS;
|
||||||
case ModuleGenTarget.Unspecified: return ModuleKind.None;
|
case ModuleGenTarget.Unspecified: return ModuleKind.None;
|
||||||
default: throw Error("unsuported ModuleGenTarget value: " + moduleGenTarget);
|
default: throw Error("unsupported ModuleGenTarget value: " + moduleGenTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +213,7 @@ module ts {
|
||||||
switch (scriptTarget) {
|
switch (scriptTarget) {
|
||||||
case ScriptTarget.ES3: return LanguageVersion.EcmaScript3;
|
case ScriptTarget.ES3: return LanguageVersion.EcmaScript3;
|
||||||
case ScriptTarget.ES5: return LanguageVersion.EcmaScript5;
|
case ScriptTarget.ES5: return LanguageVersion.EcmaScript5;
|
||||||
default: throw Error("unsuported ScriptTarget value: " + scriptTarget);
|
default: throw Error("unsupported ScriptTarget value: " + scriptTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +224,7 @@ module ts {
|
||||||
case ModuleKind.AMD: return ModuleGenTarget.Asynchronous;
|
case ModuleKind.AMD: return ModuleGenTarget.Asynchronous;
|
||||||
case ModuleKind.CommonJS: return ModuleGenTarget.Synchronous;
|
case ModuleKind.CommonJS: return ModuleGenTarget.Synchronous;
|
||||||
case ModuleKind.None: return ModuleGenTarget.Unspecified;
|
case ModuleKind.None: return ModuleGenTarget.Unspecified;
|
||||||
default: throw Error("unsuported ModuleKind value: " + moduleKind);
|
default: throw Error("unsupported ModuleKind value: " + moduleKind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,8 +328,8 @@ module ts {
|
||||||
|
|
||||||
/// TODO: this should be pushed into VS.
|
/// TODO: this should be pushed into VS.
|
||||||
/// We can not ask the LS instance to resolve, as this will lead to asking the host about files it does not know about,
|
/// We can not ask the LS instance to resolve, as this will lead to asking the host about files it does not know about,
|
||||||
/// something it is not desinged to handle. for now make sure we never get a "noresolve == false".
|
/// something it is not designed to handle. for now make sure we never get a "noresolve == false".
|
||||||
/// This value should not matter, as the host runs resolution logic independentlly
|
/// This value should not matter, as the host runs resolution logic independently
|
||||||
options.noResolve = true;
|
options.noResolve = true;
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
|
@ -362,6 +369,14 @@ module ts {
|
||||||
public getCancellationToken(): CancellationToken {
|
public getCancellationToken(): CancellationToken {
|
||||||
return this.shimHost.getCancellationToken();
|
return this.shimHost.getCancellationToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getDefaultLibFilename(): string {
|
||||||
|
return this.shimHost.getDefaultLibFilename();
|
||||||
|
}
|
||||||
|
|
||||||
|
public getCurrentDirectory(): string {
|
||||||
|
return this.shimHost.getCurrentDirectory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any): any {
|
function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any): any {
|
||||||
|
@ -419,7 +434,7 @@ module ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DISPOSE
|
// DISPOSE
|
||||||
// Ensure (almost) determinstic release of internal Javascript resources when
|
// Ensure (almost) deterministic release of internal Javascript resources when
|
||||||
// some external native objects holds onto us (e.g. Com/Interop).
|
// some external native objects holds onto us (e.g. Com/Interop).
|
||||||
public dispose(dummy: any): void {
|
public dispose(dummy: any): void {
|
||||||
this.logger.log("dispose()");
|
this.logger.log("dispose()");
|
||||||
|
@ -477,6 +492,24 @@ module ts {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getSyntacticClassifications(fileName: string, start: number, length: number): string {
|
||||||
|
return this.forwardJSONCall(
|
||||||
|
"getSyntacticClassifications('" + fileName + "', " + start + ", " + length + ")",
|
||||||
|
() => {
|
||||||
|
var classifications = this.languageService.getSyntacticClassifications(fileName, new TypeScript.TextSpan(start, length));
|
||||||
|
return classifications;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public getSemanticClassifications(fileName: string, start: number, length: number): string {
|
||||||
|
return this.forwardJSONCall(
|
||||||
|
"getSemanticClassifications('" + fileName + "', " + start + ", " + length + ")",
|
||||||
|
() => {
|
||||||
|
var classifications = this.languageService.getSemanticClassifications(fileName, new TypeScript.TextSpan(start, length));
|
||||||
|
return classifications;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public getSyntacticDiagnostics(fileName: string): string {
|
public getSyntacticDiagnostics(fileName: string): string {
|
||||||
return this.forwardJSONCall(
|
return this.forwardJSONCall(
|
||||||
"getSyntacticDiagnostics('" + fileName + "')",
|
"getSyntacticDiagnostics('" + fileName + "')",
|
||||||
|
@ -846,7 +879,7 @@ module ts {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// TODO: this is used by VS, clean this up on both sides of the interfrace
|
/// TODO: this is used by VS, clean this up on both sides of the interface
|
||||||
module TypeScript.Services {
|
module TypeScript.Services {
|
||||||
export var TypeScriptServicesFactory = ts.TypeScriptServicesFactory;
|
export var TypeScriptServicesFactory = ts.TypeScriptServicesFactory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,8 +211,6 @@ module TypeScript.Services {
|
||||||
signatureGroupInfo.signatureInfo = TypeScript.MemberName.memberNameToString(symbolName, paramIndexInfo);
|
signatureGroupInfo.signatureInfo = TypeScript.MemberName.memberNameToString(symbolName, paramIndexInfo);
|
||||||
signatureGroupInfo.docComment = symbol.docComments();
|
signatureGroupInfo.docComment = symbol.docComments();
|
||||||
|
|
||||||
var parameterMarkerIndex = 0;
|
|
||||||
|
|
||||||
var typeSymbol = symbol.type;
|
var typeSymbol = symbol.type;
|
||||||
|
|
||||||
var typeParameters = typeSymbol.getTypeParameters();
|
var typeParameters = typeSymbol.getTypeParameters();
|
||||||
|
|
|
@ -84,7 +84,6 @@ module TypeScript {
|
||||||
private cacheSyntaxTreeInfo(): void {
|
private cacheSyntaxTreeInfo(): void {
|
||||||
// If we're not keeping around the syntax tree, store the diagnostics and line
|
// If we're not keeping around the syntax tree, store the diagnostics and line
|
||||||
// map so they don't have to be recomputed.
|
// map so they don't have to be recomputed.
|
||||||
var sourceUnit = this.sourceUnit();
|
|
||||||
var firstToken = firstSyntaxTreeToken(this);
|
var firstToken = firstSyntaxTreeToken(this);
|
||||||
var leadingTrivia = firstToken.leadingTrivia(this.text);
|
var leadingTrivia = firstToken.leadingTrivia(this.text);
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,6 @@ module TypeScript.Syntax {
|
||||||
|
|
||||||
// When we run into a newline for the first time, create the string builder and copy
|
// When we run into a newline for the first time, create the string builder and copy
|
||||||
// all the values up to this newline into it.
|
// all the values up to this newline into it.
|
||||||
var isCarriageReturnLineFeed = false;
|
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case CharacterCodes.carriageReturn:
|
case CharacterCodes.carriageReturn:
|
||||||
if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === CharacterCodes.lineFeed) {
|
if (i < triviaText.length - 1 && triviaText.charCodeAt(i + 1) === CharacterCodes.lineFeed) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
///<reference path='references.ts' />
|
///<reference path='references.ts' />
|
||||||
|
|
||||||
module TypeScript {
|
module TypeScript {
|
||||||
|
|
||||||
export interface ISpan {
|
export interface ISpan {
|
||||||
start(): number;
|
start(): number;
|
||||||
end(): number;
|
end(): number;
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction1.ts(1,13): error TS1110: Type expected.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction1.ts (1 errors) ====
|
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction1.ts (1 errors) ====
|
||||||
var v = (a: ) => {
|
var v = (a: ) => {
|
||||||
~
|
~
|
||||||
!!! Type expected.
|
!!! error TS1110: Type expected.
|
||||||
|
|
||||||
};
|
};
|
|
@ -1,8 +1,12 @@
|
||||||
|
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts(1,14): error TS1009: Trailing comma not allowed.
|
||||||
|
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts(1,13): error TS2304: Cannot find name 'b'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts (2 errors) ====
|
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction2.ts (2 errors) ====
|
||||||
var v = (a: b,) => {
|
var v = (a: b,) => {
|
||||||
~
|
~
|
||||||
!!! Trailing comma not allowed.
|
!!! error TS1009: Trailing comma not allowed.
|
||||||
~
|
~
|
||||||
!!! Cannot find name 'b'.
|
!!! error TS2304: Cannot find name 'b'.
|
||||||
|
|
||||||
};
|
};
|
|
@ -1,10 +1,15 @@
|
||||||
|
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,12): error TS1005: ',' expected.
|
||||||
|
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,14): error TS1005: ';' expected.
|
||||||
|
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts(1,10): error TS2304: Cannot find name 'a'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts (3 errors) ====
|
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts (3 errors) ====
|
||||||
var v = (a): => {
|
var v = (a): => {
|
||||||
~
|
~
|
||||||
!!! ',' expected.
|
!!! error TS1005: ',' expected.
|
||||||
~~
|
~~
|
||||||
!!! ';' expected.
|
!!! error TS1005: ';' expected.
|
||||||
~
|
~
|
||||||
!!! Cannot find name 'a'.
|
!!! error TS2304: Cannot find name 'a'.
|
||||||
|
|
||||||
};
|
};
|
|
@ -1,4 +1,7 @@
|
||||||
|
tests/cases/compiler/ArrowFunctionExpression1.ts(1,10): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ArrowFunctionExpression1.ts (1 errors) ====
|
==== tests/cases/compiler/ArrowFunctionExpression1.ts (1 errors) ====
|
||||||
var v = (public x: string) => { };
|
var v = (public x: string) => { };
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
|
@ -1,3 +1,10 @@
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts(10,19): error TS2304: Cannot find name 'T'.
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts(20,12): error TS2304: Cannot find name 'T'.
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts(22,23): error TS2304: Cannot find name 'T'.
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts(35,26): error TS2304: Cannot find name 'T'.
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts(46,15): error TS2304: Cannot find name 'T'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts (5 errors) ====
|
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts (5 errors) ====
|
||||||
// all expected to be errors
|
// all expected to be errors
|
||||||
|
|
||||||
|
@ -10,7 +17,7 @@
|
||||||
module clodule1 {
|
module clodule1 {
|
||||||
function f(x: T) { }
|
function f(x: T) { }
|
||||||
~
|
~
|
||||||
!!! Cannot find name 'T'.
|
!!! error TS2304: Cannot find name 'T'.
|
||||||
}
|
}
|
||||||
|
|
||||||
class clodule2<T>{
|
class clodule2<T>{
|
||||||
|
@ -22,11 +29,11 @@
|
||||||
module clodule2 {
|
module clodule2 {
|
||||||
var x: T;
|
var x: T;
|
||||||
~
|
~
|
||||||
!!! Cannot find name 'T'.
|
!!! error TS2304: Cannot find name 'T'.
|
||||||
|
|
||||||
class D<U extends T>{
|
class D<U extends T>{
|
||||||
~
|
~
|
||||||
!!! Cannot find name 'T'.
|
!!! error TS2304: Cannot find name 'T'.
|
||||||
id: string;
|
id: string;
|
||||||
value: U;
|
value: U;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +48,7 @@
|
||||||
module clodule3 {
|
module clodule3 {
|
||||||
export var y = { id: T };
|
export var y = { id: T };
|
||||||
~
|
~
|
||||||
!!! Cannot find name 'T'.
|
!!! error TS2304: Cannot find name 'T'.
|
||||||
}
|
}
|
||||||
|
|
||||||
class clodule4<T>{
|
class clodule4<T>{
|
||||||
|
@ -54,7 +61,7 @@
|
||||||
class D {
|
class D {
|
||||||
name: T;
|
name: T;
|
||||||
~
|
~
|
||||||
!!! Cannot find name 'T'.
|
!!! error TS2304: Cannot find name 'T'.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts(10,21): error TS2300: Duplicate identifier 'fn'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts (1 errors) ====
|
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts (1 errors) ====
|
||||||
class clodule<T> {
|
class clodule<T> {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -10,7 +13,7 @@
|
||||||
// error: duplicate identifier expected
|
// error: duplicate identifier expected
|
||||||
export function fn<T>(x: T, y: T): T {
|
export function fn<T>(x: T, y: T): T {
|
||||||
~~
|
~~
|
||||||
!!! Duplicate identifier 'fn'.
|
!!! error TS2300: Duplicate identifier 'fn'.
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts(10,21): error TS2300: Duplicate identifier 'fn'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts (1 errors) ====
|
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts (1 errors) ====
|
||||||
class clodule<T> {
|
class clodule<T> {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -10,7 +13,7 @@
|
||||||
// error: duplicate identifier expected
|
// error: duplicate identifier expected
|
||||||
export function fn<T>(x: T, y: T): T {
|
export function fn<T>(x: T, y: T): T {
|
||||||
~~
|
~~
|
||||||
!!! Duplicate identifier 'fn'.
|
!!! error TS2300: Duplicate identifier 'fn'.
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts(11,16): error TS2341: Property 'clodule.sfn' is inaccessible.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts (1 errors) ====
|
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts (1 errors) ====
|
||||||
class clodule<T> {
|
class clodule<T> {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -11,7 +14,7 @@
|
||||||
export function fn<T>(x: T, y: T): number {
|
export function fn<T>(x: T, y: T): number {
|
||||||
return clodule.sfn('a');
|
return clodule.sfn('a');
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
!!! Property 'clodule.sfn' is inaccessible.
|
!!! error TS2341: Property 'clodule.sfn' is inaccessible.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts(8,21): error TS2300: Duplicate identifier 'Origin'.
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts(20,25): error TS2300: Duplicate identifier 'Origin'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts (2 errors) ====
|
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts (2 errors) ====
|
||||||
class Point {
|
class Point {
|
||||||
constructor(public x: number, public y: number) { }
|
constructor(public x: number, public y: number) { }
|
||||||
|
@ -8,7 +12,7 @@
|
||||||
module Point {
|
module Point {
|
||||||
export function Origin() { return null; } //expected duplicate identifier error
|
export function Origin() { return null; } //expected duplicate identifier error
|
||||||
~~~~~~
|
~~~~~~
|
||||||
!!! Duplicate identifier 'Origin'.
|
!!! error TS2300: Duplicate identifier 'Origin'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +26,6 @@
|
||||||
export module Point {
|
export module Point {
|
||||||
export function Origin() { return ""; }//expected duplicate identifier error
|
export function Origin() { return ""; }//expected duplicate identifier error
|
||||||
~~~~~~
|
~~~~~~
|
||||||
!!! Duplicate identifier 'Origin'.
|
!!! error TS2300: Duplicate identifier 'Origin'.
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,3 +1,7 @@
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts(8,16): error TS2300: Duplicate identifier 'Origin'.
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts(20,20): error TS2300: Duplicate identifier 'Origin'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts (2 errors) ====
|
==== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts (2 errors) ====
|
||||||
class Point {
|
class Point {
|
||||||
constructor(public x: number, public y: number) { }
|
constructor(public x: number, public y: number) { }
|
||||||
|
@ -8,7 +12,7 @@
|
||||||
module Point {
|
module Point {
|
||||||
export var Origin = ""; //expected duplicate identifier error
|
export var Origin = ""; //expected duplicate identifier error
|
||||||
~~~~~~
|
~~~~~~
|
||||||
!!! Duplicate identifier 'Origin'.
|
!!! error TS2300: Duplicate identifier 'Origin'.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +26,6 @@
|
||||||
export module Point {
|
export module Point {
|
||||||
export var Origin = ""; //expected duplicate identifier error
|
export var Origin = ""; //expected duplicate identifier error
|
||||||
~~~~~~
|
~~~~~~
|
||||||
!!! Duplicate identifier 'Origin'.
|
!!! error TS2300: Duplicate identifier 'Origin'.
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,3 +1,6 @@
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/module.ts(2,19): error TS2433: A module declaration cannot be in a different file from a class or function with which it is merged
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/DeclarationMerging/class.ts (0 errors) ====
|
==== tests/cases/conformance/internalModules/DeclarationMerging/class.ts (0 errors) ====
|
||||||
module X.Y {
|
module X.Y {
|
||||||
export class Point {
|
export class Point {
|
||||||
|
@ -14,7 +17,7 @@
|
||||||
module X.Y {
|
module X.Y {
|
||||||
export module Point {
|
export module Point {
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! A module declaration cannot be in a different file from a class or function with which it is merged
|
!!! error TS2433: A module declaration cannot be in a different file from a class or function with which it is merged
|
||||||
export var Origin = new Point(0, 0);
|
export var Origin = new Point(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
|
tests/cases/compiler/ClassDeclaration10.ts(2,4): error TS2390: Constructor implementation is missing.
|
||||||
|
tests/cases/compiler/ClassDeclaration10.ts(3,4): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ClassDeclaration10.ts (2 errors) ====
|
==== tests/cases/compiler/ClassDeclaration10.ts (2 errors) ====
|
||||||
class C {
|
class C {
|
||||||
constructor();
|
constructor();
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
!!! Constructor implementation is missing.
|
!!! error TS2390: Constructor implementation is missing.
|
||||||
foo();
|
foo();
|
||||||
~~~
|
~~~
|
||||||
!!! Function implementation is missing or not immediately following the declaration.
|
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
}
|
}
|
|
@ -1,7 +1,10 @@
|
||||||
|
tests/cases/compiler/ClassDeclaration11.ts(2,4): error TS2390: Constructor implementation is missing.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ClassDeclaration11.ts (1 errors) ====
|
==== tests/cases/compiler/ClassDeclaration11.ts (1 errors) ====
|
||||||
class C {
|
class C {
|
||||||
constructor();
|
constructor();
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
!!! Constructor implementation is missing.
|
!!! error TS2390: Constructor implementation is missing.
|
||||||
foo() { }
|
foo() { }
|
||||||
}
|
}
|
|
@ -1,7 +1,10 @@
|
||||||
|
tests/cases/compiler/ClassDeclaration13.ts(3,4): error TS2389: Function implementation name must be 'foo'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ClassDeclaration13.ts (1 errors) ====
|
==== tests/cases/compiler/ClassDeclaration13.ts (1 errors) ====
|
||||||
class C {
|
class C {
|
||||||
foo();
|
foo();
|
||||||
bar() { }
|
bar() { }
|
||||||
~~~
|
~~~
|
||||||
!!! Function implementation name must be 'foo'.
|
!!! error TS2389: Function implementation name must be 'foo'.
|
||||||
}
|
}
|
|
@ -1,9 +1,13 @@
|
||||||
|
tests/cases/compiler/ClassDeclaration14.ts(2,4): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
|
tests/cases/compiler/ClassDeclaration14.ts(3,4): error TS2390: Constructor implementation is missing.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ClassDeclaration14.ts (2 errors) ====
|
==== tests/cases/compiler/ClassDeclaration14.ts (2 errors) ====
|
||||||
class C {
|
class C {
|
||||||
foo();
|
foo();
|
||||||
~~~
|
~~~
|
||||||
!!! Function implementation is missing or not immediately following the declaration.
|
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
constructor();
|
constructor();
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
!!! Constructor implementation is missing.
|
!!! error TS2390: Constructor implementation is missing.
|
||||||
}
|
}
|
|
@ -1,7 +1,10 @@
|
||||||
|
tests/cases/compiler/ClassDeclaration15.ts(2,4): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ClassDeclaration15.ts (1 errors) ====
|
==== tests/cases/compiler/ClassDeclaration15.ts (1 errors) ====
|
||||||
class C {
|
class C {
|
||||||
foo();
|
foo();
|
||||||
~~~
|
~~~
|
||||||
!!! Function implementation is missing or not immediately following the declaration.
|
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
constructor() { }
|
constructor() { }
|
||||||
}
|
}
|
|
@ -1,7 +1,10 @@
|
||||||
|
tests/cases/compiler/ClassDeclaration21.ts(3,5): error TS2389: Function implementation name must be '0'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ClassDeclaration21.ts (1 errors) ====
|
==== tests/cases/compiler/ClassDeclaration21.ts (1 errors) ====
|
||||||
class C {
|
class C {
|
||||||
0();
|
0();
|
||||||
1() { }
|
1() { }
|
||||||
~
|
~
|
||||||
!!! Function implementation name must be '0'.
|
!!! error TS2389: Function implementation name must be '0'.
|
||||||
}
|
}
|
|
@ -1,7 +1,10 @@
|
||||||
|
tests/cases/compiler/ClassDeclaration22.ts(3,5): error TS2389: Function implementation name must be '"foo"'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ClassDeclaration22.ts (1 errors) ====
|
==== tests/cases/compiler/ClassDeclaration22.ts (1 errors) ====
|
||||||
class C {
|
class C {
|
||||||
"foo"();
|
"foo"();
|
||||||
"bar"() { }
|
"bar"() { }
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Function implementation name must be '"foo"'.
|
!!! error TS2389: Function implementation name must be '"foo"'.
|
||||||
}
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
|
tests/cases/compiler/ClassDeclaration24.ts(1,7): error TS2414: Class name cannot be 'any'
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ClassDeclaration24.ts (1 errors) ====
|
==== tests/cases/compiler/ClassDeclaration24.ts (1 errors) ====
|
||||||
class any {
|
class any {
|
||||||
~~~
|
~~~
|
||||||
!!! Class name cannot be 'any'
|
!!! error TS2414: Class name cannot be 'any'
|
||||||
}
|
}
|
|
@ -1,3 +1,7 @@
|
||||||
|
tests/cases/compiler/ClassDeclaration25.ts(6,5): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
|
tests/cases/compiler/ClassDeclaration25.ts(7,5): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ClassDeclaration25.ts (2 errors) ====
|
==== tests/cases/compiler/ClassDeclaration25.ts (2 errors) ====
|
||||||
interface IList<T> {
|
interface IList<T> {
|
||||||
data(): T;
|
data(): T;
|
||||||
|
@ -6,9 +10,9 @@
|
||||||
class List<U> implements IList<U> {
|
class List<U> implements IList<U> {
|
||||||
data(): U;
|
data(): U;
|
||||||
~~~~
|
~~~~
|
||||||
!!! Function implementation is missing or not immediately following the declaration.
|
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
next(): string;
|
next(): string;
|
||||||
~~~~
|
~~~~
|
||||||
!!! Function implementation is missing or not immediately following the declaration.
|
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
tests/cases/compiler/ClassDeclaration8.ts(2,3): error TS2390: Constructor implementation is missing.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ClassDeclaration8.ts (1 errors) ====
|
==== tests/cases/compiler/ClassDeclaration8.ts (1 errors) ====
|
||||||
class C {
|
class C {
|
||||||
constructor();
|
constructor();
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
!!! Constructor implementation is missing.
|
!!! error TS2390: Constructor implementation is missing.
|
||||||
}
|
}
|
|
@ -1,6 +1,9 @@
|
||||||
|
tests/cases/compiler/ClassDeclaration9.ts(2,4): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ClassDeclaration9.ts (1 errors) ====
|
==== tests/cases/compiler/ClassDeclaration9.ts (1 errors) ====
|
||||||
class C {
|
class C {
|
||||||
foo();
|
foo();
|
||||||
~~~
|
~~~
|
||||||
!!! Function implementation is missing or not immediately following the declaration.
|
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
}
|
}
|
|
@ -1,11 +1,16 @@
|
||||||
|
tests/cases/compiler/ExportAssignment7.ts(1,14): error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||||
|
tests/cases/compiler/ExportAssignment7.ts(4,1): error TS2304: Cannot find name 'B'.
|
||||||
|
tests/cases/compiler/ExportAssignment7.ts(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ExportAssignment7.ts (3 errors) ====
|
==== tests/cases/compiler/ExportAssignment7.ts (3 errors) ====
|
||||||
export class C {
|
export class C {
|
||||||
~
|
~
|
||||||
!!! Cannot compile external modules unless the '--module' flag is provided.
|
!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||||
}
|
}
|
||||||
|
|
||||||
export = B;
|
export = B;
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
!!! Cannot find name 'B'.
|
!!! error TS2304: Cannot find name 'B'.
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
!!! An export assignment cannot be used in a module with other exported elements.
|
!!! error TS2309: An export assignment cannot be used in a module with other exported elements.
|
|
@ -1,11 +1,16 @@
|
||||||
|
tests/cases/compiler/ExportAssignment8.ts(1,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||||
|
tests/cases/compiler/ExportAssignment8.ts(1,1): error TS2304: Cannot find name 'B'.
|
||||||
|
tests/cases/compiler/ExportAssignment8.ts(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ExportAssignment8.ts (3 errors) ====
|
==== tests/cases/compiler/ExportAssignment8.ts (3 errors) ====
|
||||||
export = B;
|
export = B;
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
!!! Cannot compile external modules unless the '--module' flag is provided.
|
!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
!!! Cannot find name 'B'.
|
!!! error TS2304: Cannot find name 'B'.
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
!!! An export assignment cannot be used in a module with other exported elements.
|
!!! error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||||
|
|
||||||
export class C {
|
export class C {
|
||||||
}
|
}
|
|
@ -1,3 +1,8 @@
|
||||||
|
tests/cases/conformance/internalModules/exportDeclarations/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.ts(8,27): error TS1005: ';' expected.
|
||||||
|
tests/cases/conformance/internalModules/exportDeclarations/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.ts(8,43): error TS1005: ';' expected.
|
||||||
|
tests/cases/conformance/internalModules/exportDeclarations/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.ts(9,30): error TS1005: ';' expected.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/exportDeclarations/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.ts (3 errors) ====
|
==== tests/cases/conformance/internalModules/exportDeclarations/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.ts (3 errors) ====
|
||||||
module A {
|
module A {
|
||||||
|
|
||||||
|
@ -8,11 +13,11 @@
|
||||||
export var UnitSquare : {
|
export var UnitSquare : {
|
||||||
top: { left: Point, right: Point },
|
top: { left: Point, right: Point },
|
||||||
~
|
~
|
||||||
!!! ';' expected.
|
!!! error TS1005: ';' expected.
|
||||||
~
|
~
|
||||||
!!! ';' expected.
|
!!! error TS1005: ';' expected.
|
||||||
bottom: { left: Point, right: Point }
|
bottom: { left: Point, right: Point }
|
||||||
~
|
~
|
||||||
!!! ';' expected.
|
!!! error TS1005: ';' expected.
|
||||||
} = null;
|
} = null;
|
||||||
}
|
}
|
|
@ -1,3 +1,8 @@
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/module.ts(2,19): error TS2433: A module declaration cannot be in a different file from a class or function with which it is merged
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/simple.ts(13,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'fn' must be of type '() => { x: number; y: number; }', but here has type 'typeof Point'.
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/test.ts(2,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'fn' must be of type '() => { x: number; y: number; }', but here has type 'typeof Point'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/DeclarationMerging/function.ts (0 errors) ====
|
==== tests/cases/conformance/internalModules/DeclarationMerging/function.ts (0 errors) ====
|
||||||
module A {
|
module A {
|
||||||
export function Point() {
|
export function Point() {
|
||||||
|
@ -9,7 +14,7 @@
|
||||||
module A {
|
module A {
|
||||||
export module Point {
|
export module Point {
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! A module declaration cannot be in a different file from a class or function with which it is merged
|
!!! error TS2433: A module declaration cannot be in a different file from a class or function with which it is merged
|
||||||
export var Origin = { x: 0, y: 0 };
|
export var Origin = { x: 0, y: 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +23,7 @@
|
||||||
var fn: () => { x: number; y: number };
|
var fn: () => { x: number; y: number };
|
||||||
var fn = A.Point;
|
var fn = A.Point;
|
||||||
~~
|
~~
|
||||||
!!! Subsequent variable declarations must have the same type. Variable 'fn' must be of type '() => { x: number; y: number; }', but here has type 'typeof Point'.
|
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'fn' must be of type '() => { x: number; y: number; }', but here has type 'typeof Point'.
|
||||||
|
|
||||||
var cl: { x: number; y: number; }
|
var cl: { x: number; y: number; }
|
||||||
var cl = A.Point();
|
var cl = A.Point();
|
||||||
|
@ -40,7 +45,7 @@
|
||||||
var fn: () => { x: number; y: number };
|
var fn: () => { x: number; y: number };
|
||||||
var fn = B.Point; // not expected to be an error. bug 840000: [corelang] Function of fundule not assignalbe as expected
|
var fn = B.Point; // not expected to be an error. bug 840000: [corelang] Function of fundule not assignalbe as expected
|
||||||
~~
|
~~
|
||||||
!!! Subsequent variable declarations must have the same type. Variable 'fn' must be of type '() => { x: number; y: number; }', but here has type 'typeof Point'.
|
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'fn' must be of type '() => { x: number; y: number; }', but here has type 'typeof Point'.
|
||||||
|
|
||||||
var cl: { x: number; y: number; }
|
var cl: { x: number; y: number; }
|
||||||
var cl = B.Point();
|
var cl = B.Point();
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
|
tests/cases/compiler/FunctionDeclaration3.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/FunctionDeclaration3.ts (1 errors) ====
|
==== tests/cases/compiler/FunctionDeclaration3.ts (1 errors) ====
|
||||||
function foo();
|
function foo();
|
||||||
~~~
|
~~~
|
||||||
!!! Function implementation is missing or not immediately following the declaration.
|
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
|
@ -1,5 +1,8 @@
|
||||||
|
tests/cases/compiler/FunctionDeclaration4.ts(2,10): error TS2389: Function implementation name must be 'foo'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/FunctionDeclaration4.ts (1 errors) ====
|
==== tests/cases/compiler/FunctionDeclaration4.ts (1 errors) ====
|
||||||
function foo();
|
function foo();
|
||||||
function bar() { }
|
function bar() { }
|
||||||
~~~
|
~~~
|
||||||
!!! Function implementation name must be 'foo'.
|
!!! error TS2389: Function implementation name must be 'foo'.
|
|
@ -1,7 +1,10 @@
|
||||||
|
tests/cases/compiler/FunctionDeclaration6.ts(3,14): error TS2389: Function implementation name must be 'foo'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/FunctionDeclaration6.ts (1 errors) ====
|
==== tests/cases/compiler/FunctionDeclaration6.ts (1 errors) ====
|
||||||
{
|
{
|
||||||
function foo();
|
function foo();
|
||||||
function bar() { }
|
function bar() { }
|
||||||
~~~
|
~~~
|
||||||
!!! Function implementation name must be 'foo'.
|
!!! error TS2389: Function implementation name must be 'foo'.
|
||||||
}
|
}
|
|
@ -1,6 +1,9 @@
|
||||||
|
tests/cases/compiler/FunctionDeclaration7.ts(2,13): error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/FunctionDeclaration7.ts (1 errors) ====
|
==== tests/cases/compiler/FunctionDeclaration7.ts (1 errors) ====
|
||||||
module M {
|
module M {
|
||||||
function foo();
|
function foo();
|
||||||
~~~
|
~~~
|
||||||
!!! Function implementation is missing or not immediately following the declaration.
|
!!! error TS2391: Function implementation is missing or not immediately following the declaration.
|
||||||
}
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
|
tests/cases/compiler/InterfaceDeclaration8.ts(1,11): error TS2427: Interface name cannot be 'string'
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/InterfaceDeclaration8.ts (1 errors) ====
|
==== tests/cases/compiler/InterfaceDeclaration8.ts (1 errors) ====
|
||||||
interface string {
|
interface string {
|
||||||
~~~~~~
|
~~~~~~
|
||||||
!!! Interface name cannot be 'string'
|
!!! error TS2427: Interface name cannot be 'string'
|
||||||
}
|
}
|
|
@ -1,3 +1,7 @@
|
||||||
|
tests/cases/conformance/internalModules/moduleDeclarations/InvalidNonInstantiatedModule.ts(5,9): error TS2304: Cannot find name 'M'.
|
||||||
|
tests/cases/conformance/internalModules/moduleDeclarations/InvalidNonInstantiatedModule.ts(7,15): error TS2304: Cannot find name 'M'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/moduleDeclarations/InvalidNonInstantiatedModule.ts (2 errors) ====
|
==== tests/cases/conformance/internalModules/moduleDeclarations/InvalidNonInstantiatedModule.ts (2 errors) ====
|
||||||
module M {
|
module M {
|
||||||
export interface Point { x: number; y: number }
|
export interface Point { x: number; y: number }
|
||||||
|
@ -5,9 +9,9 @@
|
||||||
|
|
||||||
var m = M; // Error, not instantiated can not be used as var
|
var m = M; // Error, not instantiated can not be used as var
|
||||||
~
|
~
|
||||||
!!! Cannot find name 'M'.
|
!!! error TS2304: Cannot find name 'M'.
|
||||||
|
|
||||||
var x: typeof M; // Error only a namespace
|
var x: typeof M; // Error only a namespace
|
||||||
~
|
~
|
||||||
!!! Cannot find name 'M'.
|
!!! error TS2304: Cannot find name 'M'.
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
|
tests/cases/compiler/MemberAccessorDeclaration15.ts(2,8): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/MemberAccessorDeclaration15.ts(2,12): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/MemberAccessorDeclaration15.ts (2 errors) ====
|
==== tests/cases/compiler/MemberAccessorDeclaration15.ts (2 errors) ====
|
||||||
class C {
|
class C {
|
||||||
set Foo(public a: number) { }
|
set Foo(public a: number) { }
|
||||||
~~~
|
~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
}
|
}
|
|
@ -1,8 +1,12 @@
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/module.ts(2,19): error TS2433: A module declaration cannot be in a different file from a class or function with which it is merged
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/simple.ts(1,8): error TS2434: A module declaration cannot be located prior to a class or function with which it is merged
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/DeclarationMerging/module.ts (1 errors) ====
|
==== tests/cases/conformance/internalModules/DeclarationMerging/module.ts (1 errors) ====
|
||||||
module X.Y {
|
module X.Y {
|
||||||
export module Point {
|
export module Point {
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! A module declaration cannot be in a different file from a class or function with which it is merged
|
!!! error TS2433: A module declaration cannot be in a different file from a class or function with which it is merged
|
||||||
export var Origin = new Point(0, 0);
|
export var Origin = new Point(0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +27,7 @@
|
||||||
==== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts (1 errors) ====
|
==== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts (1 errors) ====
|
||||||
module A {
|
module A {
|
||||||
~
|
~
|
||||||
!!! A module declaration cannot be located prior to a class or function with which it is merged
|
!!! error TS2434: A module declaration cannot be located prior to a class or function with which it is merged
|
||||||
export var Instance = new A();
|
export var Instance = new A();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/module.ts(2,19): error TS2433: A module declaration cannot be in a different file from a class or function with which it is merged
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/simple.ts(3,19): error TS2434: A module declaration cannot be located prior to a class or function with which it is merged
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/DeclarationMerging/module.ts (1 errors) ====
|
==== tests/cases/conformance/internalModules/DeclarationMerging/module.ts (1 errors) ====
|
||||||
module A {
|
module A {
|
||||||
export module Point {
|
export module Point {
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! A module declaration cannot be in a different file from a class or function with which it is merged
|
!!! error TS2433: A module declaration cannot be in a different file from a class or function with which it is merged
|
||||||
export var Origin = { x: 0, y: 0 };
|
export var Origin = { x: 0, y: 0 };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +24,7 @@
|
||||||
|
|
||||||
export module Point {
|
export module Point {
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! A module declaration cannot be located prior to a class or function with which it is merged
|
!!! error TS2434: A module declaration cannot be located prior to a class or function with which it is merged
|
||||||
export var Origin = { x: 0, y: 0 };
|
export var Origin = { x: 0, y: 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedClasses.ts(30,16): error TS2339: Property 'A2' does not exist on type 'typeof A'.
|
||||||
|
tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedClasses.ts(31,17): error TS2339: Property 'A2' does not exist on type 'typeof A'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedClasses.ts (2 errors) ====
|
==== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedClasses.ts (2 errors) ====
|
||||||
module A {
|
module A {
|
||||||
export class A {
|
export class A {
|
||||||
|
@ -30,9 +34,9 @@
|
||||||
// errors expected, these are not exported
|
// errors expected, these are not exported
|
||||||
var a2 = new A.A2();
|
var a2 = new A.A2();
|
||||||
~~
|
~~
|
||||||
!!! Property 'A2' does not exist on type 'typeof A'.
|
!!! error TS2339: Property 'A2' does not exist on type 'typeof A'.
|
||||||
var ag2 = new A.A2<string, number>();
|
var ag2 = new A.A2<string, number>();
|
||||||
~~
|
~~
|
||||||
!!! Property 'A2' does not exist on type 'typeof A'.
|
!!! error TS2339: Property 'A2' does not exist on type 'typeof A'.
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedEnums.ts(10,11): error TS2339: Property 'Day' does not exist on type 'typeof A'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedEnums.ts (1 errors) ====
|
==== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedEnums.ts (1 errors) ====
|
||||||
module A {
|
module A {
|
||||||
export enum Color { Red, Blue }
|
export enum Color { Red, Blue }
|
||||||
|
@ -10,5 +13,5 @@
|
||||||
// error not exported
|
// error not exported
|
||||||
var b = A.Day.Monday;
|
var b = A.Day.Monday;
|
||||||
~~~
|
~~~
|
||||||
!!! Property 'Day' does not exist on type 'typeof A'.
|
!!! error TS2339: Property 'Day' does not exist on type 'typeof A'.
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedFunctions.ts(28,13): error TS2339: Property 'fn2' does not exist on type 'typeof A'.
|
||||||
|
tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedFunctions.ts(29,14): error TS2339: Property 'fng2' does not exist on type 'typeof A'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedFunctions.ts (2 errors) ====
|
==== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedFunctions.ts (2 errors) ====
|
||||||
module A {
|
module A {
|
||||||
|
|
||||||
|
@ -28,7 +32,7 @@
|
||||||
// these should be errors since the functions are not exported
|
// these should be errors since the functions are not exported
|
||||||
var fn2 = A.fn2;
|
var fn2 = A.fn2;
|
||||||
~~~
|
~~~
|
||||||
!!! Property 'fn2' does not exist on type 'typeof A'.
|
!!! error TS2339: Property 'fn2' does not exist on type 'typeof A'.
|
||||||
var fng2 = A.fng2;
|
var fng2 = A.fng2;
|
||||||
~~~~
|
~~~~
|
||||||
!!! Property 'fng2' does not exist on type 'typeof A'.
|
!!! error TS2339: Property 'fng2' does not exist on type 'typeof A'.
|
|
@ -1,3 +1,6 @@
|
||||||
|
tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedImportAlias.ts(37,21): error TS2339: Property 'Lines' does not exist on type 'typeof Geometry'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedImportAlias.ts (1 errors) ====
|
==== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedImportAlias.ts (1 errors) ====
|
||||||
module A {
|
module A {
|
||||||
export interface Point {
|
export interface Point {
|
||||||
|
@ -37,6 +40,6 @@
|
||||||
// not expected to work since non are exported
|
// not expected to work since non are exported
|
||||||
var line = Geometry.Lines.Line;
|
var line = Geometry.Lines.Line;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Property 'Lines' does not exist on type 'typeof Geometry'.
|
!!! error TS2339: Property 'Lines' does not exist on type 'typeof Geometry'.
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedVariables.ts(11,11): error TS2339: Property 'y' does not exist on type 'typeof A'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedVariables.ts (1 errors) ====
|
==== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedVariables.ts (1 errors) ====
|
||||||
module A {
|
module A {
|
||||||
export var x = 'hello world'
|
export var x = 'hello world'
|
||||||
|
@ -11,5 +14,5 @@
|
||||||
// Error, since y is not exported
|
// Error, since y is not exported
|
||||||
var y = A.y;
|
var y = A.y;
|
||||||
~
|
~
|
||||||
!!! Property 'y' does not exist on type 'typeof A'.
|
!!! error TS2339: Property 'y' does not exist on type 'typeof A'.
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
tests/cases/compiler/ParameterList13.ts(2,10): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ParameterList13.ts (1 errors) ====
|
==== tests/cases/compiler/ParameterList13.ts (1 errors) ====
|
||||||
interface I {
|
interface I {
|
||||||
new (public x);
|
new (public x);
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
}
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
|
tests/cases/compiler/ParameterList4.ts(1,12): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ParameterList4.ts (1 errors) ====
|
==== tests/cases/compiler/ParameterList4.ts (1 errors) ====
|
||||||
function F(public A) {
|
function F(public A) {
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
}
|
}
|
|
@ -1,9 +1,14 @@
|
||||||
|
tests/cases/compiler/ParameterList5.ts(1,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||||
|
tests/cases/compiler/ParameterList5.ts(1,16): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
tests/cases/compiler/ParameterList5.ts(1,29): error TS2304: Cannot find name 'C'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ParameterList5.ts (3 errors) ====
|
==== tests/cases/compiler/ParameterList5.ts (3 errors) ====
|
||||||
function A(): (public B) => C {
|
function A(): (public B) => C {
|
||||||
~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~
|
||||||
!!! A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
~
|
~
|
||||||
!!! Cannot find name 'C'.
|
!!! error TS2304: Cannot find name 'C'.
|
||||||
}
|
}
|
|
@ -1,7 +1,10 @@
|
||||||
|
tests/cases/compiler/ParameterList6.ts(2,19): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ParameterList6.ts (1 errors) ====
|
==== tests/cases/compiler/ParameterList6.ts (1 errors) ====
|
||||||
class C {
|
class C {
|
||||||
constructor(C: (public A) => any) {
|
constructor(C: (public A) => any) {
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,10 +1,14 @@
|
||||||
|
tests/cases/compiler/ParameterList7.ts(2,14): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
tests/cases/compiler/ParameterList7.ts(3,14): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ParameterList7.ts (2 errors) ====
|
==== tests/cases/compiler/ParameterList7.ts (2 errors) ====
|
||||||
class C1 {
|
class C1 {
|
||||||
constructor(public p1:string); // ERROR
|
constructor(public p1:string); // ERROR
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
constructor(private p2:number); // ERROR
|
constructor(private p2:number); // ERROR
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
constructor(public p3:any) {} // OK
|
constructor(public p3:any) {} // OK
|
||||||
}
|
}
|
|
@ -1,12 +1,17 @@
|
||||||
|
tests/cases/compiler/ParameterList8.ts(2,14): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
tests/cases/compiler/ParameterList8.ts(3,14): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
tests/cases/compiler/ParameterList8.ts(4,14): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ParameterList8.ts (3 errors) ====
|
==== tests/cases/compiler/ParameterList8.ts (3 errors) ====
|
||||||
declare class C2 {
|
declare class C2 {
|
||||||
constructor(public p1:string); // ERROR
|
constructor(public p1:string); // ERROR
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
constructor(private p2:number); // ERROR
|
constructor(private p2:number); // ERROR
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
constructor(public p3:any); // ERROR
|
constructor(public p3:any); // ERROR
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
}
|
}
|
|
@ -1,3 +1,7 @@
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts(10,18): error TS2300: Duplicate identifier 'Point'.
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts(26,26): error TS2300: Duplicate identifier 'Line'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts (2 errors) ====
|
==== tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts (2 errors) ====
|
||||||
module A {
|
module A {
|
||||||
export class Point {
|
export class Point {
|
||||||
|
@ -10,7 +14,7 @@
|
||||||
// expected error
|
// expected error
|
||||||
export class Point {
|
export class Point {
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Duplicate identifier 'Point'.
|
!!! error TS2300: Duplicate identifier 'Point'.
|
||||||
origin: number;
|
origin: number;
|
||||||
angle: number;
|
angle: number;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +32,7 @@
|
||||||
// expected error
|
// expected error
|
||||||
export class Line {
|
export class Line {
|
||||||
~~~~
|
~~~~
|
||||||
!!! Duplicate identifier 'Line'.
|
!!! error TS2300: Duplicate identifier 'Line'.
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/part1.ts(1,15): error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/part2.ts(3,24): error TS2304: Cannot find name 'Point'.
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/part2.ts(7,36): error TS2304: Cannot find name 'Point'.
|
||||||
|
tests/cases/conformance/internalModules/DeclarationMerging/part2.ts(7,54): error TS2304: Cannot find name 'Point'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/internalModules/DeclarationMerging/part1.ts (1 errors) ====
|
==== tests/cases/conformance/internalModules/DeclarationMerging/part1.ts (1 errors) ====
|
||||||
export module A {
|
export module A {
|
||||||
~
|
~
|
||||||
!!! Cannot compile external modules unless the '--module' flag is provided.
|
!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||||
export interface Point {
|
export interface Point {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
|
@ -21,15 +27,15 @@
|
||||||
// collision with 'Origin' var in other part of merged module
|
// collision with 'Origin' var in other part of merged module
|
||||||
export var Origin: Point = { x: 0, y: 0 };
|
export var Origin: Point = { x: 0, y: 0 };
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Cannot find name 'Point'.
|
!!! error TS2304: Cannot find name 'Point'.
|
||||||
|
|
||||||
export module Utils {
|
export module Utils {
|
||||||
export class Plane {
|
export class Plane {
|
||||||
constructor(public tl: Point, public br: Point) { }
|
constructor(public tl: Point, public br: Point) { }
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Cannot find name 'Point'.
|
!!! error TS2304: Cannot find name 'Point'.
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Cannot find name 'Point'.
|
!!! error TS2304: Cannot find name 'Point'.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
|
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,9): error TS1127: Invalid character.
|
||||||
|
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,1): error TS2304: Cannot find name 'Foo'.
|
||||||
|
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,5): error TS2304: Cannot find name 'A'.
|
||||||
|
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,7): error TS2304: Cannot find name 'B'.
|
||||||
|
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts(1,11): error TS2304: Cannot find name 'C'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts (5 errors) ====
|
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts (5 errors) ====
|
||||||
Foo<A,B,\ C>(4, 5, 6);
|
Foo<A,B,\ C>(4, 5, 6);
|
||||||
|
|
||||||
!!! Invalid character.
|
!!! error TS1127: Invalid character.
|
||||||
~~~
|
~~~
|
||||||
!!! Cannot find name 'Foo'.
|
!!! error TS2304: Cannot find name 'Foo'.
|
||||||
~
|
~
|
||||||
!!! Cannot find name 'A'.
|
!!! error TS2304: Cannot find name 'A'.
|
||||||
~
|
~
|
||||||
!!! Cannot find name 'B'.
|
!!! error TS2304: Cannot find name 'B'.
|
||||||
~
|
~
|
||||||
!!! Cannot find name 'C'.
|
!!! error TS2304: Cannot find name 'C'.
|
|
@ -1,14 +1,20 @@
|
||||||
|
tests/cases/compiler/accessorParameterAccessibilityModifier.ts(3,9): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
tests/cases/compiler/accessorParameterAccessibilityModifier.ts(4,16): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
tests/cases/compiler/accessorParameterAccessibilityModifier.ts(3,11): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
tests/cases/compiler/accessorParameterAccessibilityModifier.ts(4,18): error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/accessorParameterAccessibilityModifier.ts (4 errors) ====
|
==== tests/cases/compiler/accessorParameterAccessibilityModifier.ts (4 errors) ====
|
||||||
|
|
||||||
class C {
|
class C {
|
||||||
set X(public v) { }
|
set X(public v) { }
|
||||||
~
|
~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
static set X(public v2) { }
|
static set X(public v2) { }
|
||||||
~
|
~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
!!! A parameter property is only allowed in a constructor implementation.
|
!!! error TS2369: A parameter property is only allowed in a constructor implementation.
|
||||||
}
|
}
|
|
@ -1,3 +1,9 @@
|
||||||
|
tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithES3.ts(5,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithES3.ts(11,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithES3.ts(16,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithES3.ts(20,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithES3.ts (4 errors) ====
|
==== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithES3.ts (4 errors) ====
|
||||||
|
|
||||||
// error to use accessors in ES3 mode
|
// error to use accessors in ES3 mode
|
||||||
|
@ -5,7 +11,7 @@
|
||||||
class C {
|
class C {
|
||||||
get x() {
|
get x() {
|
||||||
~
|
~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,18 +19,18 @@
|
||||||
class D {
|
class D {
|
||||||
set x(v) {
|
set x(v) {
|
||||||
~
|
~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var x = {
|
var x = {
|
||||||
get a() { return 1 }
|
get a() { return 1 }
|
||||||
~
|
~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
}
|
}
|
||||||
|
|
||||||
var y = {
|
var y = {
|
||||||
set b(v) { }
|
set b(v) { }
|
||||||
~
|
~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
}
|
}
|
|
@ -1,10 +1,14 @@
|
||||||
|
tests/cases/compiler/accessorWithInitializer.ts(3,9): error TS1052: A 'set' accessor parameter cannot have an initializer.
|
||||||
|
tests/cases/compiler/accessorWithInitializer.ts(4,16): error TS1052: A 'set' accessor parameter cannot have an initializer.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/accessorWithInitializer.ts (2 errors) ====
|
==== tests/cases/compiler/accessorWithInitializer.ts (2 errors) ====
|
||||||
|
|
||||||
class C {
|
class C {
|
||||||
set X(v = 0) { }
|
set X(v = 0) { }
|
||||||
~
|
~
|
||||||
!!! A 'set' accessor parameter cannot have an initializer.
|
!!! error TS1052: A 'set' accessor parameter cannot have an initializer.
|
||||||
static set X(v2 = 0) { }
|
static set X(v2 = 0) { }
|
||||||
~
|
~
|
||||||
!!! A 'set' accessor parameter cannot have an initializer.
|
!!! error TS1052: A 'set' accessor parameter cannot have an initializer.
|
||||||
}
|
}
|
|
@ -1,10 +1,14 @@
|
||||||
|
tests/cases/compiler/accessorWithRestParam.ts(3,9): error TS1053: A 'set' accessor cannot have rest parameter.
|
||||||
|
tests/cases/compiler/accessorWithRestParam.ts(4,16): error TS1053: A 'set' accessor cannot have rest parameter.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/accessorWithRestParam.ts (2 errors) ====
|
==== tests/cases/compiler/accessorWithRestParam.ts (2 errors) ====
|
||||||
|
|
||||||
class C {
|
class C {
|
||||||
set X(...v) { }
|
set X(...v) { }
|
||||||
~
|
~
|
||||||
!!! A 'set' accessor cannot have rest parameter.
|
!!! error TS1053: A 'set' accessor cannot have rest parameter.
|
||||||
static set X(...v2) { }
|
static set X(...v2) { }
|
||||||
~
|
~
|
||||||
!!! A 'set' accessor cannot have rest parameter.
|
!!! error TS1053: A 'set' accessor cannot have rest parameter.
|
||||||
}
|
}
|
|
@ -1,15 +1,19 @@
|
||||||
|
tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorsAreNotContextuallyTyped.ts(4,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorsAreNotContextuallyTyped.ts(7,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorsAreNotContextuallyTyped.ts (2 errors) ====
|
==== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorsAreNotContextuallyTyped.ts (2 errors) ====
|
||||||
// accessors are not contextually typed
|
// accessors are not contextually typed
|
||||||
|
|
||||||
class C {
|
class C {
|
||||||
set x(v: (a: string) => string) {
|
set x(v: (a: string) => string) {
|
||||||
~
|
~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
}
|
}
|
||||||
|
|
||||||
get x() {
|
get x() {
|
||||||
~
|
~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
return (x: string) => "";
|
return (x: string) => "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
|
tests/cases/compiler/accessorsEmit.ts(4,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessorsEmit.ts(11,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/accessorsEmit.ts (2 errors) ====
|
==== tests/cases/compiler/accessorsEmit.ts (2 errors) ====
|
||||||
class Result { }
|
class Result { }
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
get Property(): Result {
|
get Property(): Result {
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
var x = 1;
|
var x = 1;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +17,7 @@
|
||||||
class Test2 {
|
class Test2 {
|
||||||
get Property() {
|
get Property() {
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
var x = 1;
|
var x = 1;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,35 +1,45 @@
|
||||||
|
tests/cases/compiler/accessorsInAmbientContext.ts(4,13): error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
|
tests/cases/compiler/accessorsInAmbientContext.ts(5,13): error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
|
tests/cases/compiler/accessorsInAmbientContext.ts(7,20): error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
|
tests/cases/compiler/accessorsInAmbientContext.ts(8,20): error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
|
tests/cases/compiler/accessorsInAmbientContext.ts(13,9): error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
|
tests/cases/compiler/accessorsInAmbientContext.ts(14,9): error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
|
tests/cases/compiler/accessorsInAmbientContext.ts(16,16): error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
|
tests/cases/compiler/accessorsInAmbientContext.ts(17,16): error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/accessorsInAmbientContext.ts (8 errors) ====
|
==== tests/cases/compiler/accessorsInAmbientContext.ts (8 errors) ====
|
||||||
|
|
||||||
declare module M {
|
declare module M {
|
||||||
class C {
|
class C {
|
||||||
get X() { return 1; }
|
get X() { return 1; }
|
||||||
~
|
~
|
||||||
!!! An accessor cannot be declared in an ambient context.
|
!!! error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
set X(v) { }
|
set X(v) { }
|
||||||
~
|
~
|
||||||
!!! An accessor cannot be declared in an ambient context.
|
!!! error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
|
|
||||||
static get Y() { return 1; }
|
static get Y() { return 1; }
|
||||||
~
|
~
|
||||||
!!! An accessor cannot be declared in an ambient context.
|
!!! error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
static set Y(v) { }
|
static set Y(v) { }
|
||||||
~
|
~
|
||||||
!!! An accessor cannot be declared in an ambient context.
|
!!! error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare class C {
|
declare class C {
|
||||||
get X() { return 1; }
|
get X() { return 1; }
|
||||||
~
|
~
|
||||||
!!! An accessor cannot be declared in an ambient context.
|
!!! error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
set X(v) { }
|
set X(v) { }
|
||||||
~
|
~
|
||||||
!!! An accessor cannot be declared in an ambient context.
|
!!! error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
|
|
||||||
static get Y() { return 1; }
|
static get Y() { return 1; }
|
||||||
~
|
~
|
||||||
!!! An accessor cannot be declared in an ambient context.
|
!!! error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
static set Y(v) { }
|
static set Y(v) { }
|
||||||
~
|
~
|
||||||
!!! An accessor cannot be declared in an ambient context.
|
!!! error TS1086: An accessor cannot be declared in an ambient context.
|
||||||
}
|
}
|
|
@ -1,11 +1,15 @@
|
||||||
|
tests/cases/compiler/accessorsNotAllowedInES3.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessorsNotAllowedInES3.ts(5,15): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/accessorsNotAllowedInES3.ts (2 errors) ====
|
==== tests/cases/compiler/accessorsNotAllowedInES3.ts (2 errors) ====
|
||||||
|
|
||||||
class C {
|
class C {
|
||||||
get x(): number { return 1; }
|
get x(): number { return 1; }
|
||||||
~
|
~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
}
|
}
|
||||||
var y = { get foo() { return 3; } };
|
var y = { get foo() { return 3; } };
|
||||||
~~~
|
~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
|
|
@ -1,38 +1,52 @@
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(6,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(8,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(11,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(12,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,55): error TS2323: Type 'string' is not assignable to type 'number'.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,54): error TS2323: Type 'string' is not assignable to type 'number'.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(9,52): error TS2323: Type 'number' is not assignable to type 'string'.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(11,51): error TS2323: Type 'number' is not assignable to type 'string'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts (12 errors) ====
|
==== tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts (12 errors) ====
|
||||||
class LanguageSpec_section_4_5_error_cases {
|
class LanguageSpec_section_4_5_error_cases {
|
||||||
public set AnnotatedSetter_SetterFirst(a: number) { }
|
public set AnnotatedSetter_SetterFirst(a: number) { }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
public get AnnotatedSetter_SetterFirst() { return ""; }
|
public get AnnotatedSetter_SetterFirst() { return ""; }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
~~
|
~~
|
||||||
!!! Type 'string' is not assignable to type 'number'.
|
!!! error TS2323: Type 'string' is not assignable to type 'number'.
|
||||||
|
|
||||||
public get AnnotatedSetter_SetterLast() { return ""; }
|
public get AnnotatedSetter_SetterLast() { return ""; }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
~~
|
~~
|
||||||
!!! Type 'string' is not assignable to type 'number'.
|
!!! error TS2323: Type 'string' is not assignable to type 'number'.
|
||||||
public set AnnotatedSetter_SetterLast(a: number) { }
|
public set AnnotatedSetter_SetterLast(a: number) { }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
|
||||||
public get AnnotatedGetter_GetterFirst(): string { return ""; }
|
public get AnnotatedGetter_GetterFirst(): string { return ""; }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
public set AnnotatedGetter_GetterFirst(aStr) { aStr = 0; }
|
public set AnnotatedGetter_GetterFirst(aStr) { aStr = 0; }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
~~~~
|
~~~~
|
||||||
!!! Type 'number' is not assignable to type 'string'.
|
!!! error TS2323: Type 'number' is not assignable to type 'string'.
|
||||||
|
|
||||||
public set AnnotatedGetter_GetterLast(aStr) { aStr = 0; }
|
public set AnnotatedGetter_GetterLast(aStr) { aStr = 0; }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
~~~~
|
~~~~
|
||||||
!!! Type 'number' is not assignable to type 'string'.
|
!!! error TS2323: Type 'number' is not assignable to type 'string'.
|
||||||
public get AnnotatedGetter_GetterLast(): string { return ""; }
|
public get AnnotatedGetter_GetterLast(): string { return ""; }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
}
|
}
|
|
@ -1,3 +1,17 @@
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_inference.ts(6,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_inference.ts(7,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_inference.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_inference.ts(10,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_inference.ts(13,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_inference.ts(14,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_inference.ts(16,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_inference.ts(17,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_inference.ts(19,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_inference.ts(20,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_inference.ts(22,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
tests/cases/compiler/accessors_spec_section-4.5_inference.ts(23,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/accessors_spec_section-4.5_inference.ts (12 errors) ====
|
==== tests/cases/compiler/accessors_spec_section-4.5_inference.ts (12 errors) ====
|
||||||
class A { }
|
class A { }
|
||||||
class B extends A { }
|
class B extends A { }
|
||||||
|
@ -6,44 +20,44 @@
|
||||||
|
|
||||||
public set InferredGetterFromSetterAnnotation(a: A) { }
|
public set InferredGetterFromSetterAnnotation(a: A) { }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
public get InferredGetterFromSetterAnnotation() { return new B(); }
|
public get InferredGetterFromSetterAnnotation() { return new B(); }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
|
||||||
public get InferredGetterFromSetterAnnotation_GetterFirst() { return new B(); }
|
public get InferredGetterFromSetterAnnotation_GetterFirst() { return new B(); }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
public set InferredGetterFromSetterAnnotation_GetterFirst(a: A) { }
|
public set InferredGetterFromSetterAnnotation_GetterFirst(a: A) { }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
|
||||||
|
|
||||||
public get InferredFromGetter() { return new B(); }
|
public get InferredFromGetter() { return new B(); }
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
public set InferredFromGetter(a) { }
|
public set InferredFromGetter(a) { }
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
|
||||||
public set InferredFromGetter_SetterFirst(a) { }
|
public set InferredFromGetter_SetterFirst(a) { }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
public get InferredFromGetter_SetterFirst() { return new B(); }
|
public get InferredFromGetter_SetterFirst() { return new B(); }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
|
||||||
public set InferredSetterFromGetterAnnotation(a) { }
|
public set InferredSetterFromGetterAnnotation(a) { }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
public get InferredSetterFromGetterAnnotation() : A { return new B(); }
|
public get InferredSetterFromGetterAnnotation() : A { return new B(); }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
|
|
||||||
public get InferredSetterFromGetterAnnotation_GetterFirst() : A { return new B(); }
|
public get InferredSetterFromGetterAnnotation_GetterFirst() : A { return new B(); }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
public set InferredSetterFromGetterAnnotation_GetterFirst(a) { }
|
public set InferredSetterFromGetterAnnotation_GetterFirst(a) { }
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Accessors are only available when targeting ECMAScript 5 and higher.
|
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||||
}
|
}
|
|
@ -1,3 +1,8 @@
|
||||||
|
tests/cases/compiler/addMoreOverloadsToBaseSignature.ts(5,11): error TS2429: Interface 'Bar' incorrectly extends interface 'Foo':
|
||||||
|
Types of property 'f' are incompatible:
|
||||||
|
Type '(key: string) => string' is not assignable to type '() => string'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/addMoreOverloadsToBaseSignature.ts (1 errors) ====
|
==== tests/cases/compiler/addMoreOverloadsToBaseSignature.ts (1 errors) ====
|
||||||
interface Foo {
|
interface Foo {
|
||||||
f(): string;
|
f(): string;
|
||||||
|
@ -5,9 +10,9 @@
|
||||||
|
|
||||||
interface Bar extends Foo {
|
interface Bar extends Foo {
|
||||||
~~~
|
~~~
|
||||||
!!! Interface 'Bar' incorrectly extends interface 'Foo':
|
!!! error TS2429: Interface 'Bar' incorrectly extends interface 'Foo':
|
||||||
!!! Types of property 'f' are incompatible:
|
!!! error TS2429: Types of property 'f' are incompatible:
|
||||||
!!! Type '(key: string) => string' is not assignable to type '() => string'.
|
!!! error TS2429: Type '(key: string) => string' is not assignable to type '() => string'.
|
||||||
f(key: string): string;
|
f(key: string): string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'number'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(17,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'Object'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(22,10): error TS2365: Operator '+' cannot be applied to types 'number' and 'Object'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(25,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'boolean'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(26,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'number'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(27,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(30,11): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(31,11): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(32,11): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'number'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(33,11): error TS2365: Operator '+' cannot be applied to types '{}' and '{}'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(34,11): error TS2365: Operator '+' cannot be applied to types 'number' and 'Number'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(35,11): error TS2365: Operator '+' cannot be applied to types 'number' and '() => void'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(36,11): error TS2365: Operator '+' cannot be applied to types 'number' and 'void'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(37,11): error TS2365: Operator '+' cannot be applied to types 'number' and 'typeof C'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(38,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'C'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(39,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'void'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(40,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'typeof M'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts (19 errors) ====
|
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts (19 errors) ====
|
||||||
function foo() { }
|
function foo() { }
|
||||||
class C {
|
class C {
|
||||||
|
@ -15,65 +36,65 @@
|
||||||
// boolean + every type except any and string
|
// boolean + every type except any and string
|
||||||
var r1 = a + a;
|
var r1 = a + a;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
var r2 = a + b;
|
var r2 = a + b;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'boolean' and 'number'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'number'.
|
||||||
var r3 = a + c;
|
var r3 = a + c;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'boolean' and 'Object'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'Object'.
|
||||||
|
|
||||||
// number + every type except any and string
|
// number + every type except any and string
|
||||||
var r4 = b + a;
|
var r4 = b + a;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'number' and 'boolean'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'.
|
||||||
var r5 = b + b; // number + number is valid
|
var r5 = b + b; // number + number is valid
|
||||||
var r6 = b + c;
|
var r6 = b + c;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'number' and 'Object'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'Object'.
|
||||||
|
|
||||||
// object + every type except any and string
|
// object + every type except any and string
|
||||||
var r7 = c + a;
|
var r7 = c + a;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'Object' and 'boolean'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'boolean'.
|
||||||
var r8 = c + b;
|
var r8 = c + b;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'Object' and 'number'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'number'.
|
||||||
var r9 = c + c;
|
var r9 = c + c;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'Object' and 'Object'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'.
|
||||||
|
|
||||||
// other cases
|
// other cases
|
||||||
var r10 = a + true;
|
var r10 = a + true;
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
var r11 = true + false;
|
var r11 = true + false;
|
||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
var r12 = true + 123;
|
var r12 = true + 123;
|
||||||
~~~~~~~~~~
|
~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'boolean' and 'number'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'number'.
|
||||||
var r13 = {} + {};
|
var r13 = {} + {};
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types '{}' and '{}'.
|
!!! error TS2365: Operator '+' cannot be applied to types '{}' and '{}'.
|
||||||
var r14 = b + d;
|
var r14 = b + d;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'number' and 'Number'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'Number'.
|
||||||
var r15 = b + foo;
|
var r15 = b + foo;
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'number' and '() => void'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'number' and '() => void'.
|
||||||
var r16 = b + foo();
|
var r16 = b + foo();
|
||||||
~~~~~~~~~
|
~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'number' and 'void'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'void'.
|
||||||
var r17 = b + C;
|
var r17 = b + C;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'number' and 'typeof C'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'typeof C'.
|
||||||
var r18 = E.a + new C();
|
var r18 = E.a + new C();
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'E' and 'C'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'C'.
|
||||||
var r19 = E.a + C.foo();
|
var r19 = E.a + C.foo();
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'E' and 'void'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'void'.
|
||||||
var r20 = E.a + M;
|
var r20 = E.a + M;
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'E' and 'typeof M'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'typeof M'.
|
|
@ -1,3 +1,16 @@
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(11,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(12,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(13,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(14,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(21,10): error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(23,11): error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts (11 errors) ====
|
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts (11 errors) ====
|
||||||
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
|
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
|
||||||
|
|
||||||
|
@ -11,36 +24,36 @@
|
||||||
// null + boolean/Object
|
// null + boolean/Object
|
||||||
var r1 = null + a;
|
var r1 = null + a;
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
var r2 = null + b;
|
var r2 = null + b;
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'Object' and 'Object'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'.
|
||||||
var r3 = null + c;
|
var r3 = null + c;
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'void' and 'void'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||||
var r4 = a + null;
|
var r4 = a + null;
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
var r5 = b + null;
|
var r5 = b + null;
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'Object' and 'Object'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'.
|
||||||
var r6 = null + c;
|
var r6 = null + c;
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'void' and 'void'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||||
|
|
||||||
// other cases
|
// other cases
|
||||||
var r7 = null + d;
|
var r7 = null + d;
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'Number' and 'Number'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'.
|
||||||
var r8 = null + true;
|
var r8 = null + true;
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
var r9 = null + { a: '' };
|
var r9 = null + { a: '' };
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'.
|
!!! error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'.
|
||||||
var r10 = null + foo();
|
var r10 = null + foo();
|
||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'void' and 'void'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||||
var r11 = null + (() => { });
|
var r11 = null + (() => { });
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types '() => void' and '() => void'.
|
!!! error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'.
|
|
@ -1,14 +1,20 @@
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(2,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(3,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(4,10): error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts(5,10): error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts (4 errors) ====
|
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts (4 errors) ====
|
||||||
// bug 819721
|
// bug 819721
|
||||||
var r1 = null + null;
|
var r1 = null + null;
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'null' and 'null'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
||||||
var r2 = null + undefined;
|
var r2 = null + undefined;
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
||||||
var r3 = undefined + null;
|
var r3 = undefined + null;
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'null' and 'null'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'null' and 'null'.
|
||||||
var r4 = undefined + undefined;
|
var r4 = undefined + undefined;
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'undefined' and 'undefined'.
|
|
@ -1,3 +1,21 @@
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(15,14): error TS2365: Operator '+' cannot be applied to types 'T' and 'boolean'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(16,14): error TS2365: Operator '+' cannot be applied to types 'T' and 'number'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(18,14): error TS2365: Operator '+' cannot be applied to types 'T' and 'Object'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(19,14): error TS2365: Operator '+' cannot be applied to types 'T' and 'E'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(20,14): error TS2365: Operator '+' cannot be applied to types 'T' and 'void'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(24,14): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'T'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(25,15): error TS2365: Operator '+' cannot be applied to types 'number' and 'T'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(27,15): error TS2365: Operator '+' cannot be applied to types 'Object' and 'T'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(28,15): error TS2365: Operator '+' cannot be applied to types 'E' and 'T'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(29,15): error TS2365: Operator '+' cannot be applied to types 'void' and 'T'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(32,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(33,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(34,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'T'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(35,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'U'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(36,15): error TS2365: Operator '+' cannot be applied to types 'T' and '() => void'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts(37,15): error TS2365: Operator '+' cannot be applied to types 'T' and 'undefined[]'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts (16 errors) ====
|
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts (16 errors) ====
|
||||||
// type parameter type is not a valid operand of addition operator
|
// type parameter type is not a valid operand of addition operator
|
||||||
enum E { a, b }
|
enum E { a, b }
|
||||||
|
@ -15,57 +33,57 @@
|
||||||
var r1: any = t + a; // ok, one operand is any
|
var r1: any = t + a; // ok, one operand is any
|
||||||
var r2 = t + b;
|
var r2 = t + b;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'T' and 'boolean'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'boolean'.
|
||||||
var r3 = t + c;
|
var r3 = t + c;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'T' and 'number'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'number'.
|
||||||
var r4 = t + d; // ok, one operand is string
|
var r4 = t + d; // ok, one operand is string
|
||||||
var r5 = t + e;
|
var r5 = t + e;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'T' and 'Object'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'Object'.
|
||||||
var r6 = t + g;
|
var r6 = t + g;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'T' and 'E'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'E'.
|
||||||
var r7 = t + f;
|
var r7 = t + f;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'T' and 'void'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'void'.
|
||||||
|
|
||||||
// type parameter as right operand
|
// type parameter as right operand
|
||||||
var r8 = a + t; // ok, one operand is any
|
var r8 = a + t; // ok, one operand is any
|
||||||
var r9 = b + t;
|
var r9 = b + t;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'boolean' and 'T'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'T'.
|
||||||
var r10 = c + t;
|
var r10 = c + t;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'number' and 'T'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'T'.
|
||||||
var r11 = d + t; // ok, one operand is string
|
var r11 = d + t; // ok, one operand is string
|
||||||
var r12 = e + t;
|
var r12 = e + t;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'Object' and 'T'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'T'.
|
||||||
var r13 = g + t;
|
var r13 = g + t;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'E' and 'T'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'T'.
|
||||||
var r14 = f + t;
|
var r14 = f + t;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'void' and 'T'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'T'.
|
||||||
|
|
||||||
// other cases
|
// other cases
|
||||||
var r15 = t + null;
|
var r15 = t + null;
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'T' and 'T'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'.
|
||||||
var r16 = t + undefined;
|
var r16 = t + undefined;
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'T' and 'T'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'.
|
||||||
var r17 = t + t;
|
var r17 = t + t;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'T' and 'T'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'T'.
|
||||||
var r18 = t + u;
|
var r18 = t + u;
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'T' and 'U'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'U'.
|
||||||
var r19 = t + (() => { });
|
var r19 = t + (() => { });
|
||||||
~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'T' and '() => void'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'T' and '() => void'.
|
||||||
var r20 = t + [];
|
var r20 = t + [];
|
||||||
~~~~~~
|
~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'T' and 'undefined[]'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'T' and 'undefined[]'.
|
||||||
}
|
}
|
|
@ -1,3 +1,16 @@
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(11,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(12,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(13,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(14,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(21,10): error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||||
|
tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(23,11): error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts (11 errors) ====
|
==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts (11 errors) ====
|
||||||
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
|
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
|
||||||
|
|
||||||
|
@ -11,36 +24,36 @@
|
||||||
// undefined + boolean/Object
|
// undefined + boolean/Object
|
||||||
var r1 = undefined + a;
|
var r1 = undefined + a;
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
var r2 = undefined + b;
|
var r2 = undefined + b;
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'Object' and 'Object'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'.
|
||||||
var r3 = undefined + c;
|
var r3 = undefined + c;
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'void' and 'void'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||||
var r4 = a + undefined;
|
var r4 = a + undefined;
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
var r5 = b + undefined;
|
var r5 = b + undefined;
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'Object' and 'Object'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'.
|
||||||
var r6 = undefined + c;
|
var r6 = undefined + c;
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'void' and 'void'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||||
|
|
||||||
// other cases
|
// other cases
|
||||||
var r7 = undefined + d;
|
var r7 = undefined + d;
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'Number' and 'Number'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'.
|
||||||
var r8 = undefined + true;
|
var r8 = undefined + true;
|
||||||
~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'.
|
||||||
var r9 = undefined + { a: '' };
|
var r9 = undefined + { a: '' };
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'.
|
!!! error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'.
|
||||||
var r10 = undefined + foo();
|
var r10 = undefined + foo();
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types 'void' and 'void'.
|
!!! error TS2365: Operator '+' cannot be applied to types 'void' and 'void'.
|
||||||
var r11 = undefined + (() => { });
|
var r11 = undefined + (() => { });
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Operator '+' cannot be applied to types '() => void' and '() => void'.
|
!!! error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'.
|
|
@ -1,14 +1,19 @@
|
||||||
|
tests/cases/compiler/aliasAssignments_1.ts(3,1): error TS2322: Type 'number' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"':
|
||||||
|
Property 'someClass' is missing in type 'Number'.
|
||||||
|
tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2323: Type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"' is not assignable to type 'number'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/aliasAssignments_1.ts (2 errors) ====
|
==== tests/cases/compiler/aliasAssignments_1.ts (2 errors) ====
|
||||||
import moduleA = require("aliasAssignments_moduleA");
|
import moduleA = require("aliasAssignments_moduleA");
|
||||||
var x = moduleA;
|
var x = moduleA;
|
||||||
x = 1; // Should be error
|
x = 1; // Should be error
|
||||||
~
|
~
|
||||||
!!! Type 'number' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"':
|
!!! error TS2322: Type 'number' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"':
|
||||||
!!! Property 'someClass' is missing in type 'Number'.
|
!!! error TS2322: Property 'someClass' is missing in type 'Number'.
|
||||||
var y = 1;
|
var y = 1;
|
||||||
y = moduleA; // should be error
|
y = moduleA; // should be error
|
||||||
~
|
~
|
||||||
!!! Type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"' is not assignable to type 'number'.
|
!!! error TS2323: Type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"' is not assignable to type 'number'.
|
||||||
|
|
||||||
==== tests/cases/compiler/aliasAssignments_moduleA.ts (0 errors) ====
|
==== tests/cases/compiler/aliasAssignments_moduleA.ts (0 errors) ====
|
||||||
export class someClass {
|
export class someClass {
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
tests/cases/compiler/aliasBug.ts(17,10): error TS2305: Module 'foo.bar.baz' has no exported member 'bar'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/aliasBug.ts (1 errors) ====
|
==== tests/cases/compiler/aliasBug.ts (1 errors) ====
|
||||||
|
|
||||||
module foo {
|
module foo {
|
||||||
|
@ -17,7 +20,7 @@
|
||||||
var p2: foo.Provide;
|
var p2: foo.Provide;
|
||||||
var p3:booz.bar;
|
var p3:booz.bar;
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! Module 'foo.bar.baz' has no exported member 'bar'.
|
!!! error TS2305: Module 'foo.bar.baz' has no exported member 'bar'.
|
||||||
var p22 = new provide.Provide();
|
var p22 = new provide.Provide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
tests/cases/compiler/aliasErrors.ts(13,12): error TS1003: Identifier expected.
|
||||||
|
tests/cases/compiler/aliasErrors.ts(14,12): error TS1003: Identifier expected.
|
||||||
|
tests/cases/compiler/aliasErrors.ts(15,12): error TS1003: Identifier expected.
|
||||||
|
tests/cases/compiler/aliasErrors.ts(11,1): error TS2304: Cannot find name 'no'.
|
||||||
|
tests/cases/compiler/aliasErrors.ts(12,1): error TS2304: Cannot find name 'no'.
|
||||||
|
tests/cases/compiler/aliasErrors.ts(16,1): error TS2304: Cannot find name 'undefined'.
|
||||||
|
tests/cases/compiler/aliasErrors.ts(26,10): error TS2305: Module 'foo.bar.baz' has no exported member 'bar'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/aliasErrors.ts (7 errors) ====
|
==== tests/cases/compiler/aliasErrors.ts (7 errors) ====
|
||||||
module foo {
|
module foo {
|
||||||
export class Provide {
|
export class Provide {
|
||||||
|
@ -11,22 +20,22 @@
|
||||||
|
|
||||||
import m = no;
|
import m = no;
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
!!! Cannot find name 'no'.
|
!!! error TS2304: Cannot find name 'no'.
|
||||||
import m2 = no.mod;
|
import m2 = no.mod;
|
||||||
~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Cannot find name 'no'.
|
!!! error TS2304: Cannot find name 'no'.
|
||||||
import n = 5;
|
import n = 5;
|
||||||
~
|
~
|
||||||
!!! Identifier expected.
|
!!! error TS1003: Identifier expected.
|
||||||
import o = "s";
|
import o = "s";
|
||||||
~~~
|
~~~
|
||||||
!!! Identifier expected.
|
!!! error TS1003: Identifier expected.
|
||||||
import q = null;
|
import q = null;
|
||||||
~~~~
|
~~~~
|
||||||
!!! Identifier expected.
|
!!! error TS1003: Identifier expected.
|
||||||
import r = undefined;
|
import r = undefined;
|
||||||
~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Cannot find name 'undefined'.
|
!!! error TS2304: Cannot find name 'undefined'.
|
||||||
|
|
||||||
|
|
||||||
var p = new provide.Provide();
|
var p = new provide.Provide();
|
||||||
|
@ -38,7 +47,7 @@
|
||||||
var p2: foo.Provide;
|
var p2: foo.Provide;
|
||||||
var p3:booz.bar;
|
var p3:booz.bar;
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! Module 'foo.bar.baz' has no exported member 'bar'.
|
!!! error TS2305: Module 'foo.bar.baz' has no exported member 'bar'.
|
||||||
var p22 = new provide.Provide();
|
var p22 = new provide.Provide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
tests/cases/compiler/aliasInaccessibleModule.ts(4,5): error TS4000: Import declaration 'X' is using private name 'N'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/aliasInaccessibleModule.ts (1 errors) ====
|
==== tests/cases/compiler/aliasInaccessibleModule.ts (1 errors) ====
|
||||||
module M {
|
module M {
|
||||||
module N {
|
module N {
|
||||||
}
|
}
|
||||||
export import X = N;
|
export import X = N;
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Import declaration 'X' is using private name 'N'.
|
!!! error TS4000: Import declaration 'X' is using private name 'N'.
|
||||||
}
|
}
|
|
@ -1,3 +1,6 @@
|
||||||
|
tests/cases/compiler/aliasInaccessibleModule2.ts(7,5): error TS4000: Import declaration 'R' is using private name 'N'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/aliasInaccessibleModule2.ts (1 errors) ====
|
==== tests/cases/compiler/aliasInaccessibleModule2.ts (1 errors) ====
|
||||||
module M {
|
module M {
|
||||||
module N {
|
module N {
|
||||||
|
@ -7,6 +10,6 @@
|
||||||
}
|
}
|
||||||
import R = N;
|
import R = N;
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
!!! Import declaration 'R' is using private name 'N'.
|
!!! error TS4000: Import declaration 'R' is using private name 'N'.
|
||||||
export import X = R;
|
export import X = R;
|
||||||
}
|
}
|
|
@ -1,3 +1,6 @@
|
||||||
|
tests/cases/compiler/aliasOnMergedModuleInterface_1.ts(5,16): error TS2304: Cannot find name 'foo'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/aliasOnMergedModuleInterface_1.ts (1 errors) ====
|
==== tests/cases/compiler/aliasOnMergedModuleInterface_1.ts (1 errors) ====
|
||||||
///<reference path='aliasOnMergedModuleInterface_0.ts' />
|
///<reference path='aliasOnMergedModuleInterface_0.ts' />
|
||||||
import foo = require("foo")
|
import foo = require("foo")
|
||||||
|
@ -5,7 +8,7 @@
|
||||||
z.bar("hello"); // This should be ok
|
z.bar("hello"); // This should be ok
|
||||||
var x: foo.A = foo.bar("hello"); // foo.A should be ok but foo.bar should be error
|
var x: foo.A = foo.bar("hello"); // foo.A should be ok but foo.bar should be error
|
||||||
~~~
|
~~~
|
||||||
!!! Cannot find name 'foo'.
|
!!! error TS2304: Cannot find name 'foo'.
|
||||||
|
|
||||||
==== tests/cases/compiler/aliasOnMergedModuleInterface_0.ts (0 errors) ====
|
==== tests/cases/compiler/aliasOnMergedModuleInterface_0.ts (0 errors) ====
|
||||||
declare module "foo"
|
declare module "foo"
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts(2,9): error TS2304: Cannot find name 'b'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts (1 errors) ====
|
==== tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts (1 errors) ====
|
||||||
import moduleA = require("aliasWithInterfaceExportAssignmentUsedInVarInitializer_0");
|
import moduleA = require("aliasWithInterfaceExportAssignmentUsedInVarInitializer_0");
|
||||||
var d = b.q3;
|
var d = b.q3;
|
||||||
~
|
~
|
||||||
!!! Cannot find name 'b'.
|
!!! error TS2304: Cannot find name 'b'.
|
||||||
==== tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer_0.ts (0 errors) ====
|
==== tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer_0.ts (0 errors) ====
|
||||||
interface c {
|
interface c {
|
||||||
q3: number;
|
q3: number;
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
tests/cases/compiler/ambientClassOverloadForFunction.ts(2,10): error TS2300: Duplicate identifier 'foo'.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ambientClassOverloadForFunction.ts (1 errors) ====
|
==== tests/cases/compiler/ambientClassOverloadForFunction.ts (1 errors) ====
|
||||||
declare class foo{};
|
declare class foo{};
|
||||||
function foo() { return null; }
|
function foo() { return null; }
|
||||||
~~~
|
~~~
|
||||||
!!! Duplicate identifier 'foo'.
|
!!! error TS2300: Duplicate identifier 'foo'.
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
|
tests/cases/conformance/ambient/consumer.ts(2,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/ambient/consumer.ts (1 errors) ====
|
==== tests/cases/conformance/ambient/consumer.ts (1 errors) ====
|
||||||
/// <reference path="decls.ts" />
|
/// <reference path="decls.ts" />
|
||||||
import imp1 = require('equ');
|
import imp1 = require('equ');
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Cannot compile external modules unless the '--module' flag is provided.
|
!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||||
|
|
||||||
|
|
||||||
// Ambient external module members are always exported with or without export keyword when module lacks export assignment
|
// Ambient external module members are always exported with or without export keyword when module lacks export assignment
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
tests/cases/compiler/ambientEnumElementInitializer3.ts(2,2): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/compiler/ambientEnumElementInitializer3.ts (1 errors) ====
|
==== tests/cases/compiler/ambientEnumElementInitializer3.ts (1 errors) ====
|
||||||
declare enum E {
|
declare enum E {
|
||||||
e = 3.3 // Decimal
|
e = 3.3 // Decimal
|
||||||
~
|
~
|
||||||
!!! Ambient enum elements can only have integer literal initializers.
|
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||||
}
|
}
|
|
@ -1,14 +1,32 @@
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(2,15): error TS1039: Initializers are not allowed in ambient contexts.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(20,24): error TS1037: A function implementation cannot be declared in an ambient context.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(24,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(29,5): error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(34,11): error TS1039: Initializers are not allowed in ambient contexts.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(35,19): error TS1037: A function implementation cannot be declared in an ambient context.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(37,18): error TS1039: Initializers are not allowed in ambient contexts.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(38,11): error TS1039: Initializers are not allowed in ambient contexts.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(39,23): error TS1111: A constructor implementation cannot be declared in an ambient context.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(40,14): error TS1037: A function implementation cannot be declared in an ambient context.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(41,22): error TS1037: A function implementation cannot be declared in an ambient context.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(6,1): error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(17,22): error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(47,20): error TS2435: Ambient external modules cannot be nested in other modules.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(51,16): error TS2436: Ambient external module declaration cannot specify relative module name.
|
||||||
|
tests/cases/conformance/ambient/ambientErrors.ts(57,5): error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||||
|
|
||||||
|
|
||||||
==== tests/cases/conformance/ambient/ambientErrors.ts (16 errors) ====
|
==== tests/cases/conformance/ambient/ambientErrors.ts (16 errors) ====
|
||||||
// Ambient variable with an initializer
|
// Ambient variable with an initializer
|
||||||
declare var x = 4;
|
declare var x = 4;
|
||||||
~
|
~
|
||||||
!!! Initializers are not allowed in ambient contexts.
|
!!! error TS1039: Initializers are not allowed in ambient contexts.
|
||||||
|
|
||||||
// Ambient functions with invalid overloads
|
// Ambient functions with invalid overloads
|
||||||
declare function fn(x: number): string;
|
declare function fn(x: number): string;
|
||||||
declare function fn(x: 'foo'): number;
|
declare function fn(x: 'foo'): number;
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
!!! Specialized overload signature is not assignable to any non-specialized signature.
|
!!! error TS2382: Specialized overload signature is not assignable to any non-specialized signature.
|
||||||
|
|
||||||
// Ambient functions with duplicate signatures
|
// Ambient functions with duplicate signatures
|
||||||
declare function fn1(x: number): string;
|
declare function fn1(x: number): string;
|
||||||
|
@ -21,51 +39,51 @@
|
||||||
// Ambient function with default parameter values
|
// Ambient function with default parameter values
|
||||||
declare function fn3(x = 3);
|
declare function fn3(x = 3);
|
||||||
~~~~~
|
~~~~~
|
||||||
!!! A parameter initializer is only allowed in a function or constructor implementation.
|
!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation.
|
||||||
|
|
||||||
// Ambient function with function body
|
// Ambient function with function body
|
||||||
declare function fn4() { };
|
declare function fn4() { };
|
||||||
~
|
~
|
||||||
!!! A function implementation cannot be declared in an ambient context.
|
!!! error TS1037: A function implementation cannot be declared in an ambient context.
|
||||||
|
|
||||||
// Ambient enum with non - integer literal constant member
|
// Ambient enum with non - integer literal constant member
|
||||||
declare enum E1 {
|
declare enum E1 {
|
||||||
y = 4.23
|
y = 4.23
|
||||||
~
|
~
|
||||||
!!! Ambient enum elements can only have integer literal initializers.
|
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ambient enum with computer member
|
// Ambient enum with computer member
|
||||||
declare enum E2 {
|
declare enum E2 {
|
||||||
x = 'foo'.length
|
x = 'foo'.length
|
||||||
~
|
~
|
||||||
!!! Ambient enum elements can only have integer literal initializers.
|
!!! error TS1066: Ambient enum elements can only have integer literal initializers.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ambient module with initializers for values, bodies for functions / classes
|
// Ambient module with initializers for values, bodies for functions / classes
|
||||||
declare module M1 {
|
declare module M1 {
|
||||||
var x = 3;
|
var x = 3;
|
||||||
~
|
~
|
||||||
!!! Initializers are not allowed in ambient contexts.
|
!!! error TS1039: Initializers are not allowed in ambient contexts.
|
||||||
function fn() { }
|
function fn() { }
|
||||||
~
|
~
|
||||||
!!! A function implementation cannot be declared in an ambient context.
|
!!! error TS1037: A function implementation cannot be declared in an ambient context.
|
||||||
class C {
|
class C {
|
||||||
static x = 3;
|
static x = 3;
|
||||||
~
|
~
|
||||||
!!! Initializers are not allowed in ambient contexts.
|
!!! error TS1039: Initializers are not allowed in ambient contexts.
|
||||||
y = 4;
|
y = 4;
|
||||||
~
|
~
|
||||||
!!! Initializers are not allowed in ambient contexts.
|
!!! error TS1039: Initializers are not allowed in ambient contexts.
|
||||||
constructor() { }
|
constructor() { }
|
||||||
~
|
~
|
||||||
!!! A constructor implementation cannot be declared in an ambient context.
|
!!! error TS1111: A constructor implementation cannot be declared in an ambient context.
|
||||||
fn() { }
|
fn() { }
|
||||||
~
|
~
|
||||||
!!! A function implementation cannot be declared in an ambient context.
|
!!! error TS1037: A function implementation cannot be declared in an ambient context.
|
||||||
static sfn() { }
|
static sfn() { }
|
||||||
~
|
~
|
||||||
!!! A function implementation cannot be declared in an ambient context.
|
!!! error TS1037: A function implementation cannot be declared in an ambient context.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,13 +91,13 @@
|
||||||
module M2 {
|
module M2 {
|
||||||
declare module 'nope' { }
|
declare module 'nope' { }
|
||||||
~~~~~~
|
~~~~~~
|
||||||
!!! Ambient external modules cannot be nested in other modules.
|
!!! error TS2435: Ambient external modules cannot be nested in other modules.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ambient external module with a string literal name that isn't a top level external module name
|
// Ambient external module with a string literal name that isn't a top level external module name
|
||||||
declare module '../foo' { }
|
declare module '../foo' { }
|
||||||
~~~~~~~~
|
~~~~~~~~
|
||||||
!!! Ambient external module declaration cannot specify relative module name.
|
!!! error TS2436: Ambient external module declaration cannot specify relative module name.
|
||||||
|
|
||||||
// Ambient external module with export assignment and other exported members
|
// Ambient external module with export assignment and other exported members
|
||||||
declare module 'bar' {
|
declare module 'bar' {
|
||||||
|
@ -87,6 +105,6 @@
|
||||||
export var q;
|
export var q;
|
||||||
export = n;
|
export = n;
|
||||||
~~~~~~~~~~~
|
~~~~~~~~~~~
|
||||||
!!! An export assignment cannot be used in a module with other exported elements.
|
!!! error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue