mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-12 20:25:48 -06:00
Merge branch 'master' into mergeMaster_09/01
This commit is contained in:
commit
b5f4c074d6
@ -1024,8 +1024,8 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getDeclarationOfAliasSymbol(symbol: Symbol): Declaration {
|
||||
return findMap(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined);
|
||||
function getDeclarationOfAliasSymbol(symbol: Symbol): Declaration | undefined {
|
||||
return forEach(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined);
|
||||
}
|
||||
|
||||
function getTargetOfImportEqualsDeclaration(node: ImportEqualsDeclaration): Symbol {
|
||||
@ -1192,6 +1192,7 @@ namespace ts {
|
||||
if (!links.target) {
|
||||
links.target = resolvingSymbol;
|
||||
const node = getDeclarationOfAliasSymbol(symbol);
|
||||
Debug.assert(!!node);
|
||||
const target = getTargetOfAliasDeclaration(node);
|
||||
if (links.target === resolvingSymbol) {
|
||||
links.target = target || unknownSymbol;
|
||||
@ -1227,6 +1228,7 @@ namespace ts {
|
||||
if (!links.referenced) {
|
||||
links.referenced = true;
|
||||
const node = getDeclarationOfAliasSymbol(symbol);
|
||||
Debug.assert(!!node);
|
||||
if (node.kind === SyntaxKind.ExportAssignment) {
|
||||
// export default <symbol>
|
||||
checkExpressionCached((<ExportAssignment>node).expression);
|
||||
@ -3348,7 +3350,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;
|
||||
}
|
||||
@ -5374,7 +5382,7 @@ namespace ts {
|
||||
while (i > 0) {
|
||||
i--;
|
||||
if (isSubtypeOfAny(types[i], types)) {
|
||||
types.splice(i, 1);
|
||||
orderedRemoveItemAt(types, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8758,7 +8766,7 @@ namespace ts {
|
||||
// The location isn't a reference to the given symbol, meaning we're being asked
|
||||
// a hypothetical question of what type the symbol would have if there was a reference
|
||||
// to it at the given location. Since we have no control flow information for the
|
||||
// hypotherical reference (control flow information is created and attached by the
|
||||
// hypothetical reference (control flow information is created and attached by the
|
||||
// binder), we simply return the declared type of the symbol.
|
||||
return getTypeOfSymbol(symbol);
|
||||
}
|
||||
@ -11993,18 +12001,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) {
|
||||
@ -12027,6 +12029,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);
|
||||
@ -12152,8 +12177,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);
|
||||
}
|
||||
|
||||
@ -12198,7 +12224,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);
|
||||
}
|
||||
|
||||
@ -18885,7 +18912,13 @@ namespace ts {
|
||||
(augmentations || (augmentations = [])).push(file.moduleAugmentations);
|
||||
}
|
||||
if (file.symbol && file.symbol.globalExports) {
|
||||
mergeSymbolTable(globals, file.symbol.globalExports);
|
||||
// Merge in UMD exports with first-in-wins semantics (see #9771)
|
||||
const source = file.symbol.globalExports;
|
||||
for (const id in source) {
|
||||
if (!(id in globals)) {
|
||||
globals[id] = source[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((compilerOptions.isolatedModules || isExternalModule(file)) && !file.isDeclarationFile) {
|
||||
const fileRequestedExternalEmitHelpers = file.flags & NodeFlags.EmitHelperFlags;
|
||||
|
||||
@ -891,7 +891,7 @@ namespace ts {
|
||||
function convertCompilerOptionsFromJsonWorker(jsonOptions: any,
|
||||
basePath: string, errors: Diagnostic[], configFileName?: string): CompilerOptions {
|
||||
|
||||
const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true } : {};
|
||||
const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2 } : {};
|
||||
convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_compiler_option_0, errors);
|
||||
return options;
|
||||
}
|
||||
|
||||
@ -199,8 +199,10 @@ namespace ts {
|
||||
return count;
|
||||
}
|
||||
|
||||
export function filter<T, U extends T>(array: T[], f: (x: T) => x is U): U[];
|
||||
export function filter<T>(array: T[], f: (x: T) => boolean): T[]
|
||||
/**
|
||||
* Filters an array by a predicate function. Returns the same array instance if the predicate is
|
||||
* true for all elements, otherwise returns a new array instance containing the filtered subset.
|
||||
*/
|
||||
export function filter<T>(array: T[], f: (x: T) => boolean): T[] {
|
||||
if (array) {
|
||||
const len = array.length;
|
||||
@ -1717,20 +1719,39 @@ namespace ts {
|
||||
return "";
|
||||
}
|
||||
|
||||
export function copyListRemovingItem<T>(item: T, list: T[]) {
|
||||
const copiedList: T[] = [];
|
||||
for (const e of list) {
|
||||
if (e !== item) {
|
||||
copiedList.push(e);
|
||||
}
|
||||
/** Remove an item from an array, moving everything to its right one space left. */
|
||||
export function orderedRemoveItemAt<T>(array: T[], index: number): void {
|
||||
// This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`.
|
||||
for (let i = index; i < array.length - 1; i++) {
|
||||
array[i] = array[i + 1];
|
||||
}
|
||||
return copiedList;
|
||||
array.pop();
|
||||
}
|
||||
|
||||
export function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string {
|
||||
return useCaseSensitivefileNames
|
||||
export function unorderedRemoveItemAt<T>(array: T[], index: number): void {
|
||||
// Fill in the "hole" left at `index`.
|
||||
array[index] = array[array.length - 1];
|
||||
array.pop();
|
||||
}
|
||||
|
||||
/** Remove the *first* occurrence of `item` from the array. */
|
||||
export function unorderedRemoveItem<T>(array: T[], item: T): void {
|
||||
unorderedRemoveFirstItemWhere(array, element => element === item);
|
||||
}
|
||||
|
||||
/** Remove the *first* element satisfying `predicate`. */
|
||||
function unorderedRemoveFirstItemWhere<T>(array: T[], predicate: (element: T) => boolean): void {
|
||||
for (let i = 0; i < array.length; i++) {
|
||||
if (predicate(array[i])) {
|
||||
unorderedRemoveItemAt(array, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): (fileName: string) => string {
|
||||
return useCaseSensitiveFileNames
|
||||
? ((fileName) => fileName)
|
||||
: ((fileName) => fileName.toLowerCase());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1133,8 +1133,10 @@ namespace ts {
|
||||
// it if it's not a well known symbol. In that case, the text of the name will be exactly
|
||||
// what we want, namely the name expression enclosed in brackets.
|
||||
writeTextOfNode(currentText, node.name);
|
||||
// If optional property emit ?
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature || node.kind === SyntaxKind.Parameter) && hasQuestionToken(node)) {
|
||||
// If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor
|
||||
// we don't want to emit property declaration with "?"
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature ||
|
||||
(node.kind === SyntaxKind.Parameter && !isParameterPropertyDeclaration(node))) && hasQuestionToken(node)) {
|
||||
write("?");
|
||||
}
|
||||
if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && node.parent.kind === SyntaxKind.TypeLiteral) {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -2338,6 +2338,7 @@ namespace ts {
|
||||
token() === SyntaxKind.LessThanToken ||
|
||||
token() === SyntaxKind.QuestionToken ||
|
||||
token() === SyntaxKind.ColonToken ||
|
||||
token() === SyntaxKind.CommaToken ||
|
||||
canParseSemicolon();
|
||||
}
|
||||
return false;
|
||||
|
||||
@ -1102,7 +1102,7 @@ namespace ts {
|
||||
// - This calls resolveModuleNames, and then calls findSourceFile for each resolved module.
|
||||
// As all these operations happen - and are nested - within the createProgram call, they close over the below variables.
|
||||
// The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses.
|
||||
const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2;
|
||||
const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
|
||||
let currentNodeModulesDepth = 0;
|
||||
|
||||
// If a module has some of its imports skipped due to being at the depth limit under node_modules, then track
|
||||
|
||||
@ -291,13 +291,10 @@ namespace ts {
|
||||
function removeFileWatcherCallback(filePath: string, callback: FileWatcherCallback) {
|
||||
const callbacks = fileWatcherCallbacks[filePath];
|
||||
if (callbacks) {
|
||||
const newCallbacks = copyListRemovingItem(callback, callbacks);
|
||||
if (newCallbacks.length === 0) {
|
||||
unorderedRemoveItem(callbacks, callback);
|
||||
if (callbacks.length === 0) {
|
||||
delete fileWatcherCallbacks[filePath];
|
||||
}
|
||||
else {
|
||||
fileWatcherCallbacks[filePath] = newCallbacks;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -482,10 +482,7 @@ namespace ts {
|
||||
sourceFile.fileWatcher.close();
|
||||
sourceFile.fileWatcher = undefined;
|
||||
if (removed) {
|
||||
const index = rootFileNames.indexOf(sourceFile.fileName);
|
||||
if (index >= 0) {
|
||||
rootFileNames.splice(index, 1);
|
||||
}
|
||||
unorderedRemoveItem(rootFileNames, sourceFile.fileName);
|
||||
}
|
||||
startTimerForRecompilation();
|
||||
}
|
||||
|
||||
@ -1120,6 +1120,18 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function isCallLikeExpression(node: Node): node is CallLikeExpression {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.CallExpression:
|
||||
case SyntaxKind.NewExpression:
|
||||
case SyntaxKind.TaggedTemplateExpression:
|
||||
case SyntaxKind.Decorator:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function getInvokedExpression(node: CallLikeExpression): Expression {
|
||||
if (node.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
return (<TaggedTemplateExpression>node).tag;
|
||||
@ -3022,10 +3034,13 @@ namespace ts {
|
||||
return token >= SyntaxKind.FirstAssignment && token <= SyntaxKind.LastAssignment;
|
||||
}
|
||||
|
||||
export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean {
|
||||
return node.kind === SyntaxKind.ExpressionWithTypeArguments &&
|
||||
/** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */
|
||||
export function tryGetClassExtendingExpressionWithTypeArguments(node: Node): ClassLikeDeclaration | undefined {
|
||||
if (node.kind === SyntaxKind.ExpressionWithTypeArguments &&
|
||||
(<HeritageClause>node.parent).token === SyntaxKind.ExtendsKeyword &&
|
||||
isClassLike(node.parent.parent);
|
||||
isClassLike(node.parent.parent)) {
|
||||
return node.parent.parent;
|
||||
}
|
||||
}
|
||||
|
||||
export function isDestructuringAssignment(node: Node): node is BinaryExpression {
|
||||
@ -3058,6 +3073,10 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean {
|
||||
return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined;
|
||||
}
|
||||
|
||||
export function isEntityNameExpression(node: Expression): node is EntityNameExpression {
|
||||
return node.kind === SyntaxKind.Identifier ||
|
||||
node.kind === SyntaxKind.PropertyAccessExpression && isEntityNameExpression((<PropertyAccessExpression>node).expression);
|
||||
|
||||
@ -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[]) {
|
||||
@ -777,6 +795,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];
|
||||
@ -811,6 +843,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);
|
||||
@ -856,30 +892,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[]) {
|
||||
@ -1546,7 +1564,7 @@ namespace FourSlash {
|
||||
public goToDefinition(definitionIndex: number) {
|
||||
const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (!definitions || !definitions.length) {
|
||||
this.raiseError("goToDefinition failed - expected to at least one definition location but got 0");
|
||||
this.raiseError("goToDefinition failed - expected to find at least one definition location but got 0");
|
||||
}
|
||||
|
||||
if (definitionIndex >= definitions.length) {
|
||||
@ -1561,7 +1579,7 @@ namespace FourSlash {
|
||||
public goToTypeDefinition(definitionIndex: number) {
|
||||
const definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (!definitions || !definitions.length) {
|
||||
this.raiseError("goToTypeDefinition failed - expected to at least one definition location but got 0");
|
||||
this.raiseError("goToTypeDefinition failed - expected to find at least one definition location but got 0");
|
||||
}
|
||||
|
||||
if (definitionIndex >= definitions.length) {
|
||||
@ -1582,7 +1600,7 @@ namespace FourSlash {
|
||||
this.raiseError(`goToDefinition - expected to 0 definition locations but got ${definitions.length}`);
|
||||
}
|
||||
else if (!foundDefinitions && !negative) {
|
||||
this.raiseError("goToDefinition - expected to at least one definition location but got 0");
|
||||
this.raiseError("goToDefinition - expected to find at least one definition location but got 0");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2947,6 +2965,10 @@ namespace FourSlashInterface {
|
||||
this.state.verifyRangesReferenceEachOther(ranges);
|
||||
}
|
||||
|
||||
public findReferencesDefinitionDisplayPartsAtCaretAre(expected: ts.SymbolDisplayPart[]) {
|
||||
this.state.verifyDisplayPartsOfReferencedSymbol(expected);
|
||||
}
|
||||
|
||||
public rangesWithSameTextReferenceEachOther() {
|
||||
this.state.verifyRangesWithSameTextReferenceEachOther();
|
||||
}
|
||||
|
||||
@ -1444,23 +1444,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;
|
||||
@ -1470,7 +1478,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 {
|
||||
@ -1846,7 +1859,7 @@ namespace Harness {
|
||||
tsConfig.options.configFilePath = data.name;
|
||||
|
||||
// delete entry from the list
|
||||
testUnitData.splice(i, 1);
|
||||
ts.orderedRemoveItemAt(testUnitData, i);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1967,7 +1980,6 @@ namespace Harness {
|
||||
|
||||
export function runBaseline(relativeFileName: string, generateContent: () => string, opts?: BaselineOptions): void {
|
||||
const actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder);
|
||||
|
||||
const actual = generateActual(generateContent);
|
||||
const comparison = compareToBaseline(actual, relativeFileName, opts);
|
||||
writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName);
|
||||
|
||||
@ -509,7 +509,6 @@ class ProjectRunner extends RunnerBase {
|
||||
// });
|
||||
|
||||
// Verify that all the generated .d.ts files compile
|
||||
|
||||
it("Errors in generated Dts files for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => {
|
||||
if (!compilerResult.errors.length && testCase.declaration) {
|
||||
const dTsCompileResult = compileCompileDTsFiles(compilerResult);
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -403,6 +403,7 @@ namespace ts {
|
||||
{
|
||||
compilerOptions: <CompilerOptions>{
|
||||
allowJs: true,
|
||||
maxNodeModuleJsDepth: 2,
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
@ -429,6 +430,7 @@ namespace ts {
|
||||
{
|
||||
compilerOptions: <CompilerOptions>{
|
||||
allowJs: false,
|
||||
maxNodeModuleJsDepth: 2,
|
||||
module: ModuleKind.CommonJS,
|
||||
target: ScriptTarget.ES5,
|
||||
noImplicitAny: false,
|
||||
@ -450,7 +452,8 @@ namespace ts {
|
||||
{
|
||||
compilerOptions:
|
||||
{
|
||||
allowJs: true
|
||||
allowJs: true,
|
||||
maxNodeModuleJsDepth: 2
|
||||
},
|
||||
errors: [{
|
||||
file: undefined,
|
||||
@ -469,7 +472,8 @@ namespace ts {
|
||||
{
|
||||
compilerOptions:
|
||||
{
|
||||
allowJs: true
|
||||
allowJs: true,
|
||||
maxNodeModuleJsDepth: 2
|
||||
},
|
||||
errors: <Diagnostic[]>[]
|
||||
}
|
||||
|
||||
@ -289,4 +289,4 @@ namespace ts {
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,79 +0,0 @@
|
||||
class a {
|
||||
constructor ( n : number ) ;
|
||||
constructor ( s : string ) ;
|
||||
constructor ( ns : any ) {
|
||||
|
||||
}
|
||||
|
||||
public pgF ( ) { } ;
|
||||
|
||||
public pv ;
|
||||
public get d ( ) {
|
||||
return 30 ;
|
||||
}
|
||||
public set d ( ) {
|
||||
}
|
||||
|
||||
public static get p2 ( ) {
|
||||
return { x : 30 , y : 40 } ;
|
||||
}
|
||||
|
||||
private static d2 ( ) {
|
||||
}
|
||||
private static get p3 ( ) {
|
||||
return "string" ;
|
||||
}
|
||||
private pv3 ;
|
||||
|
||||
private foo ( n : number ) : string ;
|
||||
private foo ( s : string ) : string ;
|
||||
private foo ( ns : any ) {
|
||||
return ns.toString ( ) ;
|
||||
}
|
||||
}
|
||||
|
||||
class b extends a {
|
||||
}
|
||||
|
||||
class m1b {
|
||||
|
||||
}
|
||||
|
||||
interface m1ib {
|
||||
|
||||
}
|
||||
class c extends m1b {
|
||||
}
|
||||
|
||||
class ib2 implements m1ib {
|
||||
}
|
||||
|
||||
declare class aAmbient {
|
||||
constructor ( n : number ) ;
|
||||
constructor ( s : string ) ;
|
||||
public pgF ( ) : void ;
|
||||
public pv ;
|
||||
public d : number ;
|
||||
static p2 : { x : number ; y : number ; } ;
|
||||
static d2 ( ) ;
|
||||
static p3 ;
|
||||
private pv3 ;
|
||||
private foo ( s ) ;
|
||||
}
|
||||
|
||||
class d {
|
||||
private foo ( n : number ) : string ;
|
||||
private foo ( ns : any ) {
|
||||
return ns.toString ( ) ;
|
||||
}
|
||||
private foo ( s : string ) : string ;
|
||||
}
|
||||
|
||||
class e {
|
||||
private foo ( ns : any ) {
|
||||
return ns.toString ( ) ;
|
||||
}
|
||||
private foo ( s : string ) : string ;
|
||||
private foo ( n : number ) : string ;
|
||||
}
|
||||
|
||||
@ -1,79 +0,0 @@
|
||||
class a {
|
||||
constructor(n: number);
|
||||
constructor(s: string);
|
||||
constructor(ns: any) {
|
||||
|
||||
}
|
||||
|
||||
public pgF() { };
|
||||
|
||||
public pv;
|
||||
public get d() {
|
||||
return 30;
|
||||
}
|
||||
public set d() {
|
||||
}
|
||||
|
||||
public static get p2() {
|
||||
return { x: 30, y: 40 };
|
||||
}
|
||||
|
||||
private static d2() {
|
||||
}
|
||||
private static get p3() {
|
||||
return "string";
|
||||
}
|
||||
private pv3;
|
||||
|
||||
private foo(n: number): string;
|
||||
private foo(s: string): string;
|
||||
private foo(ns: any) {
|
||||
return ns.toString();
|
||||
}
|
||||
}
|
||||
|
||||
class b extends a {
|
||||
}
|
||||
|
||||
class m1b {
|
||||
|
||||
}
|
||||
|
||||
interface m1ib {
|
||||
|
||||
}
|
||||
class c extends m1b {
|
||||
}
|
||||
|
||||
class ib2 implements m1ib {
|
||||
}
|
||||
|
||||
declare class aAmbient {
|
||||
constructor(n: number);
|
||||
constructor(s: string);
|
||||
public pgF(): void;
|
||||
public pv;
|
||||
public d: number;
|
||||
static p2: { x: number; y: number; };
|
||||
static d2();
|
||||
static p3;
|
||||
private pv3;
|
||||
private foo(s);
|
||||
}
|
||||
|
||||
class d {
|
||||
private foo(n: number): string;
|
||||
private foo(ns: any) {
|
||||
return ns.toString();
|
||||
}
|
||||
private foo(s: string): string;
|
||||
}
|
||||
|
||||
class e {
|
||||
private foo(ns: any) {
|
||||
return ns.toString();
|
||||
}
|
||||
private foo(s: string): string;
|
||||
private foo(n: number): string;
|
||||
}
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
class foo {
|
||||
constructor (n?: number, m? = 5, o?: string = "") { }
|
||||
x:number = 1?2:3;
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
class foo {
|
||||
constructor(n?: number, m? = 5, o?: string = "") { }
|
||||
x: number = 1 ? 2 : 3;
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
$ ( document ) . ready ( function ( ) {
|
||||
alert ( 'i am ready' ) ;
|
||||
} );
|
||||
@ -1,3 +0,0 @@
|
||||
$(document).ready(function() {
|
||||
alert('i am ready');
|
||||
});
|
||||
@ -1 +0,0 @@
|
||||
{}
|
||||
@ -1 +0,0 @@
|
||||
{ }
|
||||
@ -1,10 +0,0 @@
|
||||
function foo ( x : { } ) { }
|
||||
|
||||
foo ( { } ) ;
|
||||
|
||||
|
||||
|
||||
interface bar {
|
||||
x : { } ;
|
||||
y : ( ) => { } ;
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
function foo(x: {}) { }
|
||||
|
||||
foo({});
|
||||
|
||||
|
||||
|
||||
interface bar {
|
||||
x: {};
|
||||
y: () => {};
|
||||
}
|
||||
@ -1,112 +0,0 @@
|
||||
// valid
|
||||
( ) => 1 ;
|
||||
( arg ) => 2 ;
|
||||
arg => 2 ;
|
||||
( arg = 1 ) => 3 ;
|
||||
( arg ? ) => 4 ;
|
||||
( arg : number ) => 5 ;
|
||||
( arg : number = 0 ) => 6 ;
|
||||
( arg ? : number ) => 7 ;
|
||||
( ... arg : number [ ] ) => 8 ;
|
||||
( arg1 , arg2 ) => 12 ;
|
||||
( arg1 = 1 , arg2 =3 ) => 13 ;
|
||||
( arg1 ? , arg2 ? ) => 14 ;
|
||||
( arg1 : number , arg2 : number ) => 15 ;
|
||||
( arg1 : number = 0 , arg2 : number = 1 ) => 16 ;
|
||||
( arg1 ? : number , arg2 ? : number ) => 17 ;
|
||||
( arg1 , ... arg2 : number [ ] ) => 18 ;
|
||||
( arg1 , arg2 ? : number ) => 19 ;
|
||||
|
||||
// in paren
|
||||
( ( ) => 21 ) ;
|
||||
( ( arg ) => 22 ) ;
|
||||
( ( arg = 1 ) => 23 ) ;
|
||||
( ( arg ? ) => 24 ) ;
|
||||
( ( arg : number ) => 25 ) ;
|
||||
( ( arg : number = 0 ) => 26 ) ;
|
||||
( ( arg ? : number ) => 27 ) ;
|
||||
( ( ... arg : number [ ] ) => 28 ) ;
|
||||
|
||||
// in multiple paren
|
||||
( ( ( ( ( arg ) => { return 32 ; } ) ) ) ) ;
|
||||
|
||||
// in ternary exression
|
||||
false ? ( ) => 41 : null ;
|
||||
false ? ( arg ) => 42 : null ;
|
||||
false ? ( arg = 1 ) => 43 : null ;
|
||||
false ? ( arg ? ) => 44 : null ;
|
||||
false ? ( arg : number ) => 45 : null ;
|
||||
false ? ( arg ? : number ) => 46 : null ;
|
||||
false ? ( arg ? : number = 0 ) => 47 : null ;
|
||||
false ? ( ... arg : number [ ] ) => 48 : null ;
|
||||
|
||||
// in ternary exression within paren
|
||||
false ? ( ( ) => 51 ) : null ;
|
||||
false ? ( ( arg ) => 52 ) : null ;
|
||||
false ? ( ( arg = 1 ) => 53 ) : null ;
|
||||
false ? ( ( arg ? ) => 54 ) : null ;
|
||||
false ? ( ( arg : number ) => 55 ) : null ;
|
||||
false ? ( ( arg ? : number ) => 56 ) : null ;
|
||||
false ? ( ( arg ? : number = 0 ) => 57 ) : null ;
|
||||
false ? ( ( ... arg : number [ ] ) => 58 ) : null ;
|
||||
|
||||
// ternary exression's else clause
|
||||
false ? null : ( ) => 61 ;
|
||||
false ? null : ( arg ) => 62 ;
|
||||
false ? null : ( arg = 1 ) => 63 ;
|
||||
false ? null : ( arg ? ) => 64 ;
|
||||
false ? null : ( arg : number ) => 65 ;
|
||||
false ? null : ( arg ? : number ) => 66 ;
|
||||
false ? null : ( arg ? : number = 0 ) => 67 ;
|
||||
false ? null : ( ... arg : number [ ] ) => 68 ;
|
||||
|
||||
|
||||
// nested ternary expressions
|
||||
( a ? ) => { return a ; } ? ( b ? ) => { return b ; } : ( c ? ) => { return c ; } ;
|
||||
|
||||
//multiple levels
|
||||
( a ? ) => { return a ; } ? ( b ) => ( c ) => 81 : ( c ) => ( d ) => 82 ;
|
||||
|
||||
|
||||
// In Expressions
|
||||
( ( arg ) => 90 ) instanceof Function ;
|
||||
( ( arg = 1 ) => 91 ) instanceof Function ;
|
||||
( ( arg ? ) => 92 ) instanceof Function ;
|
||||
( ( arg : number ) => 93 ) instanceof Function ;
|
||||
( ( arg : number = 1 ) => 94 ) instanceof Function ;
|
||||
( ( arg ? : number ) => 95 ) instanceof Function ;
|
||||
( ( ... arg : number [ ] ) => 96 ) instanceof Function ;
|
||||
|
||||
'' + ( arg ) => 100 ;
|
||||
( ( arg ) => 0 ) + '' + ( arg ) => 101 ;
|
||||
( ( arg = 1 ) => 0 ) + '' + ( arg = 2 ) => 102 ;
|
||||
( ( arg ? ) => 0 ) + '' + ( arg ? ) => 103 ;
|
||||
( ( arg : number ) => 0 ) + '' + ( arg : number ) => 104 ;
|
||||
( ( arg : number = 1 ) => 0 ) + '' + ( arg : number = 2 ) => 105 ;
|
||||
( ( arg ? : number = 1 ) => 0 ) + '' + ( arg ? : number = 2 ) => 106 ;
|
||||
( ( ... arg : number [ ] ) => 0 ) + '' + ( ... arg : number [ ] ) => 107 ;
|
||||
( ( arg1 , arg2 ? ) => 0 ) + '' + ( arg1 , arg2 ? ) => 108 ;
|
||||
( ( arg1 , ... arg2 : number [ ] ) => 0 ) + '' + ( arg1 , ... arg2 : number [ ] ) => 108 ;
|
||||
|
||||
|
||||
// Function Parameters
|
||||
function foo ( ... arg : any [ ] ) { }
|
||||
|
||||
foo (
|
||||
( a ) => 110 ,
|
||||
( ( a ) => 111 ) ,
|
||||
( a ) => {
|
||||
return 112 ;
|
||||
} ,
|
||||
( a ? ) => 113 ,
|
||||
( a , b ? ) => 114 ,
|
||||
( a : number ) => 115 ,
|
||||
( a : number = 0 ) => 116 ,
|
||||
( a = 0 ) => 117 ,
|
||||
( a ? : number = 0 ) => 118 ,
|
||||
( a ? , b ? : number = 0 ) => 118 ,
|
||||
( ... a : number [ ] ) => 119 ,
|
||||
( a , b ? = 0 , ... c : number [ ] ) => 120 ,
|
||||
( a ) => ( b ) => ( c ) => 121 ,
|
||||
false ? ( a ) => 0 : ( b ) => 122
|
||||
) ;
|
||||
@ -1,112 +0,0 @@
|
||||
// valid
|
||||
() => 1;
|
||||
(arg) => 2;
|
||||
arg => 2;
|
||||
(arg = 1) => 3;
|
||||
(arg?) => 4;
|
||||
(arg: number) => 5;
|
||||
(arg: number = 0) => 6;
|
||||
(arg?: number) => 7;
|
||||
(...arg: number[]) => 8;
|
||||
(arg1, arg2) => 12;
|
||||
(arg1 = 1, arg2 = 3) => 13;
|
||||
(arg1?, arg2?) => 14;
|
||||
(arg1: number, arg2: number) => 15;
|
||||
(arg1: number = 0, arg2: number = 1) => 16;
|
||||
(arg1?: number, arg2?: number) => 17;
|
||||
(arg1, ...arg2: number[]) => 18;
|
||||
(arg1, arg2?: number) => 19;
|
||||
|
||||
// in paren
|
||||
(() => 21);
|
||||
((arg) => 22);
|
||||
((arg = 1) => 23);
|
||||
((arg?) => 24);
|
||||
((arg: number) => 25);
|
||||
((arg: number = 0) => 26);
|
||||
((arg?: number) => 27);
|
||||
((...arg: number[]) => 28);
|
||||
|
||||
// in multiple paren
|
||||
(((((arg) => { return 32; }))));
|
||||
|
||||
// in ternary exression
|
||||
false ? () => 41 : null;
|
||||
false ? (arg) => 42 : null;
|
||||
false ? (arg = 1) => 43 : null;
|
||||
false ? (arg?) => 44 : null;
|
||||
false ? (arg: number) => 45 : null;
|
||||
false ? (arg?: number) => 46 : null;
|
||||
false ? (arg?: number = 0) => 47 : null;
|
||||
false ? (...arg: number[]) => 48 : null;
|
||||
|
||||
// in ternary exression within paren
|
||||
false ? (() => 51) : null;
|
||||
false ? ((arg) => 52) : null;
|
||||
false ? ((arg = 1) => 53) : null;
|
||||
false ? ((arg?) => 54) : null;
|
||||
false ? ((arg: number) => 55) : null;
|
||||
false ? ((arg?: number) => 56) : null;
|
||||
false ? ((arg?: number = 0) => 57) : null;
|
||||
false ? ((...arg: number[]) => 58) : null;
|
||||
|
||||
// ternary exression's else clause
|
||||
false ? null : () => 61;
|
||||
false ? null : (arg) => 62;
|
||||
false ? null : (arg = 1) => 63;
|
||||
false ? null : (arg?) => 64;
|
||||
false ? null : (arg: number) => 65;
|
||||
false ? null : (arg?: number) => 66;
|
||||
false ? null : (arg?: number = 0) => 67;
|
||||
false ? null : (...arg: number[]) => 68;
|
||||
|
||||
|
||||
// nested ternary expressions
|
||||
(a?) => { return a; } ? (b?) => { return b; } : (c?) => { return c; };
|
||||
|
||||
//multiple levels
|
||||
(a?) => { return a; } ? (b) => (c) => 81 : (c) => (d) => 82;
|
||||
|
||||
|
||||
// In Expressions
|
||||
((arg) => 90) instanceof Function;
|
||||
((arg = 1) => 91) instanceof Function;
|
||||
((arg?) => 92) instanceof Function;
|
||||
((arg: number) => 93) instanceof Function;
|
||||
((arg: number = 1) => 94) instanceof Function;
|
||||
((arg?: number) => 95) instanceof Function;
|
||||
((...arg: number[]) => 96) instanceof Function;
|
||||
|
||||
'' + (arg) => 100;
|
||||
((arg) => 0) + '' + (arg) => 101;
|
||||
((arg = 1) => 0) + '' + (arg = 2) => 102;
|
||||
((arg?) => 0) + '' + (arg?) => 103;
|
||||
((arg: number) => 0) + '' + (arg: number) => 104;
|
||||
((arg: number = 1) => 0) + '' + (arg: number = 2) => 105;
|
||||
((arg?: number = 1) => 0) + '' + (arg?: number = 2) => 106;
|
||||
((...arg: number[]) => 0) + '' + (...arg: number[]) => 107;
|
||||
((arg1, arg2?) => 0) + '' + (arg1, arg2?) => 108;
|
||||
((arg1, ...arg2: number[]) => 0) + '' + (arg1, ...arg2: number[]) => 108;
|
||||
|
||||
|
||||
// Function Parameters
|
||||
function foo(...arg: any[]) { }
|
||||
|
||||
foo(
|
||||
(a) => 110,
|
||||
((a) => 111),
|
||||
(a) => {
|
||||
return 112;
|
||||
},
|
||||
(a?) => 113,
|
||||
(a, b?) => 114,
|
||||
(a: number) => 115,
|
||||
(a: number = 0) => 116,
|
||||
(a = 0) => 117,
|
||||
(a?: number = 0) => 118,
|
||||
(a?, b?: number = 0) => 118,
|
||||
(...a: number[]) => 119,
|
||||
(a, b? = 0, ...c: number[]) => 120,
|
||||
(a) => (b) => (c) => 121,
|
||||
false ? (a) => 0 : (b) => 122
|
||||
);
|
||||
@ -1,2 +0,0 @@
|
||||
if(false){debugger;}
|
||||
if ( false ) { debugger ; }
|
||||
@ -1,2 +0,0 @@
|
||||
if (false) { debugger; }
|
||||
if (false) { debugger; }
|
||||
@ -1,13 +0,0 @@
|
||||
var fun1 = function ( ) {
|
||||
var x = 'foo' ,
|
||||
z = 'bar' ;
|
||||
return x ;
|
||||
},
|
||||
|
||||
fun2 = ( function ( f ) {
|
||||
var fun = function ( ) {
|
||||
console . log ( f ( ) ) ;
|
||||
},
|
||||
x = 'Foo' ;
|
||||
return fun ;
|
||||
} ( fun1 ) ) ;
|
||||
@ -1,13 +0,0 @@
|
||||
var fun1 = function() {
|
||||
var x = 'foo',
|
||||
z = 'bar';
|
||||
return x;
|
||||
},
|
||||
|
||||
fun2 = (function(f) {
|
||||
var fun = function() {
|
||||
console.log(f());
|
||||
},
|
||||
x = 'Foo';
|
||||
return fun;
|
||||
} (fun1));
|
||||
@ -1,3 +0,0 @@
|
||||
export class A {
|
||||
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
export class A {
|
||||
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
module Foo {
|
||||
}
|
||||
|
||||
import bar = Foo;
|
||||
|
||||
import bar2=Foo;
|
||||
@ -1,6 +0,0 @@
|
||||
module Foo {
|
||||
}
|
||||
|
||||
import bar = Foo;
|
||||
|
||||
import bar2 = Foo;
|
||||
@ -1,95 +0,0 @@
|
||||
|
||||
var a;var c , b;var $d
|
||||
var $e
|
||||
var f
|
||||
a++;b++;
|
||||
|
||||
function f ( ) {
|
||||
for (i = 0; i < 10; i++) {
|
||||
k = abc + 123 ^ d;
|
||||
a = XYZ[m (a[b[c][d]])];
|
||||
break;
|
||||
|
||||
switch ( variable){
|
||||
case 1: abc += 425;
|
||||
break;
|
||||
case 404 : a [x--/2]%=3 ;
|
||||
break ;
|
||||
case vari : v[--x ] *=++y*( m + n / k[z]);
|
||||
for (a in b){
|
||||
for (a = 0; a < 10; ++a) {
|
||||
a++;--a;
|
||||
if (a == b) {
|
||||
a++;b--;
|
||||
}
|
||||
else
|
||||
if (a == c){
|
||||
++a;
|
||||
(--c)+=d;
|
||||
$c = $a + --$b;
|
||||
}
|
||||
if (a == b)
|
||||
if (a != b) {
|
||||
if (a !== b)
|
||||
if (a === b)
|
||||
--a;
|
||||
else
|
||||
--a;
|
||||
else {
|
||||
a--;++b;
|
||||
a++
|
||||
}
|
||||
}
|
||||
}
|
||||
for (x in y) {
|
||||
m-=m;
|
||||
k=1+2+3+4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
var a ={b:function(){}};
|
||||
return {a:1,b:2}
|
||||
}
|
||||
|
||||
var z = 1;
|
||||
for (i = 0; i < 10; i++)
|
||||
for (j = 0; j < 10; j++)
|
||||
for (k = 0; k < 10; ++k) {
|
||||
z++;
|
||||
}
|
||||
|
||||
for (k = 0; k < 10; k += 2) {
|
||||
z++;
|
||||
}
|
||||
|
||||
$(document).ready ();
|
||||
|
||||
|
||||
function pageLoad() {
|
||||
$('#TextBox1' ) . unbind ( ) ;
|
||||
$('#TextBox1' ) . datepicker ( ) ;
|
||||
}
|
||||
|
||||
function pageLoad ( ) {
|
||||
var webclass=[
|
||||
{ 'student' :
|
||||
{ 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }
|
||||
} ,
|
||||
{ 'student':
|
||||
{'id':'2','name':'Adam Davidson','legacySkill':'Cobol,MainFrame'}
|
||||
} ,
|
||||
{ 'student':
|
||||
{ 'id':'3','name':'Charles Boyer' ,'legacySkill':'HTML, XML'}
|
||||
}
|
||||
];
|
||||
|
||||
$create(Sys.UI.DataView,{data:webclass},null,null,$get('SList'));
|
||||
|
||||
}
|
||||
|
||||
$( document ).ready(function(){
|
||||
alert('hello');
|
||||
} ) ;
|
||||
@ -1,98 +0,0 @@
|
||||
|
||||
var a; var c, b; var $d
|
||||
var $e
|
||||
var f
|
||||
a++; b++;
|
||||
|
||||
function f() {
|
||||
for (i = 0; i < 10; i++) {
|
||||
k = abc + 123 ^ d;
|
||||
a = XYZ[m(a[b[c][d]])];
|
||||
break;
|
||||
|
||||
switch (variable) {
|
||||
case 1: abc += 425;
|
||||
break;
|
||||
case 404: a[x-- / 2] %= 3;
|
||||
break;
|
||||
case vari: v[--x] *= ++y * (m + n / k[z]);
|
||||
for (a in b) {
|
||||
for (a = 0; a < 10; ++a) {
|
||||
a++; --a;
|
||||
if (a == b) {
|
||||
a++; b--;
|
||||
}
|
||||
else
|
||||
if (a == c) {
|
||||
++a;
|
||||
(--c) += d;
|
||||
$c = $a + --$b;
|
||||
}
|
||||
if (a == b)
|
||||
if (a != b) {
|
||||
if (a !== b)
|
||||
if (a === b)
|
||||
--a;
|
||||
else
|
||||
--a;
|
||||
else {
|
||||
a--; ++b;
|
||||
a++
|
||||
}
|
||||
}
|
||||
}
|
||||
for (x in y) {
|
||||
m -= m;
|
||||
k = 1 + 2 + 3 + 4;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
var a = { b: function() { } };
|
||||
return { a: 1, b: 2 }
|
||||
}
|
||||
|
||||
var z = 1;
|
||||
for (i = 0; i < 10; i++)
|
||||
for (j = 0; j < 10; j++)
|
||||
for (k = 0; k < 10; ++k) {
|
||||
z++;
|
||||
}
|
||||
|
||||
for (k = 0; k < 10; k += 2) {
|
||||
z++;
|
||||
}
|
||||
|
||||
$(document).ready();
|
||||
|
||||
|
||||
function pageLoad() {
|
||||
$('#TextBox1').unbind();
|
||||
$('#TextBox1').datepicker();
|
||||
}
|
||||
|
||||
function pageLoad() {
|
||||
var webclass = [
|
||||
{
|
||||
'student':
|
||||
{ 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' }
|
||||
},
|
||||
{
|
||||
'student':
|
||||
{ 'id': '2', 'name': 'Adam Davidson', 'legacySkill': 'Cobol,MainFrame' }
|
||||
},
|
||||
{
|
||||
'student':
|
||||
{ 'id': '3', 'name': 'Charles Boyer', 'legacySkill': 'HTML, XML' }
|
||||
}
|
||||
];
|
||||
|
||||
$create(Sys.UI.DataView, { data: webclass }, null, null, $get('SList'));
|
||||
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
alert('hello');
|
||||
});
|
||||
@ -1,3 +0,0 @@
|
||||
module Foo {
|
||||
export module A . B . C { }
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
module Foo {
|
||||
export module A.B.C { }
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
module mod1 {
|
||||
export class b {
|
||||
}
|
||||
class d {
|
||||
}
|
||||
|
||||
|
||||
export interface ib {
|
||||
}
|
||||
}
|
||||
|
||||
module m2 {
|
||||
|
||||
export module m3 {
|
||||
export class c extends mod1.b {
|
||||
}
|
||||
export class ib2 implements mod1.ib {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class c extends mod1.b {
|
||||
}
|
||||
|
||||
class ib2 implements mod1.ib {
|
||||
}
|
||||
|
||||
declare export module "m4" {
|
||||
export class d {
|
||||
} ;
|
||||
var x : d ;
|
||||
export function foo ( ) : d ;
|
||||
}
|
||||
|
||||
import m4 = module ( "m4" ) ;
|
||||
export var x4 = m4.x ;
|
||||
export var d4 = m4.d ;
|
||||
export var f4 = m4.foo ( ) ;
|
||||
|
||||
export module m1 {
|
||||
declare export module "m2" {
|
||||
export class d {
|
||||
} ;
|
||||
var x: d ;
|
||||
export function foo ( ) : d ;
|
||||
}
|
||||
import m2 = module ( "m2" ) ;
|
||||
import m3 = module ( "m4" ) ;
|
||||
|
||||
export var x2 = m2.x ;
|
||||
export var d2 = m2.d ;
|
||||
export var f2 = m2.foo ( ) ;
|
||||
|
||||
export var x3 = m3.x ;
|
||||
export var d3 = m3.d ;
|
||||
export var f3 = m3.foo ( ) ;
|
||||
}
|
||||
|
||||
export var x2 = m1.m2.x ;
|
||||
export var d2 = m1.m2.d ;
|
||||
export var f2 = m1.m2.foo ( ) ;
|
||||
|
||||
export var x3 = m1.m3.x ;
|
||||
export var d3 = m1.m3.d ;
|
||||
export var f3 = m1.m3.foo ( ) ;
|
||||
|
||||
export module m5 {
|
||||
export var x2 = m1.m2.x ;
|
||||
export var d2 = m1.m2.d ;
|
||||
export var f2 = m1.m2.foo ( ) ;
|
||||
|
||||
export var x3 = m1.m3.x ;
|
||||
export var d3 = m1.m3.d ;
|
||||
export var f3 = m1.m3.foo ( ) ;
|
||||
}
|
||||
|
||||
@ -1,76 +0,0 @@
|
||||
module mod1 {
|
||||
export class b {
|
||||
}
|
||||
class d {
|
||||
}
|
||||
|
||||
|
||||
export interface ib {
|
||||
}
|
||||
}
|
||||
|
||||
module m2 {
|
||||
|
||||
export module m3 {
|
||||
export class c extends mod1.b {
|
||||
}
|
||||
export class ib2 implements mod1.ib {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class c extends mod1.b {
|
||||
}
|
||||
|
||||
class ib2 implements mod1.ib {
|
||||
}
|
||||
|
||||
declare export module "m4" {
|
||||
export class d {
|
||||
};
|
||||
var x: d;
|
||||
export function foo(): d;
|
||||
}
|
||||
|
||||
import m4 = module("m4");
|
||||
export var x4 = m4.x;
|
||||
export var d4 = m4.d;
|
||||
export var f4 = m4.foo();
|
||||
|
||||
export module m1 {
|
||||
declare export module "m2" {
|
||||
export class d {
|
||||
};
|
||||
var x: d;
|
||||
export function foo(): d;
|
||||
}
|
||||
import m2 = module("m2");
|
||||
import m3 = module("m4");
|
||||
|
||||
export var x2 = m2.x;
|
||||
export var d2 = m2.d;
|
||||
export var f2 = m2.foo();
|
||||
|
||||
export var x3 = m3.x;
|
||||
export var d3 = m3.d;
|
||||
export var f3 = m3.foo();
|
||||
}
|
||||
|
||||
export var x2 = m1.m2.x;
|
||||
export var d2 = m1.m2.d;
|
||||
export var f2 = m1.m2.foo();
|
||||
|
||||
export var x3 = m1.m3.x;
|
||||
export var d3 = m1.m3.d;
|
||||
export var f3 = m1.m3.foo();
|
||||
|
||||
export module m5 {
|
||||
export var x2 = m1.m2.x;
|
||||
export var d2 = m1.m2.d;
|
||||
export var f2 = m1.m2.foo();
|
||||
|
||||
export var x3 = m1.m3.x;
|
||||
export var d3 = m1.m3.d;
|
||||
export var f3 = m1.m3.foo();
|
||||
}
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
var x = {foo: 1,
|
||||
bar: "tt",
|
||||
boo: 1 + 5};
|
||||
|
||||
var x2 = {foo: 1,
|
||||
bar: "tt",boo:1+5};
|
||||
|
||||
function Foo() {
|
||||
var typeICalc = {
|
||||
clear: {
|
||||
"()": [1, 2, 3]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Rule for object literal members for the "value" of the memebr to follow the indent
|
||||
// of the member, i.e. the relative position of the value is maintained when the member
|
||||
// is indented.
|
||||
var x2 = {
|
||||
foo:
|
||||
3,
|
||||
'bar':
|
||||
{ a: 1, b : 2}
|
||||
};
|
||||
|
||||
var x={ };
|
||||
var y = {};
|
||||
@ -1,31 +0,0 @@
|
||||
var x = {
|
||||
foo: 1,
|
||||
bar: "tt",
|
||||
boo: 1 + 5
|
||||
};
|
||||
|
||||
var x2 = {
|
||||
foo: 1,
|
||||
bar: "tt", boo: 1 + 5
|
||||
};
|
||||
|
||||
function Foo() {
|
||||
var typeICalc = {
|
||||
clear: {
|
||||
"()": [1, 2, 3]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Rule for object literal members for the "value" of the memebr to follow the indent
|
||||
// of the member, i.e. the relative position of the value is maintained when the member
|
||||
// is indented.
|
||||
var x2 = {
|
||||
foo:
|
||||
3,
|
||||
'bar':
|
||||
{ a: 1, b: 2 }
|
||||
};
|
||||
|
||||
var x = {};
|
||||
var y = {};
|
||||
@ -1,32 +0,0 @@
|
||||
function f( ) {
|
||||
var x = 3;
|
||||
var z = 2 ;
|
||||
a = z ++ - 2 * x ;
|
||||
for ( ; ; ) {
|
||||
a+=(g +g)*a%t;
|
||||
b -- ;
|
||||
}
|
||||
|
||||
switch ( a )
|
||||
{
|
||||
case 1 : {
|
||||
a ++ ;
|
||||
b--;
|
||||
if(a===a)
|
||||
return;
|
||||
else
|
||||
{
|
||||
for(a in b)
|
||||
if(a!=a)
|
||||
{
|
||||
for(a in b)
|
||||
{
|
||||
a++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1,28 +0,0 @@
|
||||
function f() {
|
||||
var x = 3;
|
||||
var z = 2;
|
||||
a = z++ - 2 * x;
|
||||
for (; ;) {
|
||||
a += (g + g) * a % t;
|
||||
b--;
|
||||
}
|
||||
|
||||
switch (a) {
|
||||
case 1: {
|
||||
a++;
|
||||
b--;
|
||||
if (a === a)
|
||||
return;
|
||||
else {
|
||||
for (a in b)
|
||||
if (a != a) {
|
||||
for (a in b) {
|
||||
a++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
var a=b+c^d-e*++f;
|
||||
@ -1 +0,0 @@
|
||||
var a = b + c ^ d - e * ++f;
|
||||
@ -1 +0,0 @@
|
||||
class test { constructor () { } }
|
||||
@ -1 +0,0 @@
|
||||
class test { constructor() { } }
|
||||
@ -1,10 +0,0 @@
|
||||
module Tools {
|
||||
export enum NodeType {
|
||||
Error,
|
||||
Comment,
|
||||
}
|
||||
export enum foob
|
||||
{
|
||||
Blah=1, Bleah=2
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
module Tools {
|
||||
export enum NodeType {
|
||||
Error,
|
||||
Comment,
|
||||
}
|
||||
export enum foob {
|
||||
Blah = 1, Bleah = 2
|
||||
}
|
||||
}
|
||||
@ -1,65 +0,0 @@
|
||||
module MyModule
|
||||
{
|
||||
module A.B.C {
|
||||
module F {
|
||||
}
|
||||
}
|
||||
interface Blah
|
||||
{
|
||||
boo: string;
|
||||
}
|
||||
|
||||
class Foo
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class Foo2 {
|
||||
public foo():number {
|
||||
return 5 * 6;
|
||||
}
|
||||
public foo2() {
|
||||
if (1 === 2)
|
||||
|
||||
|
||||
{
|
||||
var y : number= 76;
|
||||
return y;
|
||||
}
|
||||
|
||||
while (2 == 3) {
|
||||
if ( y == null ) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public foo3() {
|
||||
if (1 === 2)
|
||||
|
||||
//comment preventing line merging
|
||||
{
|
||||
var y = 76;
|
||||
return y;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function foo(a:number, b:number):number
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
function bar(a:number, b:number) :number[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
module BugFix3 {
|
||||
declare var f: {
|
||||
(): any;
|
||||
(x: number): string;
|
||||
foo: number;
|
||||
};
|
||||
}
|
||||
@ -1,58 +0,0 @@
|
||||
module MyModule {
|
||||
module A.B.C {
|
||||
module F {
|
||||
}
|
||||
}
|
||||
interface Blah {
|
||||
boo: string;
|
||||
}
|
||||
|
||||
class Foo {
|
||||
|
||||
}
|
||||
|
||||
class Foo2 {
|
||||
public foo(): number {
|
||||
return 5 * 6;
|
||||
}
|
||||
public foo2() {
|
||||
if (1 === 2) {
|
||||
var y: number = 76;
|
||||
return y;
|
||||
}
|
||||
|
||||
while (2 == 3) {
|
||||
if (y == null) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public foo3() {
|
||||
if (1 === 2)
|
||||
|
||||
//comment preventing line merging
|
||||
{
|
||||
var y = 76;
|
||||
return y;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function foo(a: number, b: number): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
function bar(a: number, b: number): number[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
module BugFix3 {
|
||||
declare var f: {
|
||||
(): any;
|
||||
(x: number): string;
|
||||
foo: number;
|
||||
};
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
function f(a,b,c,d){
|
||||
for(var i=0;i<10;i++){
|
||||
var a=0;
|
||||
var b=a+a+a*a%a/2-1;
|
||||
b+=a;
|
||||
++b;
|
||||
f(a,b,c,d);
|
||||
if(1===1){
|
||||
var m=function(e,f){
|
||||
return e^f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0 ; i < this.foo(); i++) {
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
function f(a, b, c, d) {
|
||||
for (var i = 0; i < 10; i++) {
|
||||
var a = 0;
|
||||
var b = a + a + a * a % a / 2 - 1;
|
||||
b += a;
|
||||
++b;
|
||||
f(a, b, c, d);
|
||||
if (1 === 1) {
|
||||
var m = function(e, f) {
|
||||
return e ^ f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0 ; i < this.foo(); i++) {
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
with (foo.bar)
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
with (bar.blah)
|
||||
{
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
with (foo.bar) {
|
||||
|
||||
}
|
||||
|
||||
with (bar.blah) {
|
||||
}
|
||||
@ -186,6 +186,7 @@ namespace ts {
|
||||
const content = `{
|
||||
"compilerOptions": {
|
||||
"allowJs": true
|
||||
// Some comments
|
||||
"outDir": "bin"
|
||||
}
|
||||
"files": ["file1.ts"]
|
||||
|
||||
@ -199,17 +199,13 @@ namespace ts {
|
||||
watchDirectory(directoryName: string, callback: DirectoryWatcherCallback, recursive: boolean): DirectoryWatcher {
|
||||
const path = this.toPath(directoryName);
|
||||
const callbacks = this.watchedDirectories[path] || (this.watchedDirectories[path] = []);
|
||||
callbacks.push({ cb: callback, recursive });
|
||||
const cbWithRecursive = { cb: callback, recursive };
|
||||
callbacks.push(cbWithRecursive);
|
||||
return {
|
||||
referenceCount: 0,
|
||||
directoryName,
|
||||
close: () => {
|
||||
for (let i = 0; i < callbacks.length; i++) {
|
||||
if (callbacks[i].cb === callback) {
|
||||
callbacks.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
unorderedRemoveItem(callbacks, cbWithRecursive);
|
||||
if (!callbacks.length) {
|
||||
delete this.watchedDirectories[path];
|
||||
}
|
||||
@ -243,8 +239,7 @@ namespace ts {
|
||||
callbacks.push(callback);
|
||||
return {
|
||||
close: () => {
|
||||
const i = callbacks.indexOf(callback);
|
||||
callbacks.splice(i, 1);
|
||||
unorderedRemoveItem(callbacks, callback);
|
||||
if (!callbacks.length) {
|
||||
delete this.watchedFiles[path];
|
||||
}
|
||||
@ -259,7 +254,7 @@ namespace ts {
|
||||
};
|
||||
readonly clearTimeout = (timeoutId: any): void => {
|
||||
if (typeof timeoutId === "number") {
|
||||
this.callbackQueue.splice(timeoutId, 1);
|
||||
orderedRemoveItemAt(this.callbackQueue, timeoutId);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -275,7 +275,7 @@ namespace ts.server {
|
||||
removeRoot(info: ScriptInfo) {
|
||||
if (this.filenameToScript.contains(info.path)) {
|
||||
this.filenameToScript.remove(info.path);
|
||||
this.roots = copyListRemovingItem(info, this.roots);
|
||||
unorderedRemoveItem(this.roots, info);
|
||||
this.resolvedModuleNames.remove(info.path);
|
||||
this.resolvedTypeReferenceDirectives.remove(info.path);
|
||||
}
|
||||
@ -585,16 +585,6 @@ namespace ts.server {
|
||||
project?: Project;
|
||||
}
|
||||
|
||||
function copyListRemovingItem<T>(item: T, list: T[]) {
|
||||
const copiedList: T[] = [];
|
||||
for (let i = 0, len = list.length; i < len; i++) {
|
||||
if (list[i] != item) {
|
||||
copiedList.push(list[i]);
|
||||
}
|
||||
}
|
||||
return copiedList;
|
||||
}
|
||||
|
||||
/**
|
||||
* This helper funciton processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project.
|
||||
*/
|
||||
@ -880,7 +870,7 @@ namespace ts.server {
|
||||
project.directoryWatcher.close();
|
||||
forEachProperty(project.directoriesWatchedForWildcards, watcher => { watcher.close(); });
|
||||
delete project.directoriesWatchedForWildcards;
|
||||
this.configuredProjects = copyListRemovingItem(project, this.configuredProjects);
|
||||
unorderedRemoveItem(this.configuredProjects, project);
|
||||
}
|
||||
else {
|
||||
for (const directory of project.directoriesWatchedForTsconfig) {
|
||||
@ -892,7 +882,7 @@ namespace ts.server {
|
||||
delete project.projectService.directoryWatchersForTsconfig[directory];
|
||||
}
|
||||
}
|
||||
this.inferredProjects = copyListRemovingItem(project, this.inferredProjects);
|
||||
unorderedRemoveItem(this.inferredProjects, project);
|
||||
}
|
||||
|
||||
const fileNames = project.getFileNames();
|
||||
@ -1017,7 +1007,7 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced);
|
||||
unorderedRemoveItem(this.openFilesReferenced, info);
|
||||
}
|
||||
info.close();
|
||||
}
|
||||
@ -1524,13 +1514,13 @@ namespace ts.server {
|
||||
// openFileRoots or openFileReferenced.
|
||||
if (info.isOpen) {
|
||||
if (this.openFileRoots.indexOf(info) >= 0) {
|
||||
this.openFileRoots = copyListRemovingItem(info, this.openFileRoots);
|
||||
unorderedRemoveItem(this.openFileRoots, info);
|
||||
if (info.defaultProject && !info.defaultProject.isConfiguredProject()) {
|
||||
this.removeProject(info.defaultProject);
|
||||
}
|
||||
}
|
||||
if (this.openFilesReferenced.indexOf(info) >= 0) {
|
||||
this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced);
|
||||
unorderedRemoveItem(this.openFilesReferenced, info);
|
||||
}
|
||||
this.openFileRootsConfigured.push(info);
|
||||
info.defaultProject = project;
|
||||
|
||||
@ -204,7 +204,7 @@ namespace ts.server {
|
||||
// average async stat takes about 30 microseconds
|
||||
// set chunk size to do 30 files in < 1 millisecond
|
||||
function createPollingWatchedFileSet(interval = 2500, chunkSize = 30) {
|
||||
let watchedFiles: WatchedFile[] = [];
|
||||
const watchedFiles: WatchedFile[] = [];
|
||||
let nextFileToCheck = 0;
|
||||
let watchTimer: any;
|
||||
|
||||
@ -267,7 +267,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
function removeFile(file: WatchedFile) {
|
||||
watchedFiles = copyListRemovingItem(file, watchedFiles);
|
||||
unorderedRemoveItem(watchedFiles, file);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@ -466,6 +466,7 @@ namespace ts.NavigationBar {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return hasSomeImportantChild(item);
|
||||
|
||||
case SyntaxKind.ArrowFunction:
|
||||
|
||||
@ -285,11 +285,14 @@ namespace ts {
|
||||
let pos = this.pos;
|
||||
const useJSDocScanner = this.kind >= SyntaxKind.FirstJSDocTagNode && this.kind <= SyntaxKind.LastJSDocTagNode;
|
||||
const processNode = (node: Node) => {
|
||||
if (pos < node.pos) {
|
||||
const isJSDocTagNode = isJSDocTag(node);
|
||||
if (!isJSDocTagNode && pos < node.pos) {
|
||||
pos = this.addSyntheticNodes(children, pos, node.pos, useJSDocScanner);
|
||||
}
|
||||
children.push(node);
|
||||
pos = node.end;
|
||||
if (!isJSDocTagNode) {
|
||||
pos = node.end;
|
||||
}
|
||||
};
|
||||
const processNodes = (nodes: NodeArray<Node>) => {
|
||||
if (pos < nodes.pos) {
|
||||
@ -1379,8 +1382,12 @@ namespace ts {
|
||||
containerName: string;
|
||||
}
|
||||
|
||||
export interface ReferencedSymbolDefinitionInfo extends DefinitionInfo {
|
||||
displayParts: SymbolDisplayPart[];
|
||||
}
|
||||
|
||||
export interface ReferencedSymbol {
|
||||
definition: DefinitionInfo;
|
||||
definition: ReferencedSymbolDefinitionInfo;
|
||||
references: ReferenceEntry[];
|
||||
}
|
||||
|
||||
@ -2794,18 +2801,42 @@ namespace ts {
|
||||
return node && node.parent && node.parent.kind === SyntaxKind.PropertyAccessExpression && (<PropertyAccessExpression>node.parent).name === node;
|
||||
}
|
||||
|
||||
function climbPastPropertyAccess(node: Node) {
|
||||
return isRightSideOfPropertyAccess(node) ? node.parent : node;
|
||||
}
|
||||
|
||||
/** Get `C` given `N` if `N` is in the position `class C extends N` or `class C extends foo.N` where `N` is an identifier. */
|
||||
function tryGetClassByExtendingIdentifier(node: Node): ClassLikeDeclaration | undefined {
|
||||
return tryGetClassExtendingExpressionWithTypeArguments(climbPastPropertyAccess(node).parent);
|
||||
}
|
||||
|
||||
function isCallExpressionTarget(node: Node): boolean {
|
||||
if (isRightSideOfPropertyAccess(node)) {
|
||||
node = node.parent;
|
||||
}
|
||||
return node && node.parent && node.parent.kind === SyntaxKind.CallExpression && (<CallExpression>node.parent).expression === node;
|
||||
return isCallOrNewExpressionTarget(node, SyntaxKind.CallExpression);
|
||||
}
|
||||
|
||||
function isNewExpressionTarget(node: Node): boolean {
|
||||
if (isRightSideOfPropertyAccess(node)) {
|
||||
node = node.parent;
|
||||
}
|
||||
return node && node.parent && node.parent.kind === SyntaxKind.NewExpression && (<CallExpression>node.parent).expression === node;
|
||||
return isCallOrNewExpressionTarget(node, SyntaxKind.NewExpression);
|
||||
}
|
||||
|
||||
function isCallOrNewExpressionTarget(node: Node, kind: SyntaxKind) {
|
||||
const target = climbPastPropertyAccess(node);
|
||||
return target && target.parent && target.parent.kind === kind && (<CallExpression>target.parent).expression === target;
|
||||
}
|
||||
|
||||
function climbPastManyPropertyAccesses(node: Node): Node {
|
||||
return isRightSideOfPropertyAccess(node) ? climbPastManyPropertyAccesses(node.parent) : node;
|
||||
}
|
||||
|
||||
/** Returns a CallLikeExpression where `node` is the target being invoked. */
|
||||
function getAncestorCallLikeExpression(node: Node): CallLikeExpression | undefined {
|
||||
const target = climbPastManyPropertyAccesses(node);
|
||||
const callLike = target.parent;
|
||||
return callLike && isCallLikeExpression(callLike) && getInvokedExpression(callLike) === target && callLike;
|
||||
}
|
||||
|
||||
function tryGetSignatureDeclaration(typeChecker: TypeChecker, node: Node): SignatureDeclaration | undefined {
|
||||
const callLike = getAncestorCallLikeExpression(node);
|
||||
return callLike && typeChecker.getResolvedSignature(callLike).declaration;
|
||||
}
|
||||
|
||||
function isNameOfModuleDeclaration(node: Node) {
|
||||
@ -4611,7 +4642,7 @@ namespace ts {
|
||||
const symbolFlags = symbol.flags;
|
||||
let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location);
|
||||
let hasAddedSymbolInfo: boolean;
|
||||
const isThisExpression: boolean = location.kind === SyntaxKind.ThisKeyword && isExpression(location);
|
||||
const isThisExpression = location.kind === SyntaxKind.ThisKeyword && isExpression(location);
|
||||
let type: Type;
|
||||
|
||||
// Class at constructor site need to be shown as constructor apart from property,method, vars
|
||||
@ -5074,14 +5105,25 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function getSymbolInfo(typeChecker: TypeChecker, symbol: Symbol, node: Node) {
|
||||
return {
|
||||
symbolName: typeChecker.symbolToString(symbol), // Do not get scoped name, just the name of the symbol
|
||||
symbolKind: getSymbolKind(symbol, node),
|
||||
containerName: symbol.parent ? typeChecker.symbolToString(symbol.parent, node) : ""
|
||||
};
|
||||
}
|
||||
|
||||
function createDefinitionFromSignatureDeclaration(decl: SignatureDeclaration): DefinitionInfo {
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const { symbolName, symbolKind, containerName } = getSymbolInfo(typeChecker, decl.symbol, decl);
|
||||
return createDefinitionInfo(decl, symbolKind, symbolName, containerName);
|
||||
}
|
||||
|
||||
function getDefinitionFromSymbol(symbol: Symbol, node: Node): DefinitionInfo[] {
|
||||
const typeChecker = program.getTypeChecker();
|
||||
const result: DefinitionInfo[] = [];
|
||||
const declarations = symbol.getDeclarations();
|
||||
const symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol
|
||||
const symbolKind = getSymbolKind(symbol, node);
|
||||
const containerSymbol = symbol.parent;
|
||||
const containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : "";
|
||||
const { symbolName, symbolKind, containerName } = getSymbolInfo(typeChecker, symbol, node);
|
||||
|
||||
if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) &&
|
||||
!tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) {
|
||||
@ -5207,6 +5249,12 @@ namespace ts {
|
||||
}
|
||||
|
||||
const typeChecker = program.getTypeChecker();
|
||||
|
||||
const calledDeclaration = tryGetSignatureDeclaration(typeChecker, node);
|
||||
if (calledDeclaration) {
|
||||
return [createDefinitionFromSignatureDeclaration(calledDeclaration)];
|
||||
}
|
||||
|
||||
let symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
// Could not find a symbol e.g. node is string or number keyword,
|
||||
@ -6014,6 +6062,7 @@ namespace ts {
|
||||
case SyntaxKind.Identifier:
|
||||
case SyntaxKind.ThisKeyword:
|
||||
// case SyntaxKind.SuperKeyword: TODO:GH#9268
|
||||
case SyntaxKind.ConstructorKeyword:
|
||||
case SyntaxKind.StringLiteral:
|
||||
return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments);
|
||||
}
|
||||
@ -6058,6 +6107,8 @@ namespace ts {
|
||||
return getReferencesForSuperKeyword(node);
|
||||
}
|
||||
|
||||
// `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword,
|
||||
// so we have to specify that we want the constructor symbol.
|
||||
const symbol = typeChecker.getSymbolAtLocation(node);
|
||||
|
||||
if (!symbol && node.kind === SyntaxKind.StringLiteral) {
|
||||
@ -6113,7 +6164,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;
|
||||
@ -6127,11 +6178,12 @@ 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
|
||||
};
|
||||
}
|
||||
|
||||
function getAliasSymbolForPropertyNameSymbol(symbol: Symbol, location: Node): Symbol {
|
||||
function getAliasSymbolForPropertyNameSymbol(symbol: Symbol, location: Node): Symbol | undefined {
|
||||
if (symbol.flags & SymbolFlags.Alias) {
|
||||
// Default import get alias
|
||||
const defaultImport = getDeclarationOfKind(symbol, SyntaxKind.ImportClause);
|
||||
@ -6157,6 +6209,10 @@ namespace ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function followAliasIfNecessary(symbol: Symbol, location: Node): Symbol {
|
||||
return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol;
|
||||
}
|
||||
|
||||
function getPropertySymbolOfDestructuringAssignment(location: Node) {
|
||||
return isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) &&
|
||||
typeChecker.getPropertySymbolOfDestructuringAssignment(<Identifier>location);
|
||||
@ -6322,13 +6378,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 }];
|
||||
@ -6420,7 +6477,8 @@ namespace ts {
|
||||
if (referenceSymbol) {
|
||||
const referenceSymbolDeclaration = referenceSymbol.valueDeclaration;
|
||||
const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
|
||||
const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation);
|
||||
const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation,
|
||||
/*searchLocationIsConstructor*/ searchLocation.kind === SyntaxKind.ConstructorKeyword);
|
||||
|
||||
if (relatedSymbol) {
|
||||
const referencedSymbol = getReferencedSymbol(relatedSymbol);
|
||||
@ -6436,12 +6494,94 @@ namespace ts {
|
||||
const referencedSymbol = getReferencedSymbol(shorthandValueSymbol);
|
||||
referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name));
|
||||
}
|
||||
else if (searchLocation.kind === SyntaxKind.ConstructorKeyword) {
|
||||
findAdditionalConstructorReferences(referenceSymbol, referenceLocation);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
/** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */
|
||||
function findAdditionalConstructorReferences(referenceSymbol: Symbol, referenceLocation: Node): void {
|
||||
Debug.assert(isClassLike(searchSymbol.valueDeclaration));
|
||||
|
||||
const referenceClass = referenceLocation.parent;
|
||||
if (referenceSymbol === searchSymbol && isClassLike(referenceClass)) {
|
||||
Debug.assert(referenceClass.name === referenceLocation);
|
||||
// This is the class declaration containing the constructor.
|
||||
addReferences(findOwnConstructorCalls(searchSymbol));
|
||||
}
|
||||
else {
|
||||
// If this class appears in `extends C`, then the extending class' "super" calls are references.
|
||||
const classExtending = tryGetClassByExtendingIdentifier(referenceLocation);
|
||||
if (classExtending && isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) {
|
||||
addReferences(superConstructorAccesses(classExtending));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addReferences(references: Node[]): void {
|
||||
if (references.length) {
|
||||
const referencedSymbol = getReferencedSymbol(searchSymbol);
|
||||
addRange(referencedSymbol.references, map(references, getReferenceEntryFromNode));
|
||||
}
|
||||
}
|
||||
|
||||
/** `classSymbol` is the class where the constructor was defined.
|
||||
* Reference the constructor and all calls to `new this()`.
|
||||
*/
|
||||
function findOwnConstructorCalls(classSymbol: Symbol): Node[] {
|
||||
const result: Node[] = [];
|
||||
|
||||
for (const decl of classSymbol.members["__constructor"].declarations) {
|
||||
Debug.assert(decl.kind === SyntaxKind.Constructor);
|
||||
const ctrKeyword = decl.getChildAt(0);
|
||||
Debug.assert(ctrKeyword.kind === SyntaxKind.ConstructorKeyword);
|
||||
result.push(ctrKeyword);
|
||||
}
|
||||
|
||||
forEachProperty(classSymbol.exports, member => {
|
||||
const decl = member.valueDeclaration;
|
||||
if (decl && decl.kind === SyntaxKind.MethodDeclaration) {
|
||||
const body = (<MethodDeclaration>decl).body;
|
||||
if (body) {
|
||||
forEachDescendantOfKind(body, SyntaxKind.ThisKeyword, thisKeyword => {
|
||||
if (isNewExpressionTarget(thisKeyword)) {
|
||||
result.push(thisKeyword);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Find references to `super` in the constructor of an extending class. */
|
||||
function superConstructorAccesses(cls: ClassLikeDeclaration): Node[] {
|
||||
const symbol = cls.symbol;
|
||||
const ctr = symbol.members["__constructor"];
|
||||
if (!ctr) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const result: Node[] = [];
|
||||
for (const decl of ctr.declarations) {
|
||||
Debug.assert(decl.kind === SyntaxKind.Constructor);
|
||||
const body = (<ConstructorDeclaration>decl).body;
|
||||
if (body) {
|
||||
forEachDescendantOfKind(body, SyntaxKind.SuperKeyword, node => {
|
||||
if (isCallExpressionTarget(node)) {
|
||||
result.push(node);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
function getReferencedSymbol(symbol: Symbol): ReferencedSymbol {
|
||||
const symbolId = getSymbolId(symbol);
|
||||
let index = symbolToIndex[symbolId];
|
||||
@ -6568,6 +6708,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: "",
|
||||
@ -6575,7 +6720,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
|
||||
}];
|
||||
@ -6646,7 +6792,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
|
||||
}];
|
||||
@ -6815,16 +6962,17 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node): Symbol {
|
||||
if (searchSymbols.indexOf(referenceSymbol) >= 0) {
|
||||
return referenceSymbol;
|
||||
function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, searchLocationIsConstructor: boolean): Symbol | undefined {
|
||||
if (contains(searchSymbols, referenceSymbol)) {
|
||||
// If we are searching for constructor uses, they must be 'new' expressions.
|
||||
return (!searchLocationIsConstructor || isNewExpressionTarget(referenceLocation)) && referenceSymbol;
|
||||
}
|
||||
|
||||
// If the reference symbol is an alias, check if what it is aliasing is one of the search
|
||||
// symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness.
|
||||
const aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation);
|
||||
if (aliasSymbol) {
|
||||
return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation);
|
||||
return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor);
|
||||
}
|
||||
|
||||
// If the reference location is in an object literal, try to get the contextual type for the
|
||||
@ -8348,6 +8496,15 @@ namespace ts {
|
||||
};
|
||||
}
|
||||
|
||||
function forEachDescendantOfKind(node: Node, kind: SyntaxKind, action: (node: Node) => void) {
|
||||
forEachChild(node, child => {
|
||||
if (child.kind === kind) {
|
||||
action(child);
|
||||
}
|
||||
forEachDescendantOfKind(child, kind, action);
|
||||
});
|
||||
}
|
||||
|
||||
/* @internal */
|
||||
export function getNameTable(sourceFile: SourceFile): Map<number> {
|
||||
if (!sourceFile.nameTable) {
|
||||
|
||||
@ -930,7 +930,8 @@ namespace ts {
|
||||
const options: TranspileOptions = {
|
||||
fileName: "config.js",
|
||||
compilerOptions: {
|
||||
target: ScriptTarget.ES6
|
||||
target: ScriptTarget.ES6,
|
||||
removeComments: true
|
||||
},
|
||||
reportDiagnostics: true
|
||||
};
|
||||
|
||||
@ -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 {
|
||||
|
||||
}
|
||||
|
||||
30
tests/baselines/reference/constructableDecoratorOnClass01.js
Normal file
30
tests/baselines/reference/constructableDecoratorOnClass01.js
Normal file
@ -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
|
||||
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ export declare class ConstructorWithPrivateParameterProperty {
|
||||
constructor(x: string);
|
||||
}
|
||||
export declare class ConstructorWithOptionalParameterProperty {
|
||||
x?: string;
|
||||
x: string;
|
||||
constructor(x?: string);
|
||||
}
|
||||
export declare class ConstructorWithParameterInitializer {
|
||||
@ -281,7 +281,7 @@ declare class GlobalConstructorWithPrivateParameterProperty {
|
||||
constructor(x: string);
|
||||
}
|
||||
declare class GlobalConstructorWithOptionalParameterProperty {
|
||||
x?: string;
|
||||
x: string;
|
||||
constructor(x?: string);
|
||||
}
|
||||
declare class GlobalConstructorWithParameterInitializer {
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
tests/cases/compiler/errorForConflictingExportEqualsValue.ts(2,1): error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||
|
||||
|
||||
==== tests/cases/compiler/errorForConflictingExportEqualsValue.ts (1 errors) ====
|
||||
export var x;
|
||||
export = {};
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS2309: An export assignment cannot be used in a module with other exported elements.
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
//// [errorForConflictingExportEqualsValue.ts]
|
||||
export var x;
|
||||
export = {};
|
||||
|
||||
|
||||
//// [errorForConflictingExportEqualsValue.js]
|
||||
"use strict";
|
||||
module.exports = {};
|
||||
@ -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,26 @@
|
||||
/index.ts(4,5): error TS2339: Property 'y' does not exist on type 'typeof "shortid"'.
|
||||
|
||||
|
||||
==== /index.ts (1 errors) ====
|
||||
/// <reference path="/typings/index.d.ts" />
|
||||
import * as foo from "shortid";
|
||||
foo.x // found in index.d.ts
|
||||
foo.y // ignored from shortid/index.js
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'typeof "shortid"'.
|
||||
|
||||
|
||||
==== /node_modules/shortid/node_modules/z/index.js (0 errors) ====
|
||||
// z will not be found because maxNodeModulesJsDepth: 0
|
||||
module.exports = { z: 'no' };
|
||||
|
||||
==== /node_modules/shortid/index.js (0 errors) ====
|
||||
var z = require('z');
|
||||
var y = { y: 'foo' };
|
||||
module.exports = y;
|
||||
|
||||
==== /typings/index.d.ts (0 errors) ====
|
||||
declare module "shortid" {
|
||||
export var x: number;
|
||||
}
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
[
|
||||
"======== Resolving module 'shortid' from '/index.ts'. ========",
|
||||
"Explicitly specified module resolution kind: 'NodeJs'.",
|
||||
"Loading module 'shortid' from 'node_modules' folder.",
|
||||
"File '/node_modules/shortid.ts' does not exist.",
|
||||
"File '/node_modules/shortid.tsx' does not exist.",
|
||||
"File '/node_modules/shortid.d.ts' does not exist.",
|
||||
"File '/node_modules/shortid.js' does not exist.",
|
||||
"File '/node_modules/shortid.jsx' does not exist.",
|
||||
"File '/node_modules/shortid/package.json' does not exist.",
|
||||
"File '/node_modules/shortid/index.ts' does not exist.",
|
||||
"File '/node_modules/shortid/index.tsx' does not exist.",
|
||||
"File '/node_modules/shortid/index.d.ts' does not exist.",
|
||||
"File '/node_modules/shortid/index.js' exist - use it as a name resolution result.",
|
||||
"File '/node_modules/@types/shortid.ts' does not exist.",
|
||||
"File '/node_modules/@types/shortid.tsx' does not exist.",
|
||||
"File '/node_modules/@types/shortid.d.ts' does not exist.",
|
||||
"File '/node_modules/@types/shortid.js' does not exist.",
|
||||
"File '/node_modules/@types/shortid.jsx' does not exist.",
|
||||
"File '/node_modules/@types/shortid/package.json' does not exist.",
|
||||
"File '/node_modules/@types/shortid/index.ts' does not exist.",
|
||||
"File '/node_modules/@types/shortid/index.tsx' does not exist.",
|
||||
"File '/node_modules/@types/shortid/index.d.ts' does not exist.",
|
||||
"File '/node_modules/@types/shortid/index.js' does not exist.",
|
||||
"File '/node_modules/@types/shortid/index.jsx' does not exist.",
|
||||
"Resolving real path for '/node_modules/shortid/index.js', result '/node_modules/shortid/index.js'",
|
||||
"======== Module name 'shortid' was successfully resolved to '/node_modules/shortid/index.js'. ========"
|
||||
]
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
44
tests/baselines/reference/noImplicitAnyMissingGetAccessor.js
Normal file
44
tests/baselines/reference/noImplicitAnyMissingGetAccessor.js
Normal file
@ -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 "";
|
||||
}
|
||||
}
|
||||
43
tests/baselines/reference/noImplicitAnyMissingSetAccessor.js
Normal file
43
tests/baselines/reference/noImplicitAnyMissingSetAccessor.js
Normal file
@ -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));
|
||||
@ -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
|
||||
|
||||
@ -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'.
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -126,7 +126,7 @@ interface Foo {
|
||||
}
|
||||
declare function test1(x: Foo): void;
|
||||
declare class Bar {
|
||||
d?: number;
|
||||
d: number;
|
||||
e: number;
|
||||
a: number;
|
||||
b?: number;
|
||||
|
||||
10
tests/baselines/reference/parseObjectLiteralsWithoutTypes.js
Normal file
10
tests/baselines/reference/parseObjectLiteralsWithoutTypes.js
Normal file
@ -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
|
||||
|
||||
23
tests/baselines/reference/umdGlobalConflict.js
Normal file
23
tests/baselines/reference/umdGlobalConflict.js
Normal file
@ -0,0 +1,23 @@
|
||||
//// [tests/cases/compiler/umdGlobalConflict.ts] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
export as namespace Alpha;
|
||||
export var x: string;
|
||||
|
||||
//// [index.d.ts]
|
||||
export as namespace Alpha;
|
||||
export var y: number;
|
||||
|
||||
//// [consumer.ts]
|
||||
import * as v1 from './v1';
|
||||
import * as v2 from './v2';
|
||||
|
||||
//// [global.ts]
|
||||
// Should be OK, first in wins
|
||||
const p: string = Alpha.x;
|
||||
|
||||
//// [consumer.js]
|
||||
"use strict";
|
||||
//// [global.js]
|
||||
// Should be OK, first in wins
|
||||
var p = Alpha.x;
|
||||
29
tests/baselines/reference/umdGlobalConflict.symbols
Normal file
29
tests/baselines/reference/umdGlobalConflict.symbols
Normal file
@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/v1/index.d.ts ===
|
||||
export as namespace Alpha;
|
||||
>Alpha : Symbol(Alpha, Decl(index.d.ts, 0, 0))
|
||||
|
||||
export var x: string;
|
||||
>x : Symbol(x, Decl(index.d.ts, 1, 10))
|
||||
|
||||
=== tests/cases/compiler/v2/index.d.ts ===
|
||||
export as namespace Alpha;
|
||||
>Alpha : Symbol(Alpha, Decl(index.d.ts, 0, 0))
|
||||
|
||||
export var y: number;
|
||||
>y : Symbol(y, Decl(index.d.ts, 1, 10))
|
||||
|
||||
=== tests/cases/compiler/consumer.ts ===
|
||||
import * as v1 from './v1';
|
||||
>v1 : Symbol(v1, Decl(consumer.ts, 0, 6))
|
||||
|
||||
import * as v2 from './v2';
|
||||
>v2 : Symbol(v2, Decl(consumer.ts, 1, 6))
|
||||
|
||||
=== tests/cases/compiler/global.ts ===
|
||||
// Should be OK, first in wins
|
||||
const p: string = Alpha.x;
|
||||
>p : Symbol(p, Decl(global.ts, 1, 5))
|
||||
>Alpha.x : Symbol(Alpha.x, Decl(index.d.ts, 1, 10))
|
||||
>Alpha : Symbol(Alpha, Decl(index.d.ts, 0, 0))
|
||||
>x : Symbol(Alpha.x, Decl(index.d.ts, 1, 10))
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user