mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into pvb/codeaction/api
This commit is contained in:
+38
-13
@@ -3346,7 +3346,13 @@ namespace ts {
|
||||
// Otherwise, fall back to 'any'.
|
||||
else {
|
||||
if (compilerOptions.noImplicitAny) {
|
||||
error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol));
|
||||
if (setter) {
|
||||
error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
|
||||
}
|
||||
else {
|
||||
Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function");
|
||||
error(getter, Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
|
||||
}
|
||||
}
|
||||
type = anyType;
|
||||
}
|
||||
@@ -11960,18 +11966,12 @@ namespace ts {
|
||||
// Function interface, since they have none by default. This is a bit of a leap of faith
|
||||
// that the user will not add any.
|
||||
const callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call);
|
||||
|
||||
const constructSignatures = getSignaturesOfType(apparentType, SignatureKind.Construct);
|
||||
// TS 1.0 spec: 4.12
|
||||
// If FuncExpr is of type Any, or of an object type that has no call or construct signatures
|
||||
// but is a subtype of the Function interface, the call is an untyped function call. In an
|
||||
// untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual
|
||||
|
||||
// TS 1.0 Spec: 4.12
|
||||
// In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual
|
||||
// types are provided for the argument expressions, and the result is always of type Any.
|
||||
// We exclude union types because we may have a union of function types that happen to have
|
||||
// no common signatures.
|
||||
if (isTypeAny(funcType) ||
|
||||
(isTypeAny(apparentType) && funcType.flags & TypeFlags.TypeParameter) ||
|
||||
(!callSignatures.length && !constructSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) {
|
||||
if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, constructSignatures.length)) {
|
||||
// The unknownType indicates that an error already occurred (and was reported). No
|
||||
// need to report another error in this case.
|
||||
if (funcType !== unknownType && node.typeArguments) {
|
||||
@@ -11994,6 +11994,29 @@ namespace ts {
|
||||
return resolveCall(node, callSignatures, candidatesOutArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* TS 1.0 spec: 4.12
|
||||
* If FuncExpr is of type Any, or of an object type that has no call or construct signatures
|
||||
* but is a subtype of the Function interface, the call is an untyped function call.
|
||||
*/
|
||||
function isUntypedFunctionCall(funcType: Type, apparentFuncType: Type, numCallSignatures: number, numConstructSignatures: number) {
|
||||
if (isTypeAny(funcType)) {
|
||||
return true;
|
||||
}
|
||||
if (isTypeAny(apparentFuncType) && funcType.flags & TypeFlags.TypeParameter) {
|
||||
return true;
|
||||
}
|
||||
if (!numCallSignatures && !numConstructSignatures) {
|
||||
// We exclude union types because we may have a union of function types that happen to have
|
||||
// no common signatures.
|
||||
if (funcType.flags & TypeFlags.Union) {
|
||||
return false;
|
||||
}
|
||||
return isTypeAssignableTo(funcType, globalFunctionType);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function resolveNewExpression(node: NewExpression, candidatesOutArray: Signature[]): Signature {
|
||||
if (node.arguments && languageVersion < ScriptTarget.ES5) {
|
||||
const spreadIndex = getSpreadArgumentIndex(node.arguments);
|
||||
@@ -12119,8 +12142,9 @@ namespace ts {
|
||||
}
|
||||
|
||||
const callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call);
|
||||
const constructSignatures = getSignaturesOfType(apparentType, SignatureKind.Construct);
|
||||
|
||||
if (isTypeAny(tagType) || (!callSignatures.length && !(tagType.flags & TypeFlags.Union) && isTypeAssignableTo(tagType, globalFunctionType))) {
|
||||
if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, constructSignatures.length)) {
|
||||
return resolveUntypedCall(node);
|
||||
}
|
||||
|
||||
@@ -12165,7 +12189,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
const callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call);
|
||||
if (funcType === anyType || (!callSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) {
|
||||
const constructSignatures = getSignaturesOfType(apparentType, SignatureKind.Construct);
|
||||
if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, constructSignatures.length)) {
|
||||
return resolveUntypedCall(node);
|
||||
}
|
||||
|
||||
|
||||
@@ -2871,11 +2871,7 @@
|
||||
"Element implicitly has an 'any' type because index expression is not of type 'number'.": {
|
||||
"category": "Error",
|
||||
"code": 7015
|
||||
},
|
||||
"Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 7016
|
||||
},
|
||||
},
|
||||
"Index signature of object type implicitly has an 'any' type.": {
|
||||
"category": "Error",
|
||||
"code": 7017
|
||||
@@ -2932,6 +2928,14 @@
|
||||
"category": "Error",
|
||||
"code": 7031
|
||||
},
|
||||
"Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 7032
|
||||
},
|
||||
"Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation.": {
|
||||
"category": "Error",
|
||||
"code": 7033
|
||||
},
|
||||
"You cannot rename this element.": {
|
||||
"category": "Error",
|
||||
"code": 8000
|
||||
|
||||
@@ -6587,7 +6587,7 @@ const _super = (function (geti, seti) {
|
||||
// import { x, y } from "foo"
|
||||
// import d, * as x from "foo"
|
||||
// import d, { x, y } from "foo"
|
||||
const isNakedImport = SyntaxKind.ImportDeclaration && !(<ImportDeclaration>node).importClause;
|
||||
const isNakedImport = node.kind === SyntaxKind.ImportDeclaration && !(<ImportDeclaration>node).importClause;
|
||||
if (!isNakedImport) {
|
||||
write(varOrConst);
|
||||
write(getGeneratedNameForNode(<ImportDeclaration>node));
|
||||
|
||||
@@ -2339,6 +2339,7 @@ namespace ts {
|
||||
token() === SyntaxKind.LessThanToken ||
|
||||
token() === SyntaxKind.QuestionToken ||
|
||||
token() === SyntaxKind.ColonToken ||
|
||||
token() === SyntaxKind.CommaToken ||
|
||||
canParseSemicolon();
|
||||
}
|
||||
return false;
|
||||
|
||||
+42
-20
@@ -206,6 +206,24 @@ namespace FourSlash {
|
||||
|
||||
private inputFiles = ts.createMap<string>(); // Map between inputFile's fileName and its content for easily looking up when resolving references
|
||||
|
||||
private static getDisplayPartsJson(displayParts: ts.SymbolDisplayPart[]) {
|
||||
let result = "";
|
||||
ts.forEach(displayParts, part => {
|
||||
if (result) {
|
||||
result += ",\n ";
|
||||
}
|
||||
else {
|
||||
result = "[\n ";
|
||||
}
|
||||
result += JSON.stringify(part);
|
||||
});
|
||||
if (result) {
|
||||
result += "\n]";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Add input file which has matched file name with the given reference-file path.
|
||||
// This is necessary when resolveReference flag is specified
|
||||
private addMatchedInputFile(referenceFilePath: string, extensions: string[]) {
|
||||
@@ -776,6 +794,20 @@ namespace FourSlash {
|
||||
ts.forEachProperty(this.rangesByText(), ranges => this.verifyRangesReferenceEachOther(ranges));
|
||||
}
|
||||
|
||||
public verifyDisplayPartsOfReferencedSymbol(expected: ts.SymbolDisplayPart[]) {
|
||||
const referencedSymbols = this.findReferencesAtCaret();
|
||||
|
||||
if (referencedSymbols.length === 0) {
|
||||
this.raiseError("No referenced symbols found at current caret position");
|
||||
}
|
||||
else if (referencedSymbols.length > 1) {
|
||||
this.raiseError("More than one referenced symbol found");
|
||||
}
|
||||
|
||||
assert.equal(TestState.getDisplayPartsJson(referencedSymbols[0].definition.displayParts),
|
||||
TestState.getDisplayPartsJson(expected), this.messageAtLastKnownMarker("referenced symbol definition display parts"));
|
||||
}
|
||||
|
||||
private verifyReferencesWorker(references: ts.ReferenceEntry[], fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) {
|
||||
for (let i = 0; i < references.length; i++) {
|
||||
const reference = references[i];
|
||||
@@ -810,6 +842,10 @@ namespace FourSlash {
|
||||
return this.languageService.getReferencesAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
}
|
||||
|
||||
private findReferencesAtCaret() {
|
||||
return this.languageService.findReferences(this.activeFile.fileName, this.currentCaretPosition);
|
||||
}
|
||||
|
||||
public getSyntacticDiagnostics(expected: string) {
|
||||
const diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName);
|
||||
this.testDiagnostics(expected, diagnostics);
|
||||
@@ -855,30 +891,12 @@ namespace FourSlash {
|
||||
displayParts: ts.SymbolDisplayPart[],
|
||||
documentation: ts.SymbolDisplayPart[]) {
|
||||
|
||||
function getDisplayPartsJson(displayParts: ts.SymbolDisplayPart[]) {
|
||||
let result = "";
|
||||
ts.forEach(displayParts, part => {
|
||||
if (result) {
|
||||
result += ",\n ";
|
||||
}
|
||||
else {
|
||||
result = "[\n ";
|
||||
}
|
||||
result += JSON.stringify(part);
|
||||
});
|
||||
if (result) {
|
||||
result += "\n]";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
const actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
assert.equal(actualQuickInfo.kind, kind, this.messageAtLastKnownMarker("QuickInfo kind"));
|
||||
assert.equal(actualQuickInfo.kindModifiers, kindModifiers, this.messageAtLastKnownMarker("QuickInfo kindModifiers"));
|
||||
assert.equal(JSON.stringify(actualQuickInfo.textSpan), JSON.stringify(textSpan), this.messageAtLastKnownMarker("QuickInfo textSpan"));
|
||||
assert.equal(getDisplayPartsJson(actualQuickInfo.displayParts), getDisplayPartsJson(displayParts), this.messageAtLastKnownMarker("QuickInfo displayParts"));
|
||||
assert.equal(getDisplayPartsJson(actualQuickInfo.documentation), getDisplayPartsJson(documentation), this.messageAtLastKnownMarker("QuickInfo documentation"));
|
||||
assert.equal(TestState.getDisplayPartsJson(actualQuickInfo.displayParts), TestState.getDisplayPartsJson(displayParts), this.messageAtLastKnownMarker("QuickInfo displayParts"));
|
||||
assert.equal(TestState.getDisplayPartsJson(actualQuickInfo.documentation), TestState.getDisplayPartsJson(documentation), this.messageAtLastKnownMarker("QuickInfo documentation"));
|
||||
}
|
||||
|
||||
public verifyRenameLocations(findInStrings: boolean, findInComments: boolean, ranges?: Range[]) {
|
||||
@@ -2988,6 +3006,10 @@ namespace FourSlashInterface {
|
||||
this.state.verifyRangesReferenceEachOther(ranges);
|
||||
}
|
||||
|
||||
public findReferencesDefinitionDisplayPartsAtCaretAre(expected: ts.SymbolDisplayPart[]) {
|
||||
this.state.verifyDisplayPartsOfReferencedSymbol(expected);
|
||||
}
|
||||
|
||||
public rangesWithSameTextReferenceEachOther() {
|
||||
this.state.verifyRangesWithSameTextReferenceEachOther();
|
||||
}
|
||||
|
||||
+19
-6
@@ -1370,23 +1370,31 @@ namespace Harness {
|
||||
|
||||
// Produce baselines. The first gives the types for all expressions.
|
||||
// The second gives symbols for all identifiers.
|
||||
let e1: Error, e2: Error;
|
||||
let typesError: Error, symbolsError: Error;
|
||||
try {
|
||||
checkBaseLines(/*isSymbolBaseLine*/ false);
|
||||
}
|
||||
catch (e) {
|
||||
e1 = e;
|
||||
typesError = e;
|
||||
}
|
||||
|
||||
try {
|
||||
checkBaseLines(/*isSymbolBaseLine*/ true);
|
||||
}
|
||||
catch (e) {
|
||||
e2 = e;
|
||||
symbolsError = e;
|
||||
}
|
||||
|
||||
if (e1 || e2) {
|
||||
throw e1 || e2;
|
||||
if (typesError && symbolsError) {
|
||||
throw new Error(typesError.message + ts.sys.newLine + symbolsError.message);
|
||||
}
|
||||
|
||||
if (typesError) {
|
||||
throw typesError;
|
||||
}
|
||||
|
||||
if (symbolsError) {
|
||||
throw symbolsError;
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -1396,7 +1404,12 @@ namespace Harness {
|
||||
|
||||
const fullExtension = isSymbolBaseLine ? ".symbols" : ".types";
|
||||
|
||||
Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?/, fullExtension), () => fullBaseLine, opts);
|
||||
// When calling this function from rwc-runner, the baselinePath will have no extension.
|
||||
// As rwc test- file is stored in json which ".json" will get stripped off.
|
||||
// When calling this function from compiler-runner, the baselinePath will then has either ".ts" or ".tsx" extension
|
||||
const outputFileName = ts.endsWith(baselinePath, ".ts") || ts.endsWith(baselinePath, ".tsx") ?
|
||||
baselinePath.replace(/\.tsx?/, fullExtension) : baselinePath.concat(fullExtension);
|
||||
Harness.Baseline.runBaseline(outputFileName, () => fullBaseLine, opts);
|
||||
}
|
||||
|
||||
function generateBaseLine(typeWriterResults: ts.Map<TypeWriterResult[]>, isSymbolBaseline: boolean): string {
|
||||
|
||||
@@ -223,7 +223,8 @@ namespace RWC {
|
||||
});
|
||||
|
||||
it("has the expected types", () => {
|
||||
Harness.Compiler.doTypeAndSymbolBaseline(`${baseName}.types`, compilerResult, inputFiles
|
||||
// We don't need to pass the extension here because "doTypeAndSymbolBaseline" will append appropriate extension of ".types" or ".symbols"
|
||||
Harness.Compiler.doTypeAndSymbolBaseline(baseName, compilerResult, inputFiles
|
||||
.concat(otherFiles)
|
||||
.filter(file => !!compilerResult.program.getSourceFile(file.unitName))
|
||||
.filter(e => !Harness.isDefaultLibraryFile(e.unitName)), baselineOpts);
|
||||
|
||||
@@ -1388,8 +1388,12 @@ namespace ts {
|
||||
containerName: string;
|
||||
}
|
||||
|
||||
export interface ReferencedSymbolDefinitionInfo extends DefinitionInfo {
|
||||
displayParts: SymbolDisplayPart[];
|
||||
}
|
||||
|
||||
export interface ReferencedSymbol {
|
||||
definition: DefinitionInfo;
|
||||
definition: ReferencedSymbolDefinitionInfo;
|
||||
references: ReferenceEntry[];
|
||||
}
|
||||
|
||||
@@ -6127,7 +6131,7 @@ namespace ts {
|
||||
|
||||
return result;
|
||||
|
||||
function getDefinition(symbol: Symbol): DefinitionInfo {
|
||||
function getDefinition(symbol: Symbol): ReferencedSymbolDefinitionInfo {
|
||||
const info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), node);
|
||||
const name = map(info.displayParts, p => p.text).join("");
|
||||
const declarations = symbol.declarations;
|
||||
@@ -6141,7 +6145,8 @@ namespace ts {
|
||||
name,
|
||||
kind: info.symbolKind,
|
||||
fileName: declarations[0].getSourceFile().fileName,
|
||||
textSpan: createTextSpan(declarations[0].getStart(), 0)
|
||||
textSpan: createTextSpan(declarations[0].getStart(), 0),
|
||||
displayParts: info.displayParts
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6336,13 +6341,14 @@ namespace ts {
|
||||
}
|
||||
});
|
||||
|
||||
const definition: DefinitionInfo = {
|
||||
const definition: ReferencedSymbolDefinitionInfo = {
|
||||
containerKind: "",
|
||||
containerName: "",
|
||||
fileName: targetLabel.getSourceFile().fileName,
|
||||
kind: ScriptElementKind.label,
|
||||
name: labelName,
|
||||
textSpan: createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd())
|
||||
textSpan: createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()),
|
||||
displayParts: [displayPart(labelName, SymbolDisplayPartKind.text)]
|
||||
};
|
||||
|
||||
return [{ definition, references }];
|
||||
@@ -6582,6 +6588,11 @@ namespace ts {
|
||||
getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references);
|
||||
}
|
||||
|
||||
const thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword);
|
||||
|
||||
const displayParts = thisOrSuperSymbol && getSymbolDisplayPartsDocumentationAndSymbolKind(
|
||||
thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts;
|
||||
|
||||
return [{
|
||||
definition: {
|
||||
containerKind: "",
|
||||
@@ -6589,7 +6600,8 @@ namespace ts {
|
||||
fileName: node.getSourceFile().fileName,
|
||||
kind: ScriptElementKind.variableElement,
|
||||
name: "this",
|
||||
textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd())
|
||||
textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()),
|
||||
displayParts
|
||||
},
|
||||
references: references
|
||||
}];
|
||||
@@ -6660,7 +6672,8 @@ namespace ts {
|
||||
fileName: node.getSourceFile().fileName,
|
||||
kind: ScriptElementKind.variableElement,
|
||||
name: type.text,
|
||||
textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd())
|
||||
textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()),
|
||||
displayParts: [displayPart(getTextOfNode(node), SymbolDisplayPartKind.stringLiteral)]
|
||||
},
|
||||
references: references
|
||||
}];
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts(4,1): error TS1238: Unable to resolve signature of class decorator when called as an expression.
|
||||
Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts (1 errors) ====
|
||||
|
||||
class CtorDtor {}
|
||||
|
||||
@CtorDtor
|
||||
~~~~~~~~~
|
||||
!!! error TS1238: Unable to resolve signature of class decorator when called as an expression.
|
||||
!!! error TS1238: Cannot invoke an expression whose type lacks a call signature.
|
||||
class C {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//// [constructableDecoratorOnClass01.ts]
|
||||
|
||||
class CtorDtor {}
|
||||
|
||||
@CtorDtor
|
||||
class C {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//// [constructableDecoratorOnClass01.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var CtorDtor = (function () {
|
||||
function CtorDtor() {
|
||||
}
|
||||
return CtorDtor;
|
||||
}());
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C = __decorate([
|
||||
CtorDtor
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts ===
|
||||
|
||||
class CtorDtor {}
|
||||
>CtorDtor : Symbol(CtorDtor, Decl(constructableDecoratorOnClass01.ts, 0, 0))
|
||||
|
||||
@CtorDtor
|
||||
>CtorDtor : Symbol(CtorDtor, Decl(constructableDecoratorOnClass01.ts, 0, 0))
|
||||
|
||||
class C {
|
||||
>C : Symbol(C, Decl(constructableDecoratorOnClass01.ts, 1, 17))
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts ===
|
||||
|
||||
class CtorDtor {}
|
||||
>CtorDtor : CtorDtor
|
||||
|
||||
@CtorDtor
|
||||
>CtorDtor : typeof CtorDtor
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(3,5): erro
|
||||
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(4,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,16): error TS7016: Property 'haveOnlySet' implicitly has type 'any', because its 'set' accessor lacks a type annotation.
|
||||
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,16): error TS7032: Property 'haveOnlySet' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
|
||||
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,28): error TS7006: Parameter 'newXValue' implicitly has an 'any' type.
|
||||
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,16): error TS7010: 'haveOnlyGet', which lacks return-type annotation, implicitly has an 'any' return type.
|
||||
@@ -33,7 +33,7 @@ tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,16): er
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS7016: Property 'haveOnlySet' implicitly has type 'any', because its 'set' accessor lacks a type annotation.
|
||||
!!! error TS7032: Property 'haveOnlySet' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
|
||||
~~~~~~~~~
|
||||
!!! error TS7006: Parameter 'newXValue' implicitly has an 'any' type.
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts(4,25): error TS7032: Property 'message' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
|
||||
tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts(4,33): error TS7006: Parameter 'str' implicitly has an 'any' type.
|
||||
tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts(9,16): error TS7032: Property 'message' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
|
||||
tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts(9,24): error TS7006: Parameter 'str' implicitly has an 'any' type.
|
||||
|
||||
|
||||
==== tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts (4 errors) ====
|
||||
|
||||
abstract class Parent
|
||||
{
|
||||
public abstract set message(str);
|
||||
~~~~~~~
|
||||
!!! error TS7032: Property 'message' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
|
||||
~~~
|
||||
!!! error TS7006: Parameter 'str' implicitly has an 'any' type.
|
||||
}
|
||||
|
||||
class Child extends Parent {
|
||||
_x: any;
|
||||
public set message(str) {
|
||||
~~~~~~~
|
||||
!!! error TS7032: Property 'message' implicitly has type 'any', because its set accessor lacks a parameter type annotation.
|
||||
~~~
|
||||
!!! error TS7006: Parameter 'str' implicitly has an 'any' type.
|
||||
this._x = str;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
//// [noImplicitAnyMissingGetAccessor.ts]
|
||||
|
||||
abstract class Parent
|
||||
{
|
||||
public abstract set message(str);
|
||||
}
|
||||
|
||||
class Child extends Parent {
|
||||
_x: any;
|
||||
public set message(str) {
|
||||
this._x = str;
|
||||
}
|
||||
}
|
||||
|
||||
//// [noImplicitAnyMissingGetAccessor.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Parent = (function () {
|
||||
function Parent() {
|
||||
}
|
||||
Object.defineProperty(Parent.prototype, "message", {
|
||||
set: function (str) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return Parent;
|
||||
}());
|
||||
var Child = (function (_super) {
|
||||
__extends(Child, _super);
|
||||
function Child() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Object.defineProperty(Child.prototype, "message", {
|
||||
set: function (str) {
|
||||
this._x = str;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return Child;
|
||||
}(Parent));
|
||||
@@ -0,0 +1,17 @@
|
||||
tests/cases/compiler/noImplicitAnyMissingSetAccessor.ts(4,25): error TS7033: Property 'message' implicitly has type 'any', because its get accessor lacks a return type annotation.
|
||||
|
||||
|
||||
==== tests/cases/compiler/noImplicitAnyMissingSetAccessor.ts (1 errors) ====
|
||||
|
||||
abstract class Parent
|
||||
{
|
||||
public abstract get message();
|
||||
~~~~~~~
|
||||
!!! error TS7033: Property 'message' implicitly has type 'any', because its get accessor lacks a return type annotation.
|
||||
}
|
||||
|
||||
class Child extends Parent {
|
||||
public get message() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//// [noImplicitAnyMissingSetAccessor.ts]
|
||||
|
||||
abstract class Parent
|
||||
{
|
||||
public abstract get message();
|
||||
}
|
||||
|
||||
class Child extends Parent {
|
||||
public get message() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
//// [noImplicitAnyMissingSetAccessor.js]
|
||||
var __extends = (this && this.__extends) || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
var Parent = (function () {
|
||||
function Parent() {
|
||||
}
|
||||
Object.defineProperty(Parent.prototype, "message", {
|
||||
get: function () { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return Parent;
|
||||
}());
|
||||
var Child = (function (_super) {
|
||||
__extends(Child, _super);
|
||||
function Child() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
Object.defineProperty(Child.prototype, "message", {
|
||||
get: function () {
|
||||
return "";
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return Child;
|
||||
}(Parent));
|
||||
+2
-11
@@ -1,8 +1,5 @@
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'.
|
||||
Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,16): error TS1131: Property or signature expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,25): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'.
|
||||
Types of property 'id' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
@@ -11,7 +8,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
|
||||
Type 'number' is not assignable to type 'boolean'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts (6 errors) ====
|
||||
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts (3 errors) ====
|
||||
var id: number = 10000;
|
||||
var name: string = "my name";
|
||||
|
||||
@@ -19,13 +16,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
|
||||
~~~~
|
||||
!!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'.
|
||||
!!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'.
|
||||
var person1: { name, id }; // error: can't use short-hand property assignment in type position
|
||||
~~~~
|
||||
!!! error TS1131: Property or signature expected.
|
||||
~~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
var person1: { name, id }; // ok
|
||||
function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'.
|
||||
|
||||
@@ -3,7 +3,7 @@ var id: number = 10000;
|
||||
var name: string = "my name";
|
||||
|
||||
var person: { b: string; id: number } = { name, id }; // error
|
||||
var person1: { name, id }; // error: can't use short-hand property assignment in type position
|
||||
var person1: { name, id }; // ok
|
||||
function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error
|
||||
function bar(obj: { name: string; id: boolean }) { }
|
||||
bar({ name, id }); // error
|
||||
@@ -14,8 +14,7 @@ bar({ name, id }); // error
|
||||
var id = 10000;
|
||||
var name = "my name";
|
||||
var person = { name: name, id: id }; // error
|
||||
var person1 = name, id;
|
||||
; // error: can't use short-hand property assignment in type position
|
||||
var person1; // ok
|
||||
function foo(name, id) { return { name: name, id: id }; } // error
|
||||
function bar(obj) { }
|
||||
bar({ name: name, id: id }); // error
|
||||
|
||||
+4
-12
@@ -3,15 +3,12 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'.
|
||||
Types of property 'name' are incompatible.
|
||||
Type 'string' is not assignable to type 'number'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(7,16): error TS1131: Property or signature expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(7,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(7,25): error TS1128: Declaration or statement expected.
|
||||
tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(8,5): error TS2322: Type '{ name: number; id: string; }' is not assignable to type '{ name: string; id: number; }'.
|
||||
Types of property 'name' are incompatible.
|
||||
Type 'number' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts (6 errors) ====
|
||||
==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts (3 errors) ====
|
||||
var id: number = 10000;
|
||||
var name: string = "my name";
|
||||
|
||||
@@ -25,15 +22,10 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr
|
||||
!!! error TS2322: Types of property 'name' are incompatible.
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
function foo(name: string, id: number): { name: string, id: number } { return { name, id }; } // error
|
||||
var person1: { name, id }; // error : Can't use shorthand in the type position
|
||||
~~~~
|
||||
!!! error TS1131: Property or signature expected.
|
||||
~~
|
||||
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'.
|
||||
~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
var person1: { name, id }; // ok
|
||||
var person2: { name: string, id: number } = bar("hello", 5);
|
||||
~~~~~~~
|
||||
!!! error TS2322: Type '{ name: number; id: string; }' is not assignable to type '{ name: string; id: number; }'.
|
||||
!!! error TS2322: Types of property 'name' are incompatible.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
|
||||
+4
-4
@@ -5,8 +5,9 @@ var name: string = "my name";
|
||||
var person: { b: string; id: number } = { name, id }; // error
|
||||
function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error
|
||||
function foo(name: string, id: number): { name: string, id: number } { return { name, id }; } // error
|
||||
var person1: { name, id }; // error : Can't use shorthand in the type position
|
||||
var person2: { name: string, id: number } = bar("hello", 5);
|
||||
var person1: { name, id }; // ok
|
||||
var person2: { name: string, id: number } = bar("hello", 5);
|
||||
|
||||
|
||||
//// [objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.js]
|
||||
var id = 10000;
|
||||
@@ -14,6 +15,5 @@ var name = "my name";
|
||||
var person = { name: name, id: id }; // error
|
||||
function bar(name, id) { return { name: name, id: id }; } // error
|
||||
function foo(name, id) { return { name: name, id: id }; } // error
|
||||
var person1 = name, id;
|
||||
; // error : Can't use shorthand in the type position
|
||||
var person1; // ok
|
||||
var person2 = bar("hello", 5);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [parseObjectLiteralsWithoutTypes.ts]
|
||||
let x: { foo, bar }
|
||||
let y: { foo: number, bar }
|
||||
let z: { foo, bar: number }
|
||||
|
||||
|
||||
//// [parseObjectLiteralsWithoutTypes.js]
|
||||
var x;
|
||||
var y;
|
||||
var z;
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts ===
|
||||
let x: { foo, bar }
|
||||
>x : Symbol(x, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 3))
|
||||
>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 8))
|
||||
>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 13))
|
||||
|
||||
let y: { foo: number, bar }
|
||||
>y : Symbol(y, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 3))
|
||||
>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 8))
|
||||
>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 21))
|
||||
|
||||
let z: { foo, bar: number }
|
||||
>z : Symbol(z, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 3))
|
||||
>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 8))
|
||||
>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 13))
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts ===
|
||||
let x: { foo, bar }
|
||||
>x : { foo: any; bar: any; }
|
||||
>foo : any
|
||||
>bar : any
|
||||
|
||||
let y: { foo: number, bar }
|
||||
>y : { foo: number; bar: any; }
|
||||
>foo : number
|
||||
>bar : any
|
||||
|
||||
let z: { foo, bar: number }
|
||||
>z : { foo: any; bar: number; }
|
||||
>foo : any
|
||||
>bar : number
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
//// [taggedTemplateUntypedTagCall01.ts]
|
||||
var tag: Function;
|
||||
tag `Hello world!`;
|
||||
|
||||
//// [taggedTemplateUntypedTagCall01.js]
|
||||
var tag;
|
||||
(_a = ["Hello world!"], _a.raw = ["Hello world!"], tag(_a));
|
||||
var _a;
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/conformance/es6/templates/taggedTemplateUntypedTagCall01.ts ===
|
||||
var tag: Function;
|
||||
>tag : Symbol(tag, Decl(taggedTemplateUntypedTagCall01.ts, 0, 3))
|
||||
>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --))
|
||||
|
||||
tag `Hello world!`;
|
||||
>tag : Symbol(tag, Decl(taggedTemplateUntypedTagCall01.ts, 0, 3))
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
=== tests/cases/conformance/es6/templates/taggedTemplateUntypedTagCall01.ts ===
|
||||
var tag: Function;
|
||||
>tag : Function
|
||||
>Function : Function
|
||||
|
||||
tag `Hello world!`;
|
||||
>tag `Hello world!` : any
|
||||
>tag : Function
|
||||
>`Hello world!` : string
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag01.ts(3,1): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag01.ts (1 errors) ====
|
||||
class CtorTag { }
|
||||
|
||||
CtorTag `Hello world!`;
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [taggedTemplateWithConstructableTag01.ts]
|
||||
class CtorTag { }
|
||||
|
||||
CtorTag `Hello world!`;
|
||||
|
||||
//// [taggedTemplateWithConstructableTag01.js]
|
||||
var CtorTag = (function () {
|
||||
function CtorTag() {
|
||||
}
|
||||
return CtorTag;
|
||||
}());
|
||||
(_a = ["Hello world!"], _a.raw = ["Hello world!"], CtorTag(_a));
|
||||
var _a;
|
||||
@@ -0,0 +1,7 @@
|
||||
=== tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag01.ts ===
|
||||
class CtorTag { }
|
||||
>CtorTag : Symbol(CtorTag, Decl(taggedTemplateWithConstructableTag01.ts, 0, 0))
|
||||
|
||||
CtorTag `Hello world!`;
|
||||
>CtorTag : Symbol(CtorTag, Decl(taggedTemplateWithConstructableTag01.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag01.ts ===
|
||||
class CtorTag { }
|
||||
>CtorTag : CtorTag
|
||||
|
||||
CtorTag `Hello world!`;
|
||||
>CtorTag `Hello world!` : any
|
||||
>CtorTag : typeof CtorTag
|
||||
>`Hello world!` : string
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag02.ts(6,1): error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag02.ts (1 errors) ====
|
||||
interface I {
|
||||
new (...args: any[]): string;
|
||||
new (): number;
|
||||
}
|
||||
var tag: I;
|
||||
tag `Hello world!`;
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2349: Cannot invoke an expression whose type lacks a call signature.
|
||||
@@ -0,0 +1,12 @@
|
||||
//// [taggedTemplateWithConstructableTag02.ts]
|
||||
interface I {
|
||||
new (...args: any[]): string;
|
||||
new (): number;
|
||||
}
|
||||
var tag: I;
|
||||
tag `Hello world!`;
|
||||
|
||||
//// [taggedTemplateWithConstructableTag02.js]
|
||||
var tag;
|
||||
(_a = ["Hello world!"], _a.raw = ["Hello world!"], tag(_a));
|
||||
var _a;
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag02.ts ===
|
||||
interface I {
|
||||
>I : Symbol(I, Decl(taggedTemplateWithConstructableTag02.ts, 0, 0))
|
||||
|
||||
new (...args: any[]): string;
|
||||
>args : Symbol(args, Decl(taggedTemplateWithConstructableTag02.ts, 1, 9))
|
||||
|
||||
new (): number;
|
||||
}
|
||||
var tag: I;
|
||||
>tag : Symbol(tag, Decl(taggedTemplateWithConstructableTag02.ts, 4, 3))
|
||||
>I : Symbol(I, Decl(taggedTemplateWithConstructableTag02.ts, 0, 0))
|
||||
|
||||
tag `Hello world!`;
|
||||
>tag : Symbol(tag, Decl(taggedTemplateWithConstructableTag02.ts, 4, 3))
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
=== tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag02.ts ===
|
||||
interface I {
|
||||
>I : I
|
||||
|
||||
new (...args: any[]): string;
|
||||
>args : any[]
|
||||
|
||||
new (): number;
|
||||
}
|
||||
var tag: I;
|
||||
>tag : I
|
||||
>I : I
|
||||
|
||||
tag `Hello world!`;
|
||||
>tag `Hello world!` : any
|
||||
>tag : I
|
||||
>`Hello world!` : string
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// @noImplicitAny : true
|
||||
// @target: es5
|
||||
|
||||
abstract class Parent
|
||||
{
|
||||
public abstract set message(str);
|
||||
}
|
||||
|
||||
class Child extends Parent {
|
||||
_x: any;
|
||||
public set message(str) {
|
||||
this._x = str;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// @noImplicitAny: true
|
||||
// @target: es5
|
||||
|
||||
abstract class Parent
|
||||
{
|
||||
public abstract get message();
|
||||
}
|
||||
|
||||
class Child extends Parent {
|
||||
public get message() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
let x: { foo, bar }
|
||||
let y: { foo: number, bar }
|
||||
let z: { foo, bar: number }
|
||||
@@ -0,0 +1,8 @@
|
||||
// @experimentalDecorators: true
|
||||
|
||||
class CtorDtor {}
|
||||
|
||||
@CtorDtor
|
||||
class C {
|
||||
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
var name: string = "my name";
|
||||
|
||||
var person: { b: string; id: number } = { name, id }; // error
|
||||
var person1: { name, id }; // error: can't use short-hand property assignment in type position
|
||||
var person1: { name, id }; // ok
|
||||
function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error
|
||||
function bar(obj: { name: string; id: boolean }) { }
|
||||
bar({ name, id }); // error
|
||||
|
||||
+2
-2
@@ -4,5 +4,5 @@ var name: string = "my name";
|
||||
var person: { b: string; id: number } = { name, id }; // error
|
||||
function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error
|
||||
function foo(name: string, id: number): { name: string, id: number } { return { name, id }; } // error
|
||||
var person1: { name, id }; // error : Can't use shorthand in the type position
|
||||
var person2: { name: string, id: number } = bar("hello", 5);
|
||||
var person1: { name, id }; // ok
|
||||
var person2: { name: string, id: number } = bar("hello", 5);
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
var tag: Function;
|
||||
tag `Hello world!`;
|
||||
@@ -0,0 +1,3 @@
|
||||
class CtorTag { }
|
||||
|
||||
CtorTag `Hello world!`;
|
||||
@@ -0,0 +1,6 @@
|
||||
interface I {
|
||||
new (...args: any[]): string;
|
||||
new (): number;
|
||||
}
|
||||
var tag: I;
|
||||
tag `Hello world!`;
|
||||
@@ -0,0 +1,23 @@
|
||||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
//// class Gre/*1*/eter {
|
||||
//// someFunction() { th/*2*/is; }
|
||||
//// }
|
||||
////
|
||||
//// type Options = "opt/*3*/ion 1" | "option 2";
|
||||
//// let myOption: Options = "option 1";
|
||||
////
|
||||
//// some/*4*/Label:
|
||||
//// break someLabel;
|
||||
|
||||
goTo.marker("1");
|
||||
verify.findReferencesDefinitionDisplayPartsAtCaretAre([{ text: "class", kind: "keyword" }, { text: " ", kind: "space" }, { text: "Greeter", kind: "className" }]);
|
||||
|
||||
goTo.marker("2");
|
||||
verify.findReferencesDefinitionDisplayPartsAtCaretAre([{ text: "this", kind: "keyword" }, { text: ":", kind: "punctuation" }, { text: " ", kind: "space" }, { text: "this", kind: "keyword" }]);
|
||||
|
||||
goTo.marker("3");
|
||||
verify.findReferencesDefinitionDisplayPartsAtCaretAre([{ text: "\"option 1\"", kind: "stringLiteral" }]);
|
||||
|
||||
goTo.marker("4");
|
||||
verify.findReferencesDefinitionDisplayPartsAtCaretAre([{ text: "someLabel", kind: "text" }]);
|
||||
@@ -171,6 +171,7 @@ declare namespace FourSlashInterface {
|
||||
* If `ranges` is omitted, this is `test.ranges()`.
|
||||
*/
|
||||
rangesReferenceEachOther(ranges?: Range[]): void;
|
||||
findReferencesDefinitionDisplayPartsAtCaretAre(expected: ts.SymbolDisplayPart[]): void;
|
||||
rangesWithSameTextReferenceEachOther(): void;
|
||||
currentParameterHelpArgumentNameIs(name: string): void;
|
||||
currentParameterSpanIs(parameter: string): void;
|
||||
|
||||
Reference in New Issue
Block a user