Merge branch 'master' into remove-jake

This commit is contained in:
Wesley Wigham 2016-06-14 14:52:02 -07:00
commit 2634a6713e
No known key found for this signature in database
GPG key ID: D59F87F60C5400C9
155 changed files with 1804 additions and 584 deletions

View file

@ -91,10 +91,10 @@ These two files represent the DOM typings and are auto-generated. To make any mo
## Running the Tests
To run all tests, invoke the `runtests` target using jake:
To run all tests, invoke the `runtests-parallel` target using jake:
```Shell
jake runtests
jake runtests-parallel
```
This run will all tests; to run only a specific subset of tests, use:

View file

@ -193,7 +193,6 @@ function runTests(taskConfigsFolder, run, options, cb) {
counter--;
if (counter <= 0) {
var failed = 0;
var reporter = new Base(),
stats = reporter.stats,
failures = reporter.failures;
@ -224,8 +223,8 @@ function runTests(taskConfigsFolder, run, options, cb) {
reporter.epilogue();
}
if (failed) {
return cb(new Error("Test failures reported: " + failed));
if (stats.failures) {
return cb(new Error("Test failures reported: " + stats.failures));
}
else {
return cb();

View file

@ -610,10 +610,11 @@ namespace ts {
case SyntaxKind.ExclamationEqualsToken:
case SyntaxKind.EqualsEqualsEqualsToken:
case SyntaxKind.ExclamationEqualsEqualsToken:
if (isNarrowingExpression(expr.left) && (expr.right.kind === SyntaxKind.NullKeyword || expr.right.kind === SyntaxKind.Identifier)) {
if ((isNarrowingExpression(expr.left) && (expr.right.kind === SyntaxKind.NullKeyword || expr.right.kind === SyntaxKind.Identifier)) ||
(isNarrowingExpression(expr.right) && (expr.left.kind === SyntaxKind.NullKeyword || expr.left.kind === SyntaxKind.Identifier))) {
return true;
}
if (expr.left.kind === SyntaxKind.TypeOfExpression && isNarrowingExpression((<TypeOfExpression>expr.left).expression) && expr.right.kind === SyntaxKind.StringLiteral) {
if (isTypeOfNarrowingBinaryExpression(expr)) {
return true;
}
return false;
@ -625,6 +626,20 @@ namespace ts {
return false;
}
function isTypeOfNarrowingBinaryExpression(expr: BinaryExpression) {
let typeOf: Expression;
if (expr.left.kind === SyntaxKind.StringLiteral) {
typeOf = expr.right;
}
else if (expr.right.kind === SyntaxKind.StringLiteral) {
typeOf = expr.left;
}
else {
typeOf = undefined;
}
return typeOf && typeOf.kind === SyntaxKind.TypeOfExpression && isNarrowingExpression((<TypeOfExpression>typeOf).expression);
}
function createBranchLabel(): FlowLabel {
return {
flags: FlowFlags.BranchLabel,
@ -1946,7 +1961,7 @@ namespace ts {
classPrototype.parent = leftSideOfAssignment;
const funcSymbol = container.locals[constructorFunction.text];
if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function)) {
if (!funcSymbol || !(funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) {
return;
}

View file

@ -7895,10 +7895,11 @@ namespace ts {
case SyntaxKind.ExclamationEqualsToken:
case SyntaxKind.EqualsEqualsEqualsToken:
case SyntaxKind.ExclamationEqualsEqualsToken:
if (isNullOrUndefinedLiteral(expr.right)) {
if (isNullOrUndefinedLiteral(expr.left) || isNullOrUndefinedLiteral(expr.right)) {
return narrowTypeByNullCheck(type, expr, assumeTrue);
}
if (expr.left.kind === SyntaxKind.TypeOfExpression && expr.right.kind === SyntaxKind.StringLiteral) {
if (expr.left.kind === SyntaxKind.TypeOfExpression && expr.right.kind === SyntaxKind.StringLiteral ||
expr.left.kind === SyntaxKind.StringLiteral && expr.right.kind === SyntaxKind.TypeOfExpression) {
return narrowTypeByTypeof(type, expr, assumeTrue);
}
break;
@ -7911,18 +7912,20 @@ namespace ts {
}
function narrowTypeByNullCheck(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type {
// We have '==', '!=', '===', or '!==' operator with 'null' or 'undefined' on the right
// We have '==', '!=', '===', or '!==' operator with 'null' or 'undefined' on one side
const operator = expr.operatorToken.kind;
const nullLike = isNullOrUndefinedLiteral(expr.left) ? expr.left : expr.right;
const narrowed = isNullOrUndefinedLiteral(expr.left) ? expr.right : expr.left;
if (operator === SyntaxKind.ExclamationEqualsToken || operator === SyntaxKind.ExclamationEqualsEqualsToken) {
assumeTrue = !assumeTrue;
}
if (!strictNullChecks || !isMatchingReference(reference, getReferenceFromExpression(expr.left))) {
if (!strictNullChecks || !isMatchingReference(reference, getReferenceFromExpression(narrowed))) {
return type;
}
const doubleEquals = operator === SyntaxKind.EqualsEqualsToken || operator === SyntaxKind.ExclamationEqualsToken;
const facts = doubleEquals ?
assumeTrue ? TypeFacts.EQUndefinedOrNull : TypeFacts.NEUndefinedOrNull :
expr.right.kind === SyntaxKind.NullKeyword ?
nullLike.kind === SyntaxKind.NullKeyword ?
assumeTrue ? TypeFacts.EQNull : TypeFacts.NENull :
assumeTrue ? TypeFacts.EQUndefined : TypeFacts.NEUndefined;
return getTypeWithFacts(type, facts);
@ -7931,12 +7934,12 @@ namespace ts {
function narrowTypeByTypeof(type: Type, expr: BinaryExpression, assumeTrue: boolean): Type {
// We have '==', '!=', '====', or !==' operator with 'typeof xxx' on the left
// and string literal on the right
const left = getReferenceFromExpression((<TypeOfExpression>expr.left).expression);
const right = <LiteralExpression>expr.right;
if (!isMatchingReference(reference, left)) {
const narrowed = getReferenceFromExpression((<TypeOfExpression>(expr.left.kind === SyntaxKind.TypeOfExpression ? expr.left : expr.right)).expression);
const literal = <LiteralExpression>(expr.right.kind === SyntaxKind.StringLiteral ? expr.right : expr.left);
if (!isMatchingReference(reference, narrowed)) {
// For a reference of the form 'x.y', a 'typeof x === ...' type guard resets the
// narrowed type of 'y' to its declared type.
if (containsMatchingReference(reference, left)) {
if (containsMatchingReference(reference, narrowed)) {
return declaredType;
}
return type;
@ -7949,14 +7952,14 @@ namespace ts {
// We narrow a non-union type to an exact primitive type if the non-union type
// is a supertype of that primtive type. For example, type 'any' can be narrowed
// to one of the primitive types.
const targetType = getProperty(typeofTypesByName, right.text);
const targetType = getProperty(typeofTypesByName, literal.text);
if (targetType && isTypeSubtypeOf(targetType, type)) {
return targetType;
}
}
const facts = assumeTrue ?
getProperty(typeofEQFacts, right.text) || TypeFacts.TypeofEQHostObject :
getProperty(typeofNEFacts, right.text) || TypeFacts.TypeofNEHostObject;
getProperty(typeofEQFacts, literal.text) || TypeFacts.TypeofEQHostObject :
getProperty(typeofNEFacts, literal.text) || TypeFacts.TypeofNEHostObject;
return getTypeWithFacts(type, facts);
}
@ -11492,8 +11495,12 @@ namespace ts {
// When resolved signature is a call signature (and not a construct signature) the result type is any, unless
// the declaring function had members created through 'x.prototype.y = expr' or 'this.y = expr' psuedodeclarations
// in a JS file
const funcSymbol = checkExpression(node.expression).symbol;
if (funcSymbol && funcSymbol.members && (funcSymbol.flags & SymbolFlags.Function)) {
// Note:JS inferred classes might come from a variable declaration instead of a function declaration.
// In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration.
const funcSymbol = node.expression.kind === SyntaxKind.Identifier ?
getResolvedSymbol(node.expression as Identifier) :
checkExpression(node.expression).symbol;
if (funcSymbol && funcSymbol.members && (funcSymbol.flags & SymbolFlags.Function || isDeclarationOfFunctionExpression(funcSymbol))) {
return getInferredClassType(funcSymbol);
}
else if (compilerOptions.noImplicitAny) {

View file

@ -337,8 +337,13 @@ namespace ts {
}
},
{
name: "typesRoot",
type: "string"
name: "typeRoots",
type: "list",
element: {
name: "typeRoots",
type: "string",
isFilePath: true
}
},
{
name: "types",
@ -488,13 +493,20 @@ namespace ts {
}
/* @internal */
export function parseListTypeOption(opt: CommandLineOptionOfListType, value: string, errors: Diagnostic[]): (string | number)[] {
const values = trimString((value || "")).split(",");
export function parseListTypeOption(opt: CommandLineOptionOfListType, value = "", errors: Diagnostic[]): (string | number)[] | undefined {
value = trimString(value);
if (startsWith(value, "-")) {
return undefined;
}
if (value === "") {
return [];
}
const values = value.split(",");
switch (opt.element.type) {
case "number":
return ts.map(values, parseInt);
return map(values, parseInt);
case "string":
return ts.map(values, v => v || "");
return map(values, v => v || "");
default:
return filter(map(values, v => parseCustomTypeOption(<CommandLineOptionOfCustomType>opt.element, v, errors)), v => !!v);
}
@ -555,8 +567,11 @@ namespace ts {
i++;
break;
case "list":
options[opt.name] = parseListTypeOption(<CommandLineOptionOfListType>opt, args[i], errors);
i++;
const result = parseListTypeOption(<CommandLineOptionOfListType>opt, args[i], errors);
options[opt.name] = result || [];
if (result) {
i++;
}
break;
// If not a primitive, the possible types are specified in what is effectively a map of options.
default:

View file

@ -1931,6 +1931,10 @@
"category": "Error",
"code": 2687
},
"Cannot find type definition file for '{0}'.": {
"category": "Error",
"code": 2688
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
"code": 4000

View file

@ -2150,9 +2150,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
}
// Return true if identifier resolves to an exported member of a namespace
function isNamespaceExportReference(node: Identifier) {
function isExportReference(node: Identifier) {
const container = resolver.getReferencedExportContainer(node);
return container && container.kind !== SyntaxKind.SourceFile;
return !!container;
}
// Return true if identifier resolves to an imported identifier
@ -2185,10 +2185,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
// const foo_1 = require('./foo');
// exports.baz = { foo: foo_1.foo };
//
if (languageVersion < ScriptTarget.ES6 || (modulekind !== ModuleKind.ES6 && isImportedReference(node.name)) || isNamespaceExportReference(node.name) ) {
if (languageVersion < ScriptTarget.ES6 || (modulekind !== ModuleKind.ES6 && isImportedReference(node.name)) || isExportReference(node.name)) {
// Emit identifier as an identifier
write(": ");
emit(node.name);
emitExpressionIdentifier(node.name);
}
if (languageVersion >= ScriptTarget.ES6 && node.objectAssignmentInitializer) {
@ -6133,10 +6133,10 @@ const _super = (function (geti, seti) {
if (parameters[i].dotDotDotToken) {
let parameterType = parameters[i].type;
if (parameterType.kind === SyntaxKind.ArrayType) {
if (parameterType && parameterType.kind === SyntaxKind.ArrayType) {
parameterType = (<ArrayTypeNode>parameterType).elementType;
}
else if (parameterType.kind === SyntaxKind.TypeReference && (<TypeReferenceNode>parameterType).typeArguments && (<TypeReferenceNode>parameterType).typeArguments.length === 1) {
else if (parameterType && parameterType.kind === SyntaxKind.TypeReference && (<TypeReferenceNode>parameterType).typeArguments && (<TypeReferenceNode>parameterType).typeArguments.length === 1) {
parameterType = (<TypeReferenceNode>parameterType).typeArguments[0];
}
else {
@ -6156,9 +6156,15 @@ const _super = (function (geti, seti) {
/** Serializes the return type of function. Used by the __metadata decorator for a method. */
function emitSerializedReturnTypeOfNode(node: Node) {
if (node && isFunctionLike(node) && (<FunctionLikeDeclaration>node).type) {
emitSerializedTypeNode((<FunctionLikeDeclaration>node).type);
return;
if (node && isFunctionLike(node)) {
if ((<FunctionLikeDeclaration>node).type) {
emitSerializedTypeNode((<FunctionLikeDeclaration>node).type);
return;
}
else if (isAsyncFunctionLike(<FunctionLikeDeclaration>node)) {
write("Promise");
return;
}
}
write("void 0");

View file

@ -9,16 +9,11 @@ namespace ts {
/* @internal */ export let ioWriteTime = 0;
/** The version of the TypeScript compiler release */
export const version = "1.9.0";
const emptyArray: any[] = [];
const defaultLibrarySearchPaths = [
"types/",
"node_modules/",
"node_modules/@types/",
];
export const version = "1.9.0";
const defaultTypeRoots = ["node_modules/@types"];
export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string {
while (true) {
@ -183,6 +178,11 @@ namespace ts {
const typeReferenceExtensions = [".d.ts"];
function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) {
return options.typeRoots ||
defaultTypeRoots.map(d => combinePaths(options.configFilePath ? getDirectoryPath(options.configFilePath) : host.getCurrentDirectory(), d));
}
/**
* @param {string | undefined} containingFile - file that contains type reference directive, can be undefined if containing file is unknown.
* This is possible in case if resolution is performed for directives specified via 'types' parameter. In this case initial path for secondary lookups
@ -197,24 +197,22 @@ namespace ts {
traceEnabled
};
// use typesRoot and fallback to directory that contains tsconfig or current directory if typesRoot is not set
const rootDir = options.typesRoot || (options.configFilePath ? getDirectoryPath(options.configFilePath) : (host.getCurrentDirectory && host.getCurrentDirectory()));
const typeRoots = getEffectiveTypeRoots(options, host);
if (traceEnabled) {
if (containingFile === undefined) {
if (rootDir === undefined) {
if (typeRoots === undefined) {
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName);
}
else {
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, rootDir);
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots);
}
}
else {
if (rootDir === undefined) {
if (typeRoots === undefined) {
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile);
}
else {
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, rootDir);
trace(host, Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots);
}
}
}
@ -222,14 +220,13 @@ namespace ts {
const failedLookupLocations: string[] = [];
// Check primary library paths
if (rootDir !== undefined) {
const effectivePrimarySearchPaths = options.typesSearchPaths || defaultLibrarySearchPaths;
for (const searchPath of effectivePrimarySearchPaths) {
const primaryPath = combinePaths(rootDir, searchPath);
if (traceEnabled) {
trace(host, Diagnostics.Resolving_with_primary_search_path_0, primaryPath);
}
const candidate = combinePaths(primaryPath, typeReferenceDirectiveName);
if (typeRoots.length) {
if (traceEnabled) {
trace(host, Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
}
const primarySearchPaths = typeRoots;
for (const typeRoot of primarySearchPaths) {
const candidate = combinePaths(typeRoot, typeReferenceDirectiveName);
const candidateDirectory = getDirectoryPath(candidate);
const resolvedFile = loadNodeModuleFromDirectory(typeReferenceExtensions, candidate, failedLookupLocations,
!directoryProbablyExists(candidateDirectory, host), moduleResolutionState);
@ -256,9 +253,6 @@ namespace ts {
if (containingFile) {
initialLocationForSecondaryLookup = getDirectoryPath(containingFile);
}
else {
initialLocationForSecondaryLookup = rootDir;
}
if (initialLocationForSecondaryLookup !== undefined) {
// check secondary locations
@ -937,19 +931,6 @@ namespace ts {
}
}
function getDefaultTypeDirectiveNames(rootPath: string): string[] {
const localTypes = combinePaths(rootPath, "types");
const npmTypes = combinePaths(rootPath, "node_modules/@types");
let result: string[] = [];
if (sys.directoryExists(localTypes)) {
result = result.concat(sys.getDirectories(localTypes));
}
if (sys.directoryExists(npmTypes)) {
result = result.concat(sys.getDirectories(npmTypes));
}
return result;
}
function getDefaultLibLocation(): string {
return getDirectoryPath(normalizePath(sys.getExecutingFilePath()));
}
@ -958,7 +939,6 @@ namespace ts {
const realpath = sys.realpath && ((path: string) => sys.realpath(path));
return {
getDefaultTypeDirectiveNames,
getSourceFile,
getDefaultLibLocation,
getDefaultLibFileName: options => combinePaths(getDefaultLibLocation(), getDefaultLibFileName(options)),
@ -971,6 +951,7 @@ namespace ts {
readFile: fileName => sys.readFile(fileName),
trace: (s: string) => sys.write(s + newLine),
directoryExists: directoryName => sys.directoryExists(directoryName),
getDirectories: (path: string) => sys.getDirectories(path),
realpath
};
}
@ -1034,21 +1015,35 @@ namespace ts {
return resolutions;
}
export function getDefaultTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[] {
function getInferredTypesRoot(options: CompilerOptions, rootFiles: string[], host: CompilerHost) {
return computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), f => host.getCanonicalFileName(f));
}
/**
* Given a set of options and a set of root files, returns the set of type directive names
* that should be included for this program automatically.
* This list could either come from the config file,
* or from enumerating the types root + initial secondary types lookup location.
* More type directives might appear in the program later as a result of loading actual source files;
* this list is only the set of defaults that are implicitly included.
*/
export function getAutomaticTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[] {
// Use explicit type list from tsconfig.json
if (options.types) {
return options.types;
}
// or load all types from the automatic type import fields
if (host && host.getDefaultTypeDirectiveNames) {
const commonRoot = computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), f => host.getCanonicalFileName(f));
if (commonRoot) {
return host.getDefaultTypeDirectiveNames(commonRoot);
// Walk the primary type lookup locations
let result: string[] = [];
if (host.directoryExists && host.getDirectories) {
const typeRoots = getEffectiveTypeRoots(options, host);
for (const root of typeRoots) {
if (host.directoryExists(root)) {
result = result.concat(host.getDirectories(root));
}
}
}
return undefined;
return result;
}
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program {
@ -1100,11 +1095,13 @@ namespace ts {
if (!tryReuseStructureFromOldProgram()) {
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));
// load type declarations specified via 'types' argument
const typeReferences: string[] = getDefaultTypeDirectiveNames(options, rootNames, host);
// load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders
const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, rootNames, host);
if (typeReferences) {
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, /*containingFile*/ undefined);
const inferredRoot = getInferredTypesRoot(options, rootNames, host);
const containingFilename = combinePaths(inferredRoot, "__inferred type names__.ts");
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
for (let i = 0; i < typeReferences.length; i++) {
processTypeReferenceDirective(typeReferences[i], resolutions[i]);
}
@ -1212,10 +1209,9 @@ namespace ts {
(oldOptions.jsx !== options.jsx) ||
(oldOptions.allowJs !== options.allowJs) ||
(oldOptions.rootDir !== options.rootDir) ||
(oldOptions.typesSearchPaths !== options.typesSearchPaths) ||
(oldOptions.configFilePath !== options.configFilePath) ||
(oldOptions.baseUrl !== options.baseUrl) ||
(oldOptions.typesRoot !== options.typesRoot) ||
!arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) ||
!arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) ||
!mapIsEqualTo(oldOptions.paths, options.paths)) {
return false;
@ -1970,7 +1966,7 @@ namespace ts {
}
}
else {
fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, Diagnostics.Cannot_find_name_0, typeReferenceDirective));
fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, Diagnostics.Cannot_find_type_definition_file_for_0, typeReferenceDirective));
}
if (saveResolution) {

View file

@ -2562,7 +2562,8 @@ namespace ts {
target?: ScriptTarget;
traceResolution?: boolean;
types?: string[];
/* @internal */ typesRoot?: string;
/** Paths used to used to compute primary types search locations */
typeRoots?: string[];
typesSearchPaths?: string[];
/*@internal*/ version?: boolean;
/*@internal*/ watch?: boolean;
@ -2871,6 +2872,7 @@ namespace ts {
getDefaultTypeDirectiveNames?(rootPath: string): string[];
writeFile: WriteFileCallback;
getCurrentDirectory(): string;
getDirectories(path: string): string[];
getCanonicalFileName(fileName: string): string;
useCaseSensitiveFileNames(): boolean;
getNewLine(): string;

View file

@ -830,6 +830,8 @@ namespace ts {
case SyntaxKind.ConstructorType:
return true;
}
return false;
}
export function introducesArgumentsExoticObject(node: Node) {
@ -1262,6 +1264,18 @@ namespace ts {
return charCode === CharacterCodes.singleQuote || charCode === CharacterCodes.doubleQuote;
}
/**
* Returns true if the node is a variable declaration whose initializer is a function expression.
* This function does not test if the node is in a JavaScript file or not.
*/
export function isDeclarationOfFunctionExpression(s: Symbol) {
if (s.valueDeclaration && s.valueDeclaration.kind === SyntaxKind.VariableDeclaration) {
const declaration = s.valueDeclaration as VariableDeclaration;
return declaration.initializer && declaration.initializer.kind === SyntaxKind.FunctionExpression;
}
return false;
}
/// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property
/// assignments we treat as special in the binder
export function getSpecialPropertyAssignmentKind(expression: Node): SpecialPropertyAssignmentKind {

View file

@ -246,8 +246,8 @@ namespace FourSlash {
// Create a new Services Adapter
this.cancellationToken = new TestCancellationToken();
const compilationOptions = convertGlobalOptionsToCompilerOptions(this.testData.globalOptions);
if (compilationOptions.typesRoot) {
compilationOptions.typesRoot = ts.getNormalizedAbsolutePath(compilationOptions.typesRoot, this.basePath);
if (compilationOptions.typeRoots) {
compilationOptions.typeRoots = compilationOptions.typeRoots.map(p => ts.getNormalizedAbsolutePath(p, this.basePath));
}
const languageServiceAdapter = this.getLanguageServiceAdapter(testType, this.cancellationToken, compilationOptions);
@ -717,6 +717,8 @@ namespace FourSlash {
public verifyCompletionEntryDetails(entryName: string, expectedText: string, expectedDocumentation?: string, kind?: string) {
const details = this.getCompletionEntryDetails(entryName);
assert(details, "no completion entry available");
assert.equal(ts.displayPartsToString(details.displayParts), expectedText, this.assertionMessageAtLastKnownMarker("completion entry details text"));
if (expectedDocumentation !== undefined) {
@ -728,7 +730,7 @@ namespace FourSlash {
}
}
public verifyReferencesAtPositionListContains(fileName: string, start: number, end: number, isWriteAccess?: boolean) {
public verifyReferencesAtPositionListContains(fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) {
const references = this.getReferencesAtCaret();
if (!references || references.length === 0) {
@ -741,11 +743,14 @@ namespace FourSlash {
if (typeof isWriteAccess !== "undefined" && reference.isWriteAccess !== isWriteAccess) {
this.raiseError(`verifyReferencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ${reference.isWriteAccess}, expected: ${isWriteAccess}.`);
}
if (typeof isDefinition !== "undefined" && reference.isDefinition !== isDefinition) {
this.raiseError(`verifyReferencesAtPositionListContains failed - item isDefinition value does not match, actual: ${reference.isDefinition}, expected: ${isDefinition}.`);
}
return;
}
}
const missingItem = { fileName: fileName, start: start, end: end, isWriteAccess: isWriteAccess };
const missingItem = { fileName, start, end, isWriteAccess, isDefinition };
this.raiseError(`verifyReferencesAtPositionListContains failed - could not find the item: ${stringify(missingItem)} in the returned list: (${stringify(references)})`);
}
@ -2835,8 +2840,8 @@ namespace FourSlashInterface {
this.state.verifyReferencesCountIs(count, /*localFilesOnly*/ false);
}
public referencesAtPositionContains(range: FourSlash.Range, isWriteAccess?: boolean) {
this.state.verifyReferencesAtPositionListContains(range.fileName, range.start, range.end, isWriteAccess);
public referencesAtPositionContains(range: FourSlash.Range, isWriteAccess?: boolean, isDefinition?: boolean) {
this.state.verifyReferencesAtPositionListContains(range.fileName, range.start, range.end, isWriteAccess, isDefinition);
}
public signatureHelpPresent() {

View file

@ -432,6 +432,7 @@ namespace Harness {
readFile(path: string): string;
writeFile(path: string, contents: string): void;
directoryName(path: string): string;
getDirectories(path: string): string[];
createDirectory(path: string): void;
fileExists(fileName: string): boolean;
directoryExists(path: string): boolean;
@ -477,6 +478,7 @@ namespace Harness {
export const readFile: typeof IO.readFile = path => ts.sys.readFile(path);
export const writeFile: typeof IO.writeFile = (path, content) => ts.sys.writeFile(path, content);
export const directoryName: typeof IO.directoryName = fso.GetParentFolderName;
export const getDirectories: typeof IO.getDirectories = dir => ts.sys.getDirectories(dir);
export const directoryExists: typeof IO.directoryExists = fso.FolderExists;
export const fileExists: typeof IO.fileExists = fso.FileExists;
export const log: typeof IO.log = global.WScript && global.WScript.StdOut.WriteLine;
@ -543,6 +545,7 @@ namespace Harness {
export const args = () => ts.sys.args;
export const getExecutingFilePath = () => ts.sys.getExecutingFilePath();
export const exit = (exitCode: number) => ts.sys.exit(exitCode);
export const getDirectories: typeof IO.getDirectories = path => ts.sys.getDirectories(path);
export const readFile: typeof IO.readFile = path => ts.sys.readFile(path);
export const writeFile: typeof IO.writeFile = (path, content) => ts.sys.writeFile(path, content);
@ -616,6 +619,7 @@ namespace Harness {
export const args = () => <string[]>[];
export const getExecutingFilePath = () => "";
export const exit = (exitCode: number) => { };
export const getDirectories = () => <string[]>[];
export let log = (s: string) => console.log(s);
@ -861,7 +865,7 @@ namespace Harness {
// Local get canonical file name function, that depends on passed in parameter for useCaseSensitiveFileNames
const getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
let realPathMap: ts.FileMap<string>;
const realPathMap: ts.FileMap<string> = ts.createFileMap<string>();
const fileMap: ts.FileMap<() => ts.SourceFile> = ts.createFileMap<() => ts.SourceFile>();
for (const file of inputFiles) {
if (file.content !== undefined) {
@ -870,9 +874,6 @@ namespace Harness {
if (file.fileOptions && file.fileOptions["symlink"]) {
const link = file.fileOptions["symlink"];
const linkPath = ts.toPath(link, currentDirectory, getCanonicalFileName);
if (!realPathMap) {
realPathMap = ts.createFileMap<string>();
}
realPathMap.set(linkPath, fileName);
fileMap.set(path, (): ts.SourceFile => { throw new Error("Symlinks should always be resolved to a realpath first"); });
}
@ -906,20 +907,6 @@ namespace Harness {
return {
getDefaultTypeDirectiveNames: (path: string) => {
const results: string[] = [];
fileMap.forEachValue((key, value) => {
const rx = /node_modules\/@types\/(\w+)/;
const typeNameResult = rx.exec(key);
if (typeNameResult) {
const typeName = typeNameResult[1];
if (results.indexOf(typeName) < 0) {
results.push(typeName);
}
}
});
return results;
},
getCurrentDirectory: () => currentDirectory,
getSourceFile,
getDefaultLibFileName,
@ -937,7 +924,37 @@ namespace Harness {
realpath: realPathMap && ((f: string) => {
const path = ts.toPath(f, currentDirectory, getCanonicalFileName);
return realPathMap.contains(path) ? realPathMap.get(path) : path;
})
}),
directoryExists: dir => {
let path = ts.toPath(dir, currentDirectory, getCanonicalFileName);
// Strip trailing /, which may exist if the path is a drive root
if (path[path.length - 1] === "/") {
path = <ts.Path>path.substr(0, path.length - 1);
}
let exists = false;
fileMap.forEachValue(key => {
if (key.indexOf(path) === 0 && key[path.length] === "/") {
exists = true;
}
});
return exists;
},
getDirectories: d => {
const path = ts.toPath(d, currentDirectory, getCanonicalFileName);
const result: string[] = [];
fileMap.forEachValue((key, value) => {
if (key.indexOf(path) === 0 && key.lastIndexOf("/") > path.length) {
let dirName = key.substr(path.length, key.indexOf("/", path.length + 1) - path.length);
if (dirName[0] === "/") {
dirName = dirName.substr(1);
}
if (result.indexOf(dirName) < 0) {
result.push(dirName);
}
}
});
return result;
}
};
}
@ -1036,7 +1053,9 @@ namespace Harness {
options.noErrorTruncation = true;
options.skipDefaultLibCheck = true;
currentDirectory = currentDirectory || Harness.IO.getCurrentDirectory();
if (typeof currentDirectory === "undefined") {
currentDirectory = Harness.IO.getCurrentDirectory();
}
// Parse settings
if (harnessSettings) {

View file

@ -246,16 +246,21 @@ namespace Harness.LanguageService {
};
this.getTypeReferenceDirectiveResolutionsForFile = (fileName) => {
const scriptInfo = this.getScriptInfo(fileName);
const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ false);
const resolutions: ts.Map<ts.ResolvedTypeReferenceDirective> = {};
const settings = this.nativeHost.getCompilationSettings();
for (const typeReferenceDirective of preprocessInfo.typeReferenceDirectives) {
const resolutionInfo = ts.resolveTypeReferenceDirective(typeReferenceDirective.fileName, fileName, settings, moduleResolutionHost);
if (resolutionInfo.resolvedTypeReferenceDirective.resolvedFileName) {
resolutions[typeReferenceDirective.fileName] = resolutionInfo.resolvedTypeReferenceDirective;
if (scriptInfo) {
const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ false);
const resolutions: ts.Map<ts.ResolvedTypeReferenceDirective> = {};
const settings = this.nativeHost.getCompilationSettings();
for (const typeReferenceDirective of preprocessInfo.typeReferenceDirectives) {
const resolutionInfo = ts.resolveTypeReferenceDirective(typeReferenceDirective.fileName, fileName, settings, moduleResolutionHost);
if (resolutionInfo.resolvedTypeReferenceDirective.resolvedFileName) {
resolutions[typeReferenceDirective.fileName] = resolutionInfo.resolvedTypeReferenceDirective;
}
}
return JSON.stringify(resolutions);
}
else {
return "[]";
}
return JSON.stringify(resolutions);
};
}
}

View file

@ -185,7 +185,8 @@ class ProjectRunner extends RunnerBase {
useCaseSensitiveFileNames: () => Harness.IO.useCaseSensitiveFileNames(),
getNewLine: () => Harness.IO.newLine(),
fileExists: fileName => fileName === Harness.Compiler.defaultLibFileName || getSourceFileText(fileName) !== undefined,
readFile: fileName => Harness.IO.readFile(fileName)
readFile: fileName => Harness.IO.readFile(fileName),
getDirectories: path => Harness.IO.getDirectories(path)
};
}
}

View file

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

View file

@ -315,6 +315,10 @@ namespace ts.server {
return this.host.directoryExists(path);
}
getDirectories(path: string): string[] {
return this.host.getDirectories(path);
}
/**
* @param line 1 based index
*/

View file

@ -304,6 +304,11 @@ declare namespace ts.server.protocol {
* True if reference is a write location, false otherwise.
*/
isWriteAccess: boolean;
/**
* True if reference is a definition, false otherwise.
*/
isDefinition: boolean;
}
/**

View file

@ -379,7 +379,7 @@ namespace ts.server {
start,
end,
file: fileName,
isWriteAccess
isWriteAccess,
};
});
}
@ -555,7 +555,8 @@ namespace ts.server {
start: start,
lineText: lineText,
end: compilerService.host.positionToLineOffset(ref.fileName, ts.textSpanEnd(ref.textSpan)),
isWriteAccess: ref.isWriteAccess
isWriteAccess: ref.isWriteAccess,
isDefinition: ref.isDefinition
};
});
},

View file

@ -1077,6 +1077,7 @@ namespace ts {
resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[];
resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[];
directoryExists?(directoryName: string): boolean;
getDirectories?(directoryName: string): string[];
}
//
@ -1208,6 +1209,7 @@ namespace ts {
textSpan: TextSpan;
fileName: string;
isWriteAccess: boolean;
isDefinition: boolean;
}
export interface DocumentHighlights {
@ -1941,17 +1943,17 @@ namespace ts {
let commandLineOptions_stringToEnum: CommandLineOptionOfCustomType[];
let commandLineOptionsStringToEnum: CommandLineOptionOfCustomType[];
/** JS users may pass in string values for enum compiler options (such as ModuleKind), so convert. */
function fixupCompilerOptions(options: CompilerOptions, diagnostics: Diagnostic[]): CompilerOptions {
// Lazily create this value to fix module loading errors.
commandLineOptions_stringToEnum = commandLineOptions_stringToEnum || <CommandLineOptionOfCustomType[]>filter(optionDeclarations, o =>
commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || <CommandLineOptionOfCustomType[]>filter(optionDeclarations, o =>
typeof o.type === "object" && !forEachValue(<Map<any>> o.type, v => typeof v !== "number"));
options = clone(options);
for (const opt of commandLineOptions_stringToEnum) {
for (const opt of commandLineOptionsStringToEnum) {
if (!hasProperty(options, opt.name)) {
continue;
}
@ -2038,7 +2040,8 @@ namespace ts {
getNewLine: () => newLine,
fileExists: (fileName): boolean => fileName === inputFileName,
readFile: (fileName): string => "",
directoryExists: directoryExists => true
directoryExists: directoryExists => true,
getDirectories: (path: string) => []
};
const program = createProgram([inputFileName], options, compilerHost);
@ -2139,7 +2142,7 @@ namespace ts {
const getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames);
function getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey {
return <DocumentRegistryBucketKey>`_${settings.target}|${settings.module}|${settings.noResolve}|${settings.jsx}|${settings.allowJs}|${settings.baseUrl}|${settings.typesRoot}|${settings.typesSearchPaths}|${JSON.stringify(settings.rootDirs)}|${JSON.stringify(settings.paths)}`;
return <DocumentRegistryBucketKey>`_${settings.target}|${settings.module}|${settings.noResolve}|${settings.jsx}|${settings.allowJs}|${settings.baseUrl}|${JSON.stringify(settings.typeRoots)}|${JSON.stringify(settings.rootDirs)}|${JSON.stringify(settings.paths)}`;
}
function getBucketForCompilationSettings(key: DocumentRegistryBucketKey, createIfMissing: boolean): FileMap<DocumentRegistryEntry> {
@ -2999,8 +3002,10 @@ namespace ts {
return entry && entry.scriptSnapshot.getText(0, entry.scriptSnapshot.getLength());
},
directoryExists: directoryName => {
Debug.assert(!host.resolveModuleNames || !host.resolveTypeReferenceDirectives);
return directoryProbablyExists(directoryName, host);
},
getDirectories: path => {
return host.getDirectories ? host.getDirectories(path) : [];
}
};
if (host.trace) {
@ -4137,7 +4142,7 @@ namespace ts {
if (!uniqueNames[name]) {
uniqueNames[name] = name;
const displayName = getCompletionEntryDisplayName(name, target, /*performCharacterChecks*/ true);
const displayName = getCompletionEntryDisplayName(unescapeIdentifier(name), target, /*performCharacterChecks*/ true);
if (displayName) {
const entry = {
name: displayName,
@ -5749,7 +5754,8 @@ namespace ts {
result.push({
fileName: entry.fileName,
textSpan: highlightSpan.textSpan,
isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference
isWriteAccess: highlightSpan.kind === HighlightSpanKind.writtenReference,
isDefinition: false
});
}
}
@ -6183,7 +6189,8 @@ namespace ts {
references: [{
fileName: sourceFile.fileName,
textSpan: createTextSpan(position, searchText.length),
isWriteAccess: false
isWriteAccess: false,
isDefinition: false
}]
});
}
@ -6737,7 +6744,8 @@ namespace ts {
return {
fileName: node.getSourceFile().fileName,
textSpan: createTextSpanFromBounds(start, end),
isWriteAccess: isWriteAccess(node)
isWriteAccess: isWriteAccess(node),
isDefinition: isDeclarationName(node) || isLiteralComputedPropertyDeclarationName(node)
};
}

View file

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

View file

@ -1,6 +1,7 @@
//// [tests/cases/compiler/commonSourceDir5.ts] ////
//// [bar.ts]
import {z} from "./foo";
export var x = z + z;

View file

@ -1,11 +1,12 @@
=== A:/bar.ts ===
import {z} from "./foo";
>z : Symbol(z, Decl(bar.ts, 0, 8))
>z : Symbol(z, Decl(bar.ts, 1, 8))
export var x = z + z;
>x : Symbol(x, Decl(bar.ts, 1, 10))
>z : Symbol(z, Decl(bar.ts, 0, 8))
>z : Symbol(z, Decl(bar.ts, 0, 8))
>x : Symbol(x, Decl(bar.ts, 2, 10))
>z : Symbol(z, Decl(bar.ts, 1, 8))
>z : Symbol(z, Decl(bar.ts, 1, 8))
=== A:/foo.ts ===
import {pi} from "B:/baz";

View file

@ -1,4 +1,5 @@
=== A:/bar.ts ===
import {z} from "./foo";
>z : number

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,13 +1,13 @@
tests/cases/compiler/es6modulekindWithES5Target10.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
tests/cases/compiler/es6modulekindWithES5Target10.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
tests/cases/compiler/es6modulekindWithES5Target10.ts(2,20): error TS2307: Cannot find module 'mod'.
tests/cases/compiler/es6modulekindWithES5Target10.ts(7,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.
tests/cases/compiler/es6modulekindWithES5Target10.ts(7,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.
==== tests/cases/compiler/es6modulekindWithES5Target10.ts (3 errors) ====
import i = require("mod"); // Error;
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
~~~~~
!!! error TS2307: Cannot find module 'mod'.
@ -16,4 +16,4 @@ tests/cases/compiler/es6modulekindWithES5Target10.ts(7,1): error TS1203: Export
}
export = N; // Error
~~~~~~~~~~~
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.

View file

@ -1,11 +1,11 @@
=== /consumer.ts ===
=== /src/consumer.ts ===
/// <reference types="jquery" />
$.foo();
>$.foo : Symbol(foo, Decl(index.d.ts, 3, 16))
>$ : Symbol($, Decl(index.d.ts, 3, 11))
>foo : Symbol(foo, Decl(index.d.ts, 3, 16))
=== /types/jquery/index.d.ts ===
=== /src/types/jquery/index.d.ts ===
// We can find typings in the ./types folder

View file

@ -1,7 +1,12 @@
[
"======== Resolving type reference directive 'jquery', containing file '/consumer.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"File '/types/jquery/package.json' does not exist.",
"File '/types/jquery/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/index.d.ts', primary: true. ========"
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'",
"File 'types/jquery/package.json' does not exist.",
"File 'types/jquery/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to 'types/jquery/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'jquery', containing file '/src/__inferred type names__.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'",
"File 'types/jquery/package.json' does not exist.",
"File 'types/jquery/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to 'types/jquery/index.d.ts', primary: true. ========"
]

View file

@ -1,4 +1,4 @@
=== /consumer.ts ===
=== /src/consumer.ts ===
/// <reference types="jquery" />
$.foo();
>$.foo() : void
@ -6,7 +6,7 @@ $.foo();
>$ : { foo(): void; }
>foo : () => void
=== /types/jquery/index.d.ts ===
=== /src/types/jquery/index.d.ts ===
// We can find typings in the ./types folder

View file

@ -1,11 +1,11 @@
=== /consumer.ts ===
=== /foo/consumer.ts ===
/// <reference types="jquery" />
$.foo();
>$.foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
>$ : Symbol($, Decl(jquery.d.ts, 0, 11))
>foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))
=== /types/jquery/jquery.d.ts ===
=== /foo/types/jquery/jquery.d.ts ===
declare var $: { foo(): void };
>$ : Symbol($, Decl(jquery.d.ts, 0, 11))
>foo : Symbol(foo, Decl(jquery.d.ts, 0, 16))

View file

@ -1,8 +1,14 @@
[
"======== Resolving type reference directive 'jquery', containing file '/consumer.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"Found 'package.json' at '/types/jquery/package.json'.",
"'package.json' has 'typings' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
"File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/jquery.d.ts', primary: true. ========"
"======== Resolving type reference directive 'jquery', containing file '/foo/consumer.ts', root directory './types'. ========",
"Resolving with primary search path './types'",
"Found 'package.json' at './types/jquery/package.json'.",
"'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.",
"File 'types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to 'types/jquery/jquery.d.ts', primary: true. ========",
"======== Resolving type reference directive 'jquery', containing file '/foo/__inferred type names__.ts', root directory './types'. ========",
"Resolving with primary search path './types'",
"Found 'package.json' at './types/jquery/package.json'.",
"'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.",
"File 'types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to 'types/jquery/jquery.d.ts', primary: true. ========"
]

View file

@ -1,4 +1,4 @@
=== /consumer.ts ===
=== /foo/consumer.ts ===
/// <reference types="jquery" />
$.foo();
>$.foo() : void
@ -6,7 +6,7 @@ $.foo();
>$ : { foo(): void; }
>foo : () => void
=== /types/jquery/jquery.d.ts ===
=== /foo/types/jquery/jquery.d.ts ===
declare var $: { foo(): void };
>$ : { foo(): void; }
>foo : () => void

View file

@ -1,12 +1,6 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"File '/types/jquery/package.json' does not exist.",
"File '/types/jquery/index.d.ts' does not exist.",
"Resolving with primary search path '/node_modules/'",
"File '/node_modules/jquery/package.json' does not exist.",
"File '/node_modules/jquery/index.d.ts' does not exist.",
"Resolving with primary search path '/node_modules/@types/'",
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/a/b'",

View file

@ -1,12 +1,6 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"File '/types/jquery/package.json' does not exist.",
"File '/types/jquery/index.d.ts' does not exist.",
"Resolving with primary search path '/node_modules/'",
"File '/node_modules/jquery/package.json' does not exist.",
"File '/node_modules/jquery/index.d.ts' does not exist.",
"Resolving with primary search path '/node_modules/@types/'",
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/a/b'",

View file

@ -1,6 +1,6 @@
[
"======== Resolving type reference directive 'jquery', containing file not set, root directory '/a'. ========",
"Resolving with primary search path '/a/types/'",
"======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory '/a/types'. ========",
"Resolving with primary search path '/a/types'",
"File '/a/types/jquery/package.json' does not exist.",
"File '/a/types/jquery/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to '/a/types/jquery/index.d.ts', primary: true. ========"

View file

@ -1,6 +1,6 @@
[
"======== Resolving type reference directive 'jquery', containing file not set, root directory '/a'. ========",
"Resolving with primary search path '/a/types/'",
"======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory '/a/types'. ========",
"Resolving with primary search path '/a/types'",
"File '/a/types/jquery/package.json' does not exist.",
"File '/a/types/jquery/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to '/a/types/jquery/index.d.ts', primary: true. ========"

View file

@ -1,15 +1,15 @@
error TS2304: Cannot find name 'jquery'.
/a/b/consumer.ts(1,1): error TS2304: Cannot find name '$'.
/a/b/consumer.ts(2,1): error TS2304: Cannot find name '$2'.
!!! error TS2304: Cannot find name 'jquery'.
==== /a/b/consumer.ts (1 errors) ====
$.foo();
~
!!! error TS2304: Cannot find name '$'.
$.foo(); // should OK
$2.foo(); // should error
~~
!!! error TS2304: Cannot find name '$2'.
==== /a/types/jquery/index.d.ts (0 errors) ====
declare var $: { foo(): void };
==== /a/types/jquery2/index.d.ts (0 errors) ====
declare var $2: { foo(): void };

View file

@ -3,11 +3,14 @@
//// [index.d.ts]
declare var $: { foo(): void };
//// [index.d.ts]
declare var $2: { foo(): void };
//// [consumer.ts]
$.foo();
$.foo(); // should OK
$2.foo(); // should error
//// [consumer.js]
$.foo();
$.foo(); // should OK
$2.foo(); // should error

View file

@ -1,24 +1,7 @@
[
"======== Resolving type reference directive 'jquery', containing file not set, root directory '/'. ========",
"Resolving with primary search path '/types/'",
"File '/types/jquery/package.json' does not exist.",
"File '/types/jquery/index.d.ts' does not exist.",
"Resolving with primary search path '/node_modules/'",
"File '/node_modules/jquery/package.json' does not exist.",
"File '/node_modules/jquery/index.d.ts' does not exist.",
"Resolving with primary search path '/node_modules/@types/'",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/'",
"File '/node_modules/jquery.ts' does not exist.",
"File '/node_modules/jquery.d.ts' does not exist.",
"File '/node_modules/jquery/package.json' does not exist.",
"File '/node_modules/jquery/index.ts' does not exist.",
"File '/node_modules/jquery/index.d.ts' does not exist.",
"File '/node_modules/@types/jquery.ts' does not exist.",
"File '/node_modules/@types/jquery.d.ts' does not exist.",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.ts' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' does not exist.",
"======== Type reference directive 'jquery' was not resolved. ========"
"======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'",
"File 'types/jquery/package.json' does not exist.",
"File 'types/jquery/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to 'types/jquery/index.d.ts', primary: true. ========"
]

View file

@ -1,6 +1,12 @@
[
"======== Resolving type reference directive 'jquery', containing file '/consumer.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"======== Resolving type reference directive 'jquery', containing file '/consumer.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"Found 'package.json' at '/types/jquery/package.json'.",
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
"File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/jquery.d.ts', primary: true. ========",
"======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"Found 'package.json' at '/types/jquery/package.json'.",
"'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.",
"File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.",

View file

@ -1,10 +1,13 @@
[
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory '/src'. ========",
"Resolving with primary search path '/src/types/'",
"File '/src/types/jquery/package.json' does not exist.",
"File '/src/types/jquery/index.d.ts' does not exist.",
"Resolving with primary search path '/src/node_modules/'",
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory '/src/node_modules/@types'. ========",
"Resolving with primary search path '/src/node_modules/@types'",
"File '/src/node_modules/@types/jquery/package.json' does not exist.",
"File '/src/node_modules/@types/jquery/index.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/src'",
"File '/src/node_modules/jquery.ts' does not exist.",
"File '/src/node_modules/jquery.d.ts' does not exist.",
"File '/src/node_modules/jquery/package.json' does not exist.",
"File '/src/node_modules/jquery/index.ts' does not exist.",
"File '/src/node_modules/jquery/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to '/src/node_modules/jquery/index.d.ts', primary: true. ========"
"======== Type reference directive 'jquery' was successfully resolved to '/src/node_modules/jquery/index.d.ts', primary: false. ========"
]

View file

@ -1,14 +1,8 @@
[
"======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory '/src'. ========",
"Resolving with primary search path '/src/types/'",
"File '/src/types/foo/package.json' does not exist.",
"File '/src/types/foo/index.d.ts' does not exist.",
"Resolving with primary search path '/src/node_modules/'",
"File '/src/node_modules/foo/package.json' does not exist.",
"File '/src/node_modules/foo/index.d.ts' does not exist.",
"Resolving with primary search path '/src/node_modules/@types/'",
"File '/src/node_modules/@types/foo/package.json' does not exist.",
"File '/src/node_modules/@types/foo/index.d.ts' does not exist.",
"Resolving with primary search path '/src'",
"File '/src/foo/package.json' does not exist.",
"File '/src/foo/index.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/src'",
"File '/src/node_modules/foo.ts' does not exist.",
"File '/src/node_modules/foo.d.ts' does not exist.",
@ -27,15 +21,9 @@
"File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========",
"======== Resolving type reference directive 'bar', containing file '/src/root.ts', root directory '/src'. ========",
"Resolving with primary search path '/src/types/'",
"File '/src/types/bar/package.json' does not exist.",
"File '/src/types/bar/index.d.ts' does not exist.",
"Resolving with primary search path '/src/node_modules/'",
"File '/src/node_modules/bar/package.json' does not exist.",
"File '/src/node_modules/bar/index.d.ts' does not exist.",
"Resolving with primary search path '/src/node_modules/@types/'",
"File '/src/node_modules/@types/bar/package.json' does not exist.",
"File '/src/node_modules/@types/bar/index.d.ts' does not exist.",
"Resolving with primary search path '/src'",
"File '/src/bar/package.json' does not exist.",
"File '/src/bar/index.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/src'",
"File '/src/node_modules/bar.ts' does not exist.",
"File '/src/node_modules/bar.d.ts' does not exist.",
@ -54,15 +42,9 @@
"File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: false. ========",
"======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory '/src'. ========",
"Resolving with primary search path '/src/types/'",
"File '/src/types/alpha/package.json' does not exist.",
"File '/src/types/alpha/index.d.ts' does not exist.",
"Resolving with primary search path '/src/node_modules/'",
"File '/src/node_modules/alpha/package.json' does not exist.",
"File '/src/node_modules/alpha/index.d.ts' does not exist.",
"Resolving with primary search path '/src/node_modules/@types/'",
"File '/src/node_modules/@types/alpha/package.json' does not exist.",
"File '/src/node_modules/@types/alpha/index.d.ts' does not exist.",
"Resolving with primary search path '/src'",
"File '/src/alpha/package.json' does not exist.",
"File '/src/alpha/index.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/node_modules/foo'",
"File '/node_modules/foo/node_modules/alpha.ts' does not exist.",
"File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.",
@ -71,15 +53,9 @@
"File '/node_modules/foo/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/foo/node_modules/alpha/index.d.ts', primary: false. ========",
"======== Resolving type reference directive 'alpha', containing file '/node_modules/bar/index.d.ts', root directory '/src'. ========",
"Resolving with primary search path '/src/types/'",
"File '/src/types/alpha/package.json' does not exist.",
"File '/src/types/alpha/index.d.ts' does not exist.",
"Resolving with primary search path '/src/node_modules/'",
"File '/src/node_modules/alpha/package.json' does not exist.",
"File '/src/node_modules/alpha/index.d.ts' does not exist.",
"Resolving with primary search path '/src/node_modules/@types/'",
"File '/src/node_modules/@types/alpha/package.json' does not exist.",
"File '/src/node_modules/@types/alpha/index.d.ts' does not exist.",
"Resolving with primary search path '/src'",
"File '/src/alpha/package.json' does not exist.",
"File '/src/alpha/index.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/node_modules/bar'",
"File '/node_modules/bar/node_modules/alpha.ts' does not exist.",
"File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.",

View file

@ -1,30 +1,50 @@
[
"======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"File '/types/foo/package.json' does not exist.",
"File '/types/foo/index.d.ts' does not exist.",
"Resolving with primary search path '/node_modules/'",
"======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'",
"File 'types/foo/package.json' does not exist.",
"File 'types/foo/index.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/src'",
"File '/src/node_modules/foo.ts' does not exist.",
"File '/src/node_modules/foo.d.ts' does not exist.",
"File '/src/node_modules/foo/package.json' does not exist.",
"File '/src/node_modules/foo/index.ts' does not exist.",
"File '/src/node_modules/foo/index.d.ts' does not exist.",
"File '/src/node_modules/@types/foo.ts' does not exist.",
"File '/src/node_modules/@types/foo.d.ts' does not exist.",
"File '/src/node_modules/@types/foo/package.json' does not exist.",
"File '/src/node_modules/@types/foo/index.ts' does not exist.",
"File '/src/node_modules/@types/foo/index.d.ts' does not exist.",
"File '/node_modules/foo.ts' does not exist.",
"File '/node_modules/foo.d.ts' does not exist.",
"File '/node_modules/foo/package.json' does not exist.",
"File '/node_modules/foo/index.ts' does not exist.",
"File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'bar', containing file '/src/root.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"File '/types/bar/package.json' does not exist.",
"File '/types/bar/index.d.ts' does not exist.",
"Resolving with primary search path '/node_modules/'",
"======== Type reference directive 'foo' was successfully resolved to '/node_modules/foo/index.d.ts', primary: false. ========",
"======== Resolving type reference directive 'bar', containing file '/src/root.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'",
"File 'types/bar/package.json' does not exist.",
"File 'types/bar/index.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/src'",
"File '/src/node_modules/bar.ts' does not exist.",
"File '/src/node_modules/bar.d.ts' does not exist.",
"File '/src/node_modules/bar/package.json' does not exist.",
"File '/src/node_modules/bar/index.ts' does not exist.",
"File '/src/node_modules/bar/index.d.ts' does not exist.",
"File '/src/node_modules/@types/bar.ts' does not exist.",
"File '/src/node_modules/@types/bar.d.ts' does not exist.",
"File '/src/node_modules/@types/bar/package.json' does not exist.",
"File '/src/node_modules/@types/bar/index.ts' does not exist.",
"File '/src/node_modules/@types/bar/index.d.ts' does not exist.",
"File '/node_modules/bar.ts' does not exist.",
"File '/node_modules/bar.d.ts' does not exist.",
"File '/node_modules/bar/package.json' does not exist.",
"File '/node_modules/bar/index.ts' does not exist.",
"File '/node_modules/bar/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"File '/types/alpha/package.json' does not exist.",
"File '/types/alpha/index.d.ts' does not exist.",
"Resolving with primary search path '/node_modules/'",
"File '/node_modules/alpha/package.json' does not exist.",
"File '/node_modules/alpha/index.d.ts' does not exist.",
"Resolving with primary search path '/node_modules/@types/'",
"File '/node_modules/@types/alpha/package.json' does not exist.",
"File '/node_modules/@types/alpha/index.d.ts' does not exist.",
"======== Type reference directive 'bar' was successfully resolved to '/node_modules/bar/index.d.ts', primary: false. ========",
"======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'",
"File 'types/alpha/package.json' does not exist.",
"File 'types/alpha/index.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/node_modules/foo'",
"File '/node_modules/foo/node_modules/alpha.ts' does not exist.",
"File '/node_modules/foo/node_modules/alpha.d.ts' does not exist.",
@ -32,16 +52,10 @@
"File '/node_modules/foo/node_modules/alpha/index.ts' does not exist.",
"File '/node_modules/foo/node_modules/alpha/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/foo/node_modules/alpha/index.d.ts', primary: false. ========",
"======== Resolving type reference directive 'alpha', containing file '/node_modules/bar/index.d.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"File '/types/alpha/package.json' does not exist.",
"File '/types/alpha/index.d.ts' does not exist.",
"Resolving with primary search path '/node_modules/'",
"File '/node_modules/alpha/package.json' does not exist.",
"File '/node_modules/alpha/index.d.ts' does not exist.",
"Resolving with primary search path '/node_modules/@types/'",
"File '/node_modules/@types/alpha/package.json' does not exist.",
"File '/node_modules/@types/alpha/index.d.ts' does not exist.",
"======== Resolving type reference directive 'alpha', containing file '/node_modules/bar/index.d.ts', root directory 'types'. ========",
"Resolving with primary search path 'types'",
"File 'types/alpha/package.json' does not exist.",
"File 'types/alpha/index.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/node_modules/bar'",
"File '/node_modules/bar/node_modules/alpha.ts' does not exist.",
"File '/node_modules/bar/node_modules/alpha.d.ts' does not exist.",

View file

@ -6,7 +6,7 @@ var x: string = alpha.a;
>alpha : Symbol(alpha, Decl(index.d.ts, 3, 11))
>a : Symbol(a, Decl(index.d.ts, 3, 20))
=== /types/alpha/index.d.ts ===
=== /node_modules/@types/alpha/index.d.ts ===
// The primary lookup folder is relative to tsconfig.json, if present

View file

@ -1,7 +1,12 @@
[
"======== Resolving type reference directive 'alpha', containing file '/src/foo.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"File '/types/alpha/package.json' does not exist.",
"File '/types/alpha/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'alpha' was successfully resolved to '/types/alpha/index.d.ts', primary: true. ========"
"======== Resolving type reference directive 'alpha', containing file '/src/foo.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/alpha/package.json' does not exist.",
"File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/@types/alpha/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'alpha', containing file '/src/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/alpha/package.json' does not exist.",
"File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'alpha' was successfully resolved to '/node_modules/@types/alpha/index.d.ts', primary: true. ========"
]

View file

@ -6,7 +6,7 @@ var x: string = alpha.a;
>alpha : { a: string; }
>a : string
=== /types/alpha/index.d.ts ===
=== /node_modules/@types/alpha/index.d.ts ===
// The primary lookup folder is relative to tsconfig.json, if present

View file

@ -1,12 +1,6 @@
[
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"File '/types/jquery/package.json' does not exist.",
"File '/types/jquery/index.d.ts' does not exist.",
"Resolving with primary search path '/node_modules/'",
"File '/node_modules/jquery/package.json' does not exist.",
"File '/node_modules/jquery/index.d.ts' does not exist.",
"Resolving with primary search path '/node_modules/@types/'",
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' does not exist.",
"Looking up in 'node_modules' folder, initial location '/src'",

View file

@ -1,4 +1,4 @@
=== /foo.ts ===
=== /test/foo.ts ===
/// <reference types="alpha" />
/// <reference types="beta" />
var x: string = alpha.a + beta.b;
@ -11,7 +11,7 @@ var x: string = alpha.a + beta.b;
>b : Symbol(b, Decl(index.d.ts, 1, 19))
=== /types/alpha/index.d.ts ===
=== /test/types/alpha/index.d.ts ===
// Don't crash in circular library reference situations
@ -20,7 +20,7 @@ declare var alpha: { a: string };
>alpha : Symbol(alpha, Decl(index.d.ts, 4, 11))
>a : Symbol(a, Decl(index.d.ts, 4, 20))
=== /types/beta/index.d.ts ===
=== /test/types/beta/index.d.ts ===
/// <reference types="alpha" />
declare var beta: { b: string };
>beta : Symbol(beta, Decl(index.d.ts, 1, 11))

View file

@ -1,22 +1,32 @@
[
"======== Resolving type reference directive 'alpha', containing file '/foo.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"File '/types/alpha/package.json' does not exist.",
"File '/types/alpha/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'alpha' was successfully resolved to '/types/alpha/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'beta', containing file '/foo.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"File '/types/beta/package.json' does not exist.",
"File '/types/beta/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'beta' was successfully resolved to '/types/beta/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'beta', containing file '/types/alpha/index.d.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"File '/types/beta/package.json' does not exist.",
"File '/types/beta/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'beta' was successfully resolved to '/types/beta/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'alpha', containing file '/types/beta/index.d.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"File '/types/alpha/package.json' does not exist.",
"File '/types/alpha/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'alpha' was successfully resolved to '/types/alpha/index.d.ts', primary: true. ========"
"======== Resolving type reference directive 'alpha', containing file '/test/foo.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'",
"File '/test/types/alpha/package.json' does not exist.",
"File '/test/types/alpha/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'alpha' was successfully resolved to '/test/types/alpha/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'beta', containing file '/test/foo.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'",
"File '/test/types/beta/package.json' does not exist.",
"File '/test/types/beta/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'beta' was successfully resolved to '/test/types/beta/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'beta', containing file '/test/types/alpha/index.d.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'",
"File '/test/types/beta/package.json' does not exist.",
"File '/test/types/beta/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'beta' was successfully resolved to '/test/types/beta/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'alpha', containing file '/test/types/beta/index.d.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'",
"File '/test/types/alpha/package.json' does not exist.",
"File '/test/types/alpha/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'alpha' was successfully resolved to '/test/types/alpha/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'alpha', containing file '/test/__inferred type names__.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'",
"File '/test/types/alpha/package.json' does not exist.",
"File '/test/types/alpha/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'alpha' was successfully resolved to '/test/types/alpha/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'beta', containing file '/test/__inferred type names__.ts', root directory '/test/types'. ========",
"Resolving with primary search path '/test/types'",
"File '/test/types/beta/package.json' does not exist.",
"File '/test/types/beta/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'beta' was successfully resolved to '/test/types/beta/index.d.ts', primary: true. ========"
]

View file

@ -1,4 +1,4 @@
=== /foo.ts ===
=== /test/foo.ts ===
/// <reference types="alpha" />
/// <reference types="beta" />
var x: string = alpha.a + beta.b;
@ -12,7 +12,7 @@ var x: string = alpha.a + beta.b;
>b : string
=== /types/alpha/index.d.ts ===
=== /test/types/alpha/index.d.ts ===
// Don't crash in circular library reference situations
@ -21,7 +21,7 @@ declare var alpha: { a: string };
>alpha : { a: string; }
>a : string
=== /types/beta/index.d.ts ===
=== /test/types/beta/index.d.ts ===
/// <reference types="alpha" />
declare var beta: { b: string };
>beta : { b: string; }

View file

@ -1,16 +0,0 @@
//// [tests/cases/conformance/references/library-reference-9.ts] ////
//// [index.d.ts]
// Use types search path
declare var alpha: { a: string };
//// [foo.ts]
/// <reference types="alpha" />
var x: string = alpha.a;
//// [foo.js]
/// <reference types="alpha" />
var x = alpha.a;

View file

@ -1,16 +0,0 @@
=== /base/src/foo.ts ===
/// <reference types="alpha" />
var x: string = alpha.a;
>x : Symbol(x, Decl(foo.ts, 1, 3))
>alpha.a : Symbol(a, Decl(index.d.ts, 3, 20))
>alpha : Symbol(alpha, Decl(index.d.ts, 3, 11))
>a : Symbol(a, Decl(index.d.ts, 3, 20))
=== /share/typelib/alpha/index.d.ts ===
// Use types search path
declare var alpha: { a: string };
>alpha : Symbol(alpha, Decl(index.d.ts, 3, 11))
>a : Symbol(a, Decl(index.d.ts, 3, 20))

View file

@ -1,7 +0,0 @@
[
"======== Resolving type reference directive 'alpha', containing file '/base/src/foo.ts', root directory '/'. ========",
"Resolving with primary search path '/share/typelib'",
"File '/share/typelib/alpha/package.json' does not exist.",
"File '/share/typelib/alpha/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'alpha' was successfully resolved to '/share/typelib/alpha/index.d.ts', primary: true. ========"
]

View file

@ -1,16 +0,0 @@
=== /base/src/foo.ts ===
/// <reference types="alpha" />
var x: string = alpha.a;
>x : string
>alpha.a : string
>alpha : { a: string; }
>a : string
=== /share/typelib/alpha/index.d.ts ===
// Use types search path
declare var alpha: { a: string };
>alpha : { a: string; }
>a : string

View file

@ -3,11 +3,13 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/src/a'.",
"File '/src/a.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/a.ts', result '/src/a.ts'",
"======== Module name './a' was successfully resolved to '/src/a.ts'. ========",
"======== Resolving module './a.ts' from '/src/c.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/src/a.ts'.",
"File '/src/a.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/a.ts', result '/src/a.ts'",
"======== Module name './a.ts' was successfully resolved to '/src/a.ts'. ========",
"======== Resolving module './a.js' from '/src/d.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@ -17,6 +19,7 @@
"File '/src/a.js.d.ts' does not exist.",
"File name '/src/a.js' has a '.js' extension - stripping it",
"File '/src/a.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/a.ts', result '/src/a.ts'",
"======== Module name './a.js' was successfully resolved to '/src/a.ts'. ========",
"======== Resolving module './jquery.js' from '/src/jquery_user_1.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@ -28,5 +31,6 @@
"File '/src/jquery.ts' does not exist.",
"File '/src/jquery.tsx' does not exist.",
"File '/src/jquery.d.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/jquery.d.ts', result '/src/jquery.d.ts'",
"======== Module name './jquery.js' was successfully resolved to '/src/jquery.d.ts'. ========"
]

View file

@ -0,0 +1,21 @@
/src/library-b/index.ts(1,23): error TS2307: Cannot find module 'library-a'.
==== /src/app.ts (0 errors) ====
import { MyClass } from "./library-a";
import { MyClass2 } from "./library-b";
let x: MyClass;
let y: MyClass2;
x = y;
y = x;
==== /src/library-a/index.ts (0 errors) ====
export class MyClass{}
==== /src/library-b/index.ts (1 errors) ====
import {MyClass} from "library-a";
~~~~~~~~~~~
!!! error TS2307: Cannot find module 'library-a'.
export { MyClass as MyClass2 }

View file

@ -1,36 +0,0 @@
=== /src/app.ts ===
import { MyClass } from "./library-a";
>MyClass : Symbol(MyClass, Decl(app.ts, 0, 8))
import { MyClass2 } from "./library-b";
>MyClass2 : Symbol(MyClass2, Decl(app.ts, 1, 8))
let x: MyClass;
>x : Symbol(x, Decl(app.ts, 3, 3))
>MyClass : Symbol(MyClass, Decl(app.ts, 0, 8))
let y: MyClass2;
>y : Symbol(y, Decl(app.ts, 4, 3))
>MyClass2 : Symbol(MyClass2, Decl(app.ts, 1, 8))
x = y;
>x : Symbol(x, Decl(app.ts, 3, 3))
>y : Symbol(y, Decl(app.ts, 4, 3))
y = x;
>y : Symbol(y, Decl(app.ts, 4, 3))
>x : Symbol(x, Decl(app.ts, 3, 3))
=== /src/library-a/index.ts ===
export class MyClass{}
>MyClass : Symbol(MyClass, Decl(index.ts, 0, 0))
=== /src/library-b/index.ts ===
import {MyClass} from "library-a";
>MyClass : Symbol(MyClass, Decl(index.ts, 0, 8))
export { MyClass as MyClass2 }
>MyClass : Symbol(MyClass2, Decl(index.ts, 1, 8))
>MyClass2 : Symbol(MyClass2, Decl(index.ts, 1, 8))

View file

@ -26,7 +26,43 @@
"File '/src/library-b/node_modules/library-a.tsx' does not exist.",
"File '/src/library-b/node_modules/library-a.d.ts' does not exist.",
"File '/src/library-b/node_modules/library-a/package.json' does not exist.",
"File '/src/library-b/node_modules/library-a/index.ts' exist - use it as a name resolution result.",
"Resolving real path for '/src/library-b/node_modules/library-a/index.ts', result '/src/library-a/index.ts'",
"======== Module name 'library-a' was successfully resolved to '/src/library-a/index.ts'. ========"
"File '/src/library-b/node_modules/library-a/index.ts' does not exist.",
"File '/src/library-b/node_modules/library-a/index.tsx' does not exist.",
"File '/src/library-b/node_modules/library-a/index.d.ts' does not exist.",
"File '/src/library-b/node_modules/@types/library-a.ts' does not exist.",
"File '/src/library-b/node_modules/@types/library-a.tsx' does not exist.",
"File '/src/library-b/node_modules/@types/library-a.d.ts' does not exist.",
"File '/src/library-b/node_modules/@types/library-a/package.json' does not exist.",
"File '/src/library-b/node_modules/@types/library-a/index.ts' does not exist.",
"File '/src/library-b/node_modules/@types/library-a/index.tsx' does not exist.",
"File '/src/library-b/node_modules/@types/library-a/index.d.ts' does not exist.",
"File '/src/node_modules/library-a.ts' does not exist.",
"File '/src/node_modules/library-a.tsx' does not exist.",
"File '/src/node_modules/library-a.d.ts' does not exist.",
"File '/src/node_modules/library-a/package.json' does not exist.",
"File '/src/node_modules/library-a/index.ts' does not exist.",
"File '/src/node_modules/library-a/index.tsx' does not exist.",
"File '/src/node_modules/library-a/index.d.ts' does not exist.",
"File '/src/node_modules/@types/library-a.ts' does not exist.",
"File '/src/node_modules/@types/library-a.tsx' does not exist.",
"File '/src/node_modules/@types/library-a.d.ts' does not exist.",
"File '/src/node_modules/@types/library-a/package.json' does not exist.",
"File '/src/node_modules/@types/library-a/index.ts' does not exist.",
"File '/src/node_modules/@types/library-a/index.tsx' does not exist.",
"File '/src/node_modules/@types/library-a/index.d.ts' does not exist.",
"File '/node_modules/library-a.ts' does not exist.",
"File '/node_modules/library-a.tsx' does not exist.",
"File '/node_modules/library-a.d.ts' does not exist.",
"File '/node_modules/library-a/package.json' does not exist.",
"File '/node_modules/library-a/index.ts' does not exist.",
"File '/node_modules/library-a/index.tsx' does not exist.",
"File '/node_modules/library-a/index.d.ts' does not exist.",
"File '/node_modules/@types/library-a.ts' does not exist.",
"File '/node_modules/@types/library-a.tsx' does not exist.",
"File '/node_modules/@types/library-a.d.ts' does not exist.",
"File '/node_modules/@types/library-a/package.json' does not exist.",
"File '/node_modules/@types/library-a/index.ts' does not exist.",
"File '/node_modules/@types/library-a/index.tsx' does not exist.",
"File '/node_modules/@types/library-a/index.d.ts' does not exist.",
"======== Module name 'library-a' was not resolved. ========"
]

View file

@ -1,38 +0,0 @@
=== /src/app.ts ===
import { MyClass } from "./library-a";
>MyClass : typeof MyClass
import { MyClass2 } from "./library-b";
>MyClass2 : typeof MyClass
let x: MyClass;
>x : MyClass
>MyClass : MyClass
let y: MyClass2;
>y : MyClass
>MyClass2 : MyClass
x = y;
>x = y : MyClass
>x : MyClass
>y : MyClass
y = x;
>y = x : MyClass
>y : MyClass
>x : MyClass
=== /src/library-a/index.ts ===
export class MyClass{}
>MyClass : MyClass
=== /src/library-b/index.ts ===
import {MyClass} from "library-a";
>MyClass : typeof MyClass
export { MyClass as MyClass2 }
>MyClass : typeof MyClass
>MyClass2 : typeof MyClass

View file

@ -0,0 +1,30 @@
//// [nullOrUndefinedTypeGuardIsOrderIndependent.ts]
function test(strOrNull: string | null, strOrUndefined: string | undefined) {
var str: string = "original";
var nil: null;
if (null === strOrNull) {
nil = strOrNull;
}
else {
str = strOrNull;
}
if (undefined !== strOrUndefined) {
str = strOrUndefined;
}
}
//// [nullOrUndefinedTypeGuardIsOrderIndependent.js]
function test(strOrNull, strOrUndefined) {
var str = "original";
var nil;
if (null === strOrNull) {
nil = strOrNull;
}
else {
str = strOrNull;
}
if (undefined !== strOrUndefined) {
str = strOrUndefined;
}
}

View file

@ -0,0 +1,34 @@
=== tests/cases/conformance/expressions/typeGuards/nullOrUndefinedTypeGuardIsOrderIndependent.ts ===
function test(strOrNull: string | null, strOrUndefined: string | undefined) {
>test : Symbol(test, Decl(nullOrUndefinedTypeGuardIsOrderIndependent.ts, 0, 0))
>strOrNull : Symbol(strOrNull, Decl(nullOrUndefinedTypeGuardIsOrderIndependent.ts, 0, 14))
>strOrUndefined : Symbol(strOrUndefined, Decl(nullOrUndefinedTypeGuardIsOrderIndependent.ts, 0, 39))
var str: string = "original";
>str : Symbol(str, Decl(nullOrUndefinedTypeGuardIsOrderIndependent.ts, 1, 7))
var nil: null;
>nil : Symbol(nil, Decl(nullOrUndefinedTypeGuardIsOrderIndependent.ts, 2, 7))
if (null === strOrNull) {
>strOrNull : Symbol(strOrNull, Decl(nullOrUndefinedTypeGuardIsOrderIndependent.ts, 0, 14))
nil = strOrNull;
>nil : Symbol(nil, Decl(nullOrUndefinedTypeGuardIsOrderIndependent.ts, 2, 7))
>strOrNull : Symbol(strOrNull, Decl(nullOrUndefinedTypeGuardIsOrderIndependent.ts, 0, 14))
}
else {
str = strOrNull;
>str : Symbol(str, Decl(nullOrUndefinedTypeGuardIsOrderIndependent.ts, 1, 7))
>strOrNull : Symbol(strOrNull, Decl(nullOrUndefinedTypeGuardIsOrderIndependent.ts, 0, 14))
}
if (undefined !== strOrUndefined) {
>undefined : Symbol(undefined)
>strOrUndefined : Symbol(strOrUndefined, Decl(nullOrUndefinedTypeGuardIsOrderIndependent.ts, 0, 39))
str = strOrUndefined;
>str : Symbol(str, Decl(nullOrUndefinedTypeGuardIsOrderIndependent.ts, 1, 7))
>strOrUndefined : Symbol(strOrUndefined, Decl(nullOrUndefinedTypeGuardIsOrderIndependent.ts, 0, 39))
}
}

View file

@ -0,0 +1,43 @@
=== tests/cases/conformance/expressions/typeGuards/nullOrUndefinedTypeGuardIsOrderIndependent.ts ===
function test(strOrNull: string | null, strOrUndefined: string | undefined) {
>test : (strOrNull: string | null, strOrUndefined: string | undefined) => void
>strOrNull : string | null
>null : null
>strOrUndefined : string | undefined
var str: string = "original";
>str : string
>"original" : string
var nil: null;
>nil : null
>null : null
if (null === strOrNull) {
>null === strOrNull : boolean
>null : null
>strOrNull : string | null
nil = strOrNull;
>nil = strOrNull : null
>nil : null
>strOrNull : null
}
else {
str = strOrNull;
>str = strOrNull : string
>str : string
>strOrNull : string
}
if (undefined !== strOrUndefined) {
>undefined !== strOrUndefined : boolean
>undefined : undefined
>strOrUndefined : string | undefined
str = strOrUndefined;
>str = strOrUndefined : string
>str : string
>strOrUndefined : string
}
}

View file

@ -5,11 +5,13 @@
"Resolving module name 'folder2/file2' relative to base url 'c:/root' - 'c:/root/folder2/file2'.",
"Loading module as file / folder, candidate module location 'c:/root/folder2/file2'.",
"File 'c:/root/folder2/file2.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/folder2/file2.ts', result 'c:/root/folder2/file2.ts'",
"======== Module name 'folder2/file2' was successfully resolved to 'c:/root/folder2/file2.ts'. ========",
"======== Resolving module './file3' from 'c:/root/folder2/file2.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module as file / folder, candidate module location 'c:/root/folder2/file3'.",
"File 'c:/root/folder2/file3.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/folder2/file3.ts', result 'c:/root/folder2/file3.ts'",
"======== Module name './file3' was successfully resolved to 'c:/root/folder2/file3.ts'. ========",
"======== Resolving module 'file4' from 'c:/root/folder2/file2.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
@ -59,5 +61,6 @@
"File 'c:/node_modules/file4/index.ts' does not exist.",
"File 'c:/node_modules/file4/index.tsx' does not exist.",
"File 'c:/node_modules/file4/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/node_modules/file4/index.d.ts', result 'c:/node_modules/file4/index.d.ts'",
"======== Module name 'file4' was successfully resolved to 'c:/node_modules/file4/index.d.ts'. ========"
]

View file

@ -5,11 +5,13 @@
"Resolving module name 'folder2/file2' relative to base url 'c:/root' - 'c:/root/folder2/file2'.",
"Loading module as file / folder, candidate module location 'c:/root/folder2/file2'.",
"File 'c:/root/folder2/file2.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/folder2/file2.ts', result 'c:/root/folder2/file2.ts'",
"======== Module name 'folder2/file2' was successfully resolved to 'c:/root/folder2/file2.ts'. ========",
"======== Resolving module './file3' from 'c:/root/folder2/file2.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
"Loading module as file / folder, candidate module location 'c:/root/folder2/file3'.",
"File 'c:/root/folder2/file3.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/folder2/file3.ts', result 'c:/root/folder2/file3.ts'",
"======== Module name './file3' was successfully resolved to 'c:/root/folder2/file3.ts'. ========",
"======== Resolving module 'file4' from 'c:/root/folder2/file2.ts'. ========",
"Explicitly specified module resolution kind: 'NodeJs'.",
@ -59,5 +61,6 @@
"File 'c:/node_modules/file4/index.ts' does not exist.",
"File 'c:/node_modules/file4/index.tsx' does not exist.",
"File 'c:/node_modules/file4/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/node_modules/file4/index.d.ts', result 'c:/node_modules/file4/index.d.ts'",
"======== Module name 'file4' was successfully resolved to 'c:/node_modules/file4/index.d.ts'. ========"
]

View file

@ -7,6 +7,7 @@
"Trying substitution '*', candidate module location: 'folder2/file1'.",
"Loading module as file / folder, candidate module location 'c:/root/folder2/file1'.",
"File 'c:/root/folder2/file1.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/folder2/file1.ts', result 'c:/root/folder2/file1.ts'",
"======== Module name 'folder2/file1' was successfully resolved to 'c:/root/folder2/file1.ts'. ========",
"======== Resolving module 'folder3/file2' from 'c:/root/folder1/file1.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@ -25,6 +26,7 @@
"Trying substitution 'generated/*', candidate module location: 'generated/folder3/file2'.",
"Loading module as file / folder, candidate module location 'c:/root/generated/folder3/file2'.",
"File 'c:/root/generated/folder3/file2.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/generated/folder3/file2.ts', result 'c:/root/generated/folder3/file2.ts'",
"======== Module name 'folder3/file2' was successfully resolved to 'c:/root/generated/folder3/file2.ts'. ========",
"======== Resolving module 'components/file3' from 'c:/root/folder1/file1.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@ -40,6 +42,7 @@
"File 'c:/root/shared/components/file3/index.ts' does not exist.",
"File 'c:/root/shared/components/file3/index.tsx' does not exist.",
"File 'c:/root/shared/components/file3/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/shared/components/file3/index.d.ts', result 'c:/root/shared/components/file3/index.d.ts'",
"======== Module name 'components/file3' was successfully resolved to 'c:/root/shared/components/file3/index.d.ts'. ========",
"======== Resolving module 'file4' from 'c:/root/folder1/file1.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@ -94,5 +97,6 @@
"File 'c:/root/node_modules/@types/file4/index.tsx' does not exist.",
"File 'c:/root/node_modules/@types/file4/index.d.ts' does not exist.",
"File 'c:/node_modules/file4.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/node_modules/file4.ts', result 'c:/node_modules/file4.ts'",
"======== Module name 'file4' was successfully resolved to 'c:/node_modules/file4.ts'. ========"
]

View file

@ -18,6 +18,7 @@
"Loading 'project/file3' from the root dir 'c:/root/generated/src', candidate location 'c:/root/generated/src/project/file3'",
"Loading module as file / folder, candidate module location 'c:/root/generated/src/project/file3'.",
"File 'c:/root/generated/src/project/file3.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/generated/src/project/file3.ts', result 'c:/root/generated/src/project/file3.ts'",
"======== Module name './project/file3' was successfully resolved to 'c:/root/generated/src/project/file3.ts'. ========",
"======== Resolving module '../file2' from 'c:/root/generated/src/project/file3.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@ -44,5 +45,6 @@
"File 'c:/root/src/file2/index.ts' does not exist.",
"File 'c:/root/src/file2/index.tsx' does not exist.",
"File 'c:/root/src/file2/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/src/file2/index.d.ts', result 'c:/root/src/file2/index.d.ts'",
"======== Module name '../file2' was successfully resolved to 'c:/root/src/file2/index.d.ts'. ========"
]

View file

@ -18,6 +18,7 @@
"Loading 'project/file2' from the root dir 'c:/root/generated/src', candidate location 'c:/root/generated/src/project/file2'",
"Loading module as file / folder, candidate module location 'c:/root/generated/src/project/file2'.",
"File 'c:/root/generated/src/project/file2.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/generated/src/project/file2.ts', result 'c:/root/generated/src/project/file2.ts'",
"======== Module name './project/file2' was successfully resolved to 'c:/root/generated/src/project/file2.ts'. ========",
"======== Resolving module 'module3' from 'c:/root/src/file1.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@ -74,6 +75,7 @@
"File 'c:/node_modules/module3.ts' does not exist.",
"File 'c:/node_modules/module3.tsx' does not exist.",
"File 'c:/node_modules/module3.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/node_modules/module3.d.ts', result 'c:/node_modules/module3.d.ts'",
"======== Module name 'module3' was successfully resolved to 'c:/node_modules/module3.d.ts'. ========",
"======== Resolving module 'module1' from 'c:/root/generated/src/project/file2.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@ -98,6 +100,7 @@
"File 'c:/shared/module1/index.ts' does not exist.",
"File 'c:/shared/module1/index.tsx' does not exist.",
"File 'c:/shared/module1/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/shared/module1/index.d.ts', result 'c:/shared/module1/index.d.ts'",
"======== Module name 'module1' was successfully resolved to 'c:/shared/module1/index.d.ts'. ========",
"======== Resolving module 'templates/module2' from 'c:/root/generated/src/project/file2.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@ -107,6 +110,7 @@
"Trying substitution 'generated/src/templates/*', candidate module location: 'generated/src/templates/module2'.",
"Loading module as file / folder, candidate module location 'c:/root/generated/src/templates/module2'.",
"File 'c:/root/generated/src/templates/module2.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/generated/src/templates/module2.ts', result 'c:/root/generated/src/templates/module2.ts'",
"======== Module name 'templates/module2' was successfully resolved to 'c:/root/generated/src/templates/module2.ts'. ========",
"======== Resolving module '../file3' from 'c:/root/generated/src/project/file2.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
@ -133,5 +137,6 @@
"File 'c:/root/src/file3/index.ts' does not exist.",
"File 'c:/root/src/file3/index.tsx' does not exist.",
"File 'c:/root/src/file3/index.d.ts' exist - use it as a name resolution result.",
"Resolving real path for 'c:/root/src/file3/index.d.ts', result 'c:/root/src/file3/index.d.ts'",
"======== Module name '../file3' was successfully resolved to 'c:/root/src/file3/index.d.ts'. ========"
]

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,69 @@
//// [typeGuardOfFormTypeOfIsOrderIndependent.ts]
var strOrNum: string | number;
var strOrBool: string | boolean;
var strOrFunc: string | (() => void);
var numOrBool: number | boolean
var str: string;
var num: number;
var bool: boolean;
var func: () => void;
if ("string" === typeof strOrNum) {
str = strOrNum;
}
else {
num = strOrNum;
}
if ("function" === typeof strOrFunc) {
func = strOrFunc;
}
else {
str = strOrFunc;
}
if ("number" === typeof numOrBool) {
num = numOrBool;
}
else {
bool = numOrBool;
}
if ("boolean" === typeof strOrBool) {
bool = strOrBool;
}
else {
str = strOrBool;
}
//// [typeGuardOfFormTypeOfIsOrderIndependent.js]
var strOrNum;
var strOrBool;
var strOrFunc;
var numOrBool;
var str;
var num;
var bool;
var func;
if ("string" === typeof strOrNum) {
str = strOrNum;
}
else {
num = strOrNum;
}
if ("function" === typeof strOrFunc) {
func = strOrFunc;
}
else {
str = strOrFunc;
}
if ("number" === typeof numOrBool) {
num = numOrBool;
}
else {
bool = numOrBool;
}
if ("boolean" === typeof strOrBool) {
bool = strOrBool;
}
else {
str = strOrBool;
}

View file

@ -0,0 +1,74 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfIsOrderIndependent.ts ===
var strOrNum: string | number;
>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 0, 3))
var strOrBool: string | boolean;
>strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 1, 3))
var strOrFunc: string | (() => void);
>strOrFunc : Symbol(strOrFunc, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 2, 3))
var numOrBool: number | boolean
>numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 3, 3))
var str: string;
>str : Symbol(str, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 4, 3))
var num: number;
>num : Symbol(num, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 5, 3))
var bool: boolean;
>bool : Symbol(bool, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 6, 3))
var func: () => void;
>func : Symbol(func, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 7, 3))
if ("string" === typeof strOrNum) {
>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 0, 3))
str = strOrNum;
>str : Symbol(str, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 4, 3))
>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 0, 3))
}
else {
num = strOrNum;
>num : Symbol(num, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 5, 3))
>strOrNum : Symbol(strOrNum, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 0, 3))
}
if ("function" === typeof strOrFunc) {
>strOrFunc : Symbol(strOrFunc, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 2, 3))
func = strOrFunc;
>func : Symbol(func, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 7, 3))
>strOrFunc : Symbol(strOrFunc, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 2, 3))
}
else {
str = strOrFunc;
>str : Symbol(str, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 4, 3))
>strOrFunc : Symbol(strOrFunc, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 2, 3))
}
if ("number" === typeof numOrBool) {
>numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 3, 3))
num = numOrBool;
>num : Symbol(num, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 5, 3))
>numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 3, 3))
}
else {
bool = numOrBool;
>bool : Symbol(bool, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 6, 3))
>numOrBool : Symbol(numOrBool, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 3, 3))
}
if ("boolean" === typeof strOrBool) {
>strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 1, 3))
bool = strOrBool;
>bool : Symbol(bool, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 6, 3))
>strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 1, 3))
}
else {
str = strOrBool;
>str : Symbol(str, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 4, 3))
>strOrBool : Symbol(strOrBool, Decl(typeGuardOfFormTypeOfIsOrderIndependent.ts, 1, 3))
}

View file

@ -0,0 +1,94 @@
=== tests/cases/conformance/expressions/typeGuards/typeGuardOfFormTypeOfIsOrderIndependent.ts ===
var strOrNum: string | number;
>strOrNum : string | number
var strOrBool: string | boolean;
>strOrBool : string | boolean
var strOrFunc: string | (() => void);
>strOrFunc : string | (() => void)
var numOrBool: number | boolean
>numOrBool : number | boolean
var str: string;
>str : string
var num: number;
>num : number
var bool: boolean;
>bool : boolean
var func: () => void;
>func : () => void
if ("string" === typeof strOrNum) {
>"string" === typeof strOrNum : boolean
>"string" : string
>typeof strOrNum : string
>strOrNum : string | number
str = strOrNum;
>str = strOrNum : string
>str : string
>strOrNum : string
}
else {
num = strOrNum;
>num = strOrNum : number
>num : number
>strOrNum : number
}
if ("function" === typeof strOrFunc) {
>"function" === typeof strOrFunc : boolean
>"function" : string
>typeof strOrFunc : string
>strOrFunc : string | (() => void)
func = strOrFunc;
>func = strOrFunc : () => void
>func : () => void
>strOrFunc : () => void
}
else {
str = strOrFunc;
>str = strOrFunc : string
>str : string
>strOrFunc : string
}
if ("number" === typeof numOrBool) {
>"number" === typeof numOrBool : boolean
>"number" : string
>typeof numOrBool : string
>numOrBool : number | boolean
num = numOrBool;
>num = numOrBool : number
>num : number
>numOrBool : number
}
else {
bool = numOrBool;
>bool = numOrBool : boolean
>bool : boolean
>numOrBool : boolean
}
if ("boolean" === typeof strOrBool) {
>"boolean" === typeof strOrBool : boolean
>"boolean" : string
>typeof strOrBool : string
>strOrBool : string | boolean
bool = strOrBool;
>bool = strOrBool : boolean
>bool : boolean
>strOrBool : boolean
}
else {
str = strOrBool;
>str = strOrBool : string
>str : string
>strOrBool : string
}

View file

@ -1,6 +1,11 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"

View file

@ -1,6 +1,6 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
@ -10,5 +10,11 @@
"File '/ref.ts' does not exist.",
"File '/ref.tsx' does not exist.",
"File '/ref.d.ts' exist - use it as a name resolution result.",
"======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========"
"Resolving real path for '/ref.d.ts', result '/ref.d.ts'",
"======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View file

@ -3,9 +3,10 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/mod1'.",
"File '/mod1.ts' exist - use it as a name resolution result.",
"Resolving real path for '/mod1.ts', result '/mod1.ts'",
"======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========",
"======== Resolving type reference directive 'lib', containing file not set, root directory '/'. ========",
"Resolving with primary search path '/types/'",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"

View file

@ -3,14 +3,16 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/main'.",
"File '/main.ts' exist - use it as a name resolution result.",
"Resolving real path for '/main.ts', result '/main.ts'",
"======== Module name './main' was successfully resolved to '/main.ts'. ========",
"======== Resolving module './mod1' from '/mod2.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/mod1'.",
"File '/mod1.ts' exist - use it as a name resolution result.",
"Resolving real path for '/mod1.ts', result '/mod1.ts'",
"======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/mod1.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"======== Resolving type reference directive 'lib', containing file '/mod1.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
@ -18,5 +20,11 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/main'.",
"File '/main.ts' exist - use it as a name resolution result.",
"======== Module name './main' was successfully resolved to '/main.ts'. ========"
"Resolving real path for '/main.ts', result '/main.ts'",
"======== Module name './main' was successfully resolved to '/main.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View file

@ -1,6 +1,6 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
@ -10,5 +10,11 @@
"File '/ref.ts' does not exist.",
"File '/ref.tsx' does not exist.",
"File '/ref.d.ts' exist - use it as a name resolution result.",
"======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========"
"Resolving real path for '/ref.d.ts', result '/ref.d.ts'",
"======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View file

@ -1,6 +1,6 @@
[
"======== Resolving type reference directive 'lib', containing file not set, root directory '/'. ========",
"Resolving with primary search path '/types/'",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"

View file

@ -1,6 +1,11 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"

View file

@ -1,6 +1,11 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"

View file

@ -1,6 +1,6 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
@ -10,5 +10,11 @@
"File '/ref.ts' does not exist.",
"File '/ref.tsx' does not exist.",
"File '/ref.d.ts' exist - use it as a name resolution result.",
"======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========"
"Resolving real path for '/ref.d.ts', result '/ref.d.ts'",
"======== Module name './ref' was successfully resolved to '/ref.d.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View file

@ -1,6 +1,11 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"

View file

@ -1,6 +1,11 @@
[
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"======== Resolving type reference directive 'lib', containing file '/app.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"

View file

@ -3,9 +3,10 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/mod1'.",
"File '/mod1.ts' exist - use it as a name resolution result.",
"Resolving real path for '/mod1.ts', result '/mod1.ts'",
"======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========",
"======== Resolving type reference directive 'lib', containing file not set, root directory '/'. ========",
"Resolving with primary search path '/types/'",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"

View file

@ -3,14 +3,16 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/main'.",
"File '/main.ts' exist - use it as a name resolution result.",
"Resolving real path for '/main.ts', result '/main.ts'",
"======== Module name './main' was successfully resolved to '/main.ts'. ========",
"======== Resolving module './mod1' from '/mod2.ts'. ========",
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/mod1'.",
"File '/mod1.ts' exist - use it as a name resolution result.",
"Resolving real path for '/mod1.ts', result '/mod1.ts'",
"======== Module name './mod1' was successfully resolved to '/mod1.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/mod1.ts', root directory '/'. ========",
"Resolving with primary search path '/types/'",
"======== Resolving type reference directive 'lib', containing file '/mod1.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========",
@ -18,5 +20,11 @@
"Module resolution kind is not specified, using 'NodeJs'.",
"Loading module as file / folder, candidate module location '/main'.",
"File '/main.ts' exist - use it as a name resolution result.",
"======== Module name './main' was successfully resolved to '/main.ts'. ========"
"Resolving real path for '/main.ts', result '/main.ts'",
"======== Module name './main' was successfully resolved to '/main.ts'. ========",
"======== Resolving type reference directive 'lib', containing file '/__inferred type names__.ts', root directory '/types'. ========",
"Resolving with primary search path '/types'",
"File '/types/lib/package.json' does not exist.",
"File '/types/lib/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'lib' was successfully resolved to '/types/lib/index.d.ts', primary: true. ========"
]

View file

@ -4,8 +4,10 @@
declare var $: { x: any };
//// [a.ts]
/// <reference types="jquery" />
$.x;
//// [a.js]
/// <reference types="jquery" />
$.x;

View file

@ -1,10 +1,11 @@
=== tests/cases/conformance/typings/a.ts ===
=== /a.ts ===
/// <reference types="jquery" />
$.x;
>$.x : Symbol(x, Decl(index.d.ts, 0, 16))
>$ : Symbol($, Decl(index.d.ts, 0, 11))
>x : Symbol(x, Decl(index.d.ts, 0, 16))
=== tests/cases/conformance/typings/node_modules/@types/jquery/index.d.ts ===
=== /node_modules/@types/jquery/index.d.ts ===
declare var $: { x: any };
>$ : Symbol($, Decl(index.d.ts, 0, 11))
>x : Symbol(x, Decl(index.d.ts, 0, 16))

View file

@ -0,0 +1,12 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========",
"======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========",
"Resolving with primary search path '/node_modules/@types'",
"File '/node_modules/@types/jquery/package.json' does not exist.",
"File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.",
"======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========"
]

View file

@ -1,10 +1,11 @@
=== tests/cases/conformance/typings/a.ts ===
=== /a.ts ===
/// <reference types="jquery" />
$.x;
>$.x : any
>$ : { x: any; }
>x : any
=== tests/cases/conformance/typings/node_modules/@types/jquery/index.d.ts ===
=== /node_modules/@types/jquery/index.d.ts ===
declare var $: { x: any };
>$ : { x: any; }
>x : any

View file

@ -1,6 +1,7 @@
// @outFile: concat.js
// @module: amd
// @moduleResolution: node
// @Filename: A:/bar.ts
import {z} from "./foo";
export var x = z + z;

View file

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

View file

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

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