Merge pull request #8670 from RyanCavanaugh/fix8275

Automatically consume @types/ folders
This commit is contained in:
Ryan Cavanaugh 2016-05-24 15:23:06 -07:00
commit 7173fa8d02
41 changed files with 408 additions and 467 deletions

View File

@ -1,294 +0,0 @@
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/// <reference no-default-lib="true"/>
/////////////////////////////
/// Windows Script Host APIS
/////////////////////////////
interface ActiveXObject {
new (s: string): any;
}
declare var ActiveXObject: ActiveXObject;
interface ITextWriter {
Write(s: string): void;
WriteLine(s: string): void;
Close(): void;
}
interface TextStreamBase {
/**
* The column number of the current character position in an input stream.
*/
Column: number;
/**
* The current line number in an input stream.
*/
Line: number;
/**
* Closes a text stream.
* It is not necessary to close standard streams; they close automatically when the process ends. If
* you close a standard stream, be aware that any other pointers to that standard stream become invalid.
*/
Close(): void;
}
interface TextStreamWriter extends TextStreamBase {
/**
* Sends a string to an output stream.
*/
Write(s: string): void;
/**
* Sends a specified number of blank lines (newline characters) to an output stream.
*/
WriteBlankLines(intLines: number): void;
/**
* Sends a string followed by a newline character to an output stream.
*/
WriteLine(s: string): void;
}
interface TextStreamReader extends TextStreamBase {
/**
* Returns a specified number of characters from an input stream, starting at the current pointer position.
* Does not return until the ENTER key is pressed.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
*/
Read(characters: number): string;
/**
* Returns all characters from an input stream.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
*/
ReadAll(): string;
/**
* Returns an entire line from an input stream.
* Although this method extracts the newline character, it does not add it to the returned string.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
*/
ReadLine(): string;
/**
* Skips a specified number of characters when reading from an input text stream.
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
* @param characters Positive number of characters to skip forward. (Backward skipping is not supported.)
*/
Skip(characters: number): void;
/**
* Skips the next line when reading from an input text stream.
* Can only be used on a stream in reading mode, not writing or appending mode.
*/
SkipLine(): void;
/**
* Indicates whether the stream pointer position is at the end of a line.
*/
AtEndOfLine: boolean;
/**
* Indicates whether the stream pointer position is at the end of a stream.
*/
AtEndOfStream: boolean;
}
declare var WScript: {
/**
* Outputs text to either a message box (under WScript.exe) or the command console window followed by
* a newline (under CScript.exe).
*/
Echo(s: any): void;
/**
* Exposes the write-only error output stream for the current script.
* Can be accessed only while using CScript.exe.
*/
StdErr: TextStreamWriter;
/**
* Exposes the write-only output stream for the current script.
* Can be accessed only while using CScript.exe.
*/
StdOut: TextStreamWriter;
Arguments: { length: number; Item(n: number): string; };
/**
* The full path of the currently running script.
*/
ScriptFullName: string;
/**
* Forces the script to stop immediately, with an optional exit code.
*/
Quit(exitCode?: number): number;
/**
* The Windows Script Host build version number.
*/
BuildVersion: number;
/**
* Fully qualified path of the host executable.
*/
FullName: string;
/**
* Gets/sets the script mode - interactive(true) or batch(false).
*/
Interactive: boolean;
/**
* The name of the host executable (WScript.exe or CScript.exe).
*/
Name: string;
/**
* Path of the directory containing the host executable.
*/
Path: string;
/**
* The filename of the currently running script.
*/
ScriptName: string;
/**
* Exposes the read-only input stream for the current script.
* Can be accessed only while using CScript.exe.
*/
StdIn: TextStreamReader;
/**
* Windows Script Host version
*/
Version: string;
/**
* Connects a COM object's event sources to functions named with a given prefix, in the form prefix_event.
*/
ConnectObject(objEventSource: any, strPrefix: string): void;
/**
* Creates a COM object.
* @param strProgiID
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
*/
CreateObject(strProgID: string, strPrefix?: string): any;
/**
* Disconnects a COM object from its event sources.
*/
DisconnectObject(obj: any): void;
/**
* Retrieves an existing object with the specified ProgID from memory, or creates a new one from a file.
* @param strPathname Fully qualified path to the file containing the object persisted to disk.
* For objects in memory, pass a zero-length string.
* @param strProgID
* @param strPrefix Function names in the form prefix_event will be bound to this object's COM events.
*/
GetObject(strPathname: string, strProgID?: string, strPrefix?: string): any;
/**
* Suspends script execution for a specified length of time, then continues execution.
* @param intTime Interval (in milliseconds) to suspend script execution.
*/
Sleep(intTime: number): void;
};
/**
* Allows enumerating over a COM collection, which may not have indexed item access.
*/
interface Enumerator<T> {
/**
* Returns true if the current item is the last one in the collection, or the collection is empty,
* or the current item is undefined.
*/
atEnd(): boolean;
/**
* Returns the current item in the collection
*/
item(): T;
/**
* Resets the current item in the collection to the first item. If there are no items in the collection,
* the current item is set to undefined.
*/
moveFirst(): void;
/**
* Moves the current item to the next item in the collection. If the enumerator is at the end of
* the collection or the collection is empty, the current item is set to undefined.
*/
moveNext(): void;
}
interface EnumeratorConstructor {
new <T>(collection: any): Enumerator<T>;
new (collection: any): Enumerator<any>;
}
declare var Enumerator: EnumeratorConstructor;
/**
* Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions.
*/
interface VBArray<T> {
/**
* Returns the number of dimensions (1-based).
*/
dimensions(): number;
/**
* Takes an index for each dimension in the array, and returns the item at the corresponding location.
*/
getItem(dimension1Index: number, ...dimensionNIndexes: number[]): T;
/**
* Returns the smallest available index for a given dimension.
* @param dimension 1-based dimension (defaults to 1)
*/
lbound(dimension?: number): number;
/**
* Returns the largest available index for a given dimension.
* @param dimension 1-based dimension (defaults to 1)
*/
ubound(dimension?: number): number;
/**
* Returns a Javascript array with all the elements in the VBArray. If there are multiple dimensions,
* each successive dimension is appended to the end of the array.
* Example: [[1,2,3],[4,5,6]] becomes [1,2,3,4,5,6]
*/
toArray(): T[];
}
interface VBArrayConstructor {
new <T>(safeArray: any): VBArray<T>;
new (safeArray: any): VBArray<any>;
}
declare var VBArray: VBArrayConstructor;

View File

@ -196,8 +196,8 @@ namespace ts {
traceEnabled
};
// use typesRoot and fallback to directory that contains tsconfig if typesRoot is not set
const rootDir = options.typesRoot || (options.configFilePath ? getDirectoryPath(options.configFilePath) : undefined);
// 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()));
if (traceEnabled) {
if (containingFile === undefined) {
@ -875,6 +875,19 @@ 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()));
}
@ -883,6 +896,7 @@ namespace ts {
const realpath = sys.realpath && ((path: string) => sys.realpath(path));
return {
getDefaultTypeDirectiveNames,
getSourceFile,
getDefaultLibLocation,
getDefaultLibFileName: options => combinePaths(getDefaultLibLocation(), getDefaultLibFileName(options)),
@ -958,6 +972,23 @@ namespace ts {
return resolutions;
}
export function getDefaultTypeDirectiveNames(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);
}
}
return undefined;
}
export function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program {
let program: Program;
let files: SourceFile[] = [];
@ -1005,15 +1036,18 @@ namespace ts {
const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap<SourceFile>(fileName => fileName.toLowerCase()) : undefined;
if (!tryReuseStructureFromOldProgram()) {
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));
// load type declarations specified via 'types' argument
if (options.types && options.types.length) {
const resolutions = resolveTypeReferenceDirectiveNamesWorker(options.types, /*containingFile*/ undefined);
for (let i = 0; i < options.types.length; i++) {
processTypeReferenceDirective(options.types[i], resolutions[i]);
const typeReferences: string[] = getDefaultTypeDirectiveNames(options, rootNames, host);
if (typeReferences) {
const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, /*containingFile*/ undefined);
for (let i = 0; i < typeReferences.length; i++) {
processTypeReferenceDirective(typeReferences[i], resolutions[i]);
}
}
forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false));
// Do not process the default library if:
// - The '--noLib' flag is used.
// - A 'no-default-lib' reference comment is encountered in
@ -1909,20 +1943,7 @@ namespace ts {
i < file.imports.length;
if (shouldAddFile) {
const importedFile = findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, /*isReference*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
if (importedFile && resolution.isExternalLibraryImport) {
// Since currently irrespective of allowJs, we only look for supportedTypeScript extension external module files,
// this check is ok. Otherwise this would be never true for javascript file
if (!isExternalModule(importedFile) && importedFile.statements.length) {
const start = getTokenPosOfNode(file.imports[i], file);
fileProcessingDiagnostics.add(createFileDiagnostic(file, start, file.imports[i].end - start, Diagnostics.Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition, importedFile.fileName));
}
else if (importedFile.referencedFiles.length) {
const firstRef = importedFile.referencedFiles[0];
fileProcessingDiagnostics.add(createFileDiagnostic(importedFile, firstRef.pos, firstRef.end - firstRef.pos, Diagnostics.Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition));
}
}
findSourceFile(resolution.resolvedFileName, toPath(resolution.resolvedFileName, currentDirectory, getCanonicalFileName), /*isDefaultLib*/ false, /*isReference*/ false, file, skipTrivia(file.text, file.imports[i].pos), file.imports[i].end);
}
}
}

View File

@ -24,6 +24,7 @@ namespace ts {
createDirectory(path: string): void;
getExecutingFilePath(): string;
getCurrentDirectory(): string;
getDirectories(path: string): string[];
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
getModifiedTime?(path: string): Date;
createHash?(data: string): string;
@ -71,6 +72,7 @@ namespace ts {
resolvePath(path: string): string;
readFile(path: string): string;
writeFile(path: string, contents: string): void;
getDirectories(path: string): string[];
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
watchFile?(path: string, callback: FileWatcherCallback): FileWatcher;
watchDirectory?(path: string, callback: DirectoryWatcherCallback, recursive?: boolean): FileWatcher;
@ -161,6 +163,11 @@ namespace ts {
return result.sort();
}
function getDirectories(path: string): string[] {
const folder = fso.GetFolder(path);
return getNames(folder.subfolders);
}
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
const result: string[] = [];
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
@ -214,6 +221,7 @@ namespace ts {
getCurrentDirectory() {
return new ActiveXObject("WScript.Shell").CurrentDirectory;
},
getDirectories,
readDirectory,
exit(exitCode?: number): void {
try {
@ -402,6 +410,10 @@ namespace ts {
return fileSystemEntryExists(path, FileSystemEntryKind.Directory);
}
function getDirectories(path: string): string[] {
return filter<string>(_fs.readdirSync(path), p => fileSystemEntryExists(combinePaths(path, p), FileSystemEntryKind.Directory));
}
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
const result: string[] = [];
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
@ -507,6 +519,7 @@ namespace ts {
getCurrentDirectory() {
return process.cwd();
},
getDirectories,
readDirectory,
getModifiedTime(path) {
try {
@ -561,6 +574,7 @@ namespace ts {
createDirectory: ChakraHost.createDirectory,
getExecutingFilePath: () => ChakraHost.executingFile,
getCurrentDirectory: () => ChakraHost.currentDirectory,
getDirectories: ChakraHost.getDirectories,
readDirectory: ChakraHost.readDirectory,
exit: ChakraHost.quit,
realpath

View File

@ -2786,6 +2786,7 @@ namespace ts {
trace?(s: string): void;
directoryExists?(directoryName: string): boolean;
realpath?(path: string): string;
getCurrentDirectory?(): string;
}
export interface ResolvedModule {
@ -2822,6 +2823,7 @@ namespace ts {
getCancellationToken?(): CancellationToken;
getDefaultLibFileName(options: CompilerOptions): string;
getDefaultLibLocation?(): string;
getDefaultTypeDirectiveNames?(rootPath: string): string[];
writeFile: WriteFileCallback;
getCurrentDirectory(): string;
getCanonicalFileName(fileName: string): string;

View File

@ -107,7 +107,7 @@ class CompilerBaselineRunner extends RunnerBase {
}
const output = Harness.Compiler.compileFiles(
toBeCompiled, otherFiles, harnessSettings, /*options*/ tsConfigOptions, /*currentDirectory*/ undefined);
toBeCompiled, otherFiles, harnessSettings, /*options*/ tsConfigOptions, /*currentDirectory*/ harnessSettings["currentDirectory"]);
options = output.options;
result = output.result;

View File

@ -127,7 +127,7 @@ namespace Utils {
export function memoize<T extends Function>(f: T): T {
const cache: { [idx: string]: any } = {};
return <any>(function () {
return <any>(function() {
const key = Array.prototype.join.call(arguments);
const cachedResult = cache[key];
if (cachedResult) {
@ -609,7 +609,7 @@ namespace Harness {
export const getCurrentDirectory = () => "";
export const args = () => <string[]>[];
export const getExecutingFilePath = () => "";
export const exit = (exitCode: number) => {};
export const exit = (exitCode: number) => { };
export let log = (s: string) => console.log(s);
@ -826,7 +826,7 @@ namespace Harness {
}
if (!libFileNameSourceFileMap[fileName]) {
libFileNameSourceFileMap[fileName] = createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest);
libFileNameSourceFileMap[fileName] = createSourceFileAndAssertInvariants(fileName, IO.readFile(libFolder + fileName), ts.ScriptTarget.Latest);
}
return libFileNameSourceFileMap[fileName];
}
@ -900,6 +900,20 @@ 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,
@ -939,6 +953,7 @@ namespace Harness {
{ name: "noErrorTruncation", type: "boolean" },
{ name: "suppressOutputPathCheck", type: "boolean" },
{ name: "noImplicitReferences", type: "boolean" },
{ name: "currentDirectory", type: "string" },
{ name: "symlink", type: "string" }
];
@ -1441,12 +1456,12 @@ namespace Harness {
if (currentFileName) {
// Store result file
const newTestFile = {
content: currentFileContent,
name: currentFileName,
fileOptions: currentFileOptions,
originalFilePath: fileName,
references: refs
};
content: currentFileContent,
name: currentFileName,
fileOptions: currentFileOptions,
originalFilePath: fileName,
references: refs
};
testUnitData.push(newTestFile);
// Reset local data
@ -1544,10 +1559,10 @@ namespace Harness {
function baselinePath(fileName: string, type: string, baselineFolder: string, subfolder?: string) {
if (subfolder !== undefined) {
return Harness.userSpecifiedRoot + baselineFolder + "/" + subfolder + "/" + type + "/" + fileName;
return Harness.userSpecifiedRoot + baselineFolder + "/" + subfolder + "/" + type + "/" + fileName;
}
else {
return Harness.userSpecifiedRoot + baselineFolder + "/" + type + "/" + fileName;
return Harness.userSpecifiedRoot + baselineFolder + "/" + type + "/" + fileName;
}
}
@ -1616,7 +1631,7 @@ namespace Harness {
}
function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) {
const encoded_actual = Utils.encodeString(actual);
const encoded_actual = Utils.encodeString(actual);
if (expected != encoded_actual) {
// Overwrite & issue error
const errMsg = "The baseline file " + relativeFileName + " has changed.";

View File

@ -182,6 +182,7 @@ namespace Harness.LanguageService {
class NativeLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceHost {
getCompilationSettings() { return this.settings; }
getCancellationToken() { return this.cancellationToken; }
getDirectories(path: string): string[] { return []; }
getCurrentDirectory(): string { return ""; }
getDefaultLibFileName(): string { return Harness.Compiler.defaultLibFileName; }
getScriptFileNames(): string[] { return this.getFilenames(); }
@ -268,6 +269,7 @@ namespace Harness.LanguageService {
getCompilationSettings(): string { return JSON.stringify(this.nativeHost.getCompilationSettings()); }
getCancellationToken(): ts.HostCancellationToken { return this.nativeHost.getCancellationToken(); }
getCurrentDirectory(): string { return this.nativeHost.getCurrentDirectory(); }
getDirectories(path: string) { return this.nativeHost.getDirectories(path); }
getDefaultLibFileName(): string { return this.nativeHost.getDefaultLibFileName(); }
getScriptFileNames(): string { return JSON.stringify(this.nativeHost.getScriptFileNames()); }
getScriptSnapshot(fileName: string): ts.ScriptSnapshotShim {
@ -600,6 +602,10 @@ namespace Harness.LanguageService {
return this.host.getCurrentDirectory();
}
getDirectories(path: string): string[] {
return [];
}
readDirectory(path: string, extension?: string): string[] {
throw new Error("Not implemented Yet.");
}

View File

@ -61,6 +61,7 @@ namespace ts {
getLocalizedDiagnosticMessages(): string;
getCancellationToken(): HostCancellationToken;
getCurrentDirectory(): string;
getDirectories(path: string): string[];
getDefaultLibFileName(options: string): string;
getNewLine?(): string;
getProjectVersion?(): string;
@ -400,6 +401,10 @@ namespace ts {
return this.shimHost.getCurrentDirectory();
}
public getDirectories(path: string): string[] {
return this.shimHost.getDirectories(path);
}
public getDefaultLibFileName(options: CompilerOptions): string {
return this.shimHost.getDefaultLibFileName(JSON.stringify(options));
}

View File

@ -1,19 +0,0 @@
tests/cases/compiler/moduleA/a.js(2,17): error TS2656: Exported external package typings file 'tests/cases/compiler/node_modules/b.ts' is not a module. Please contact the package author to update the package definition.
==== tests/cases/compiler/moduleA/a.js (1 errors) ====
import {a} from "b";
~~~
!!! error TS2656: Exported external package typings file 'b.ts' is not a module. Please contact the package author to update the package definition.
a++;
import {c} from "c";
c++;
==== tests/cases/compiler/node_modules/b.ts (0 errors) ====
var a = 10;
==== tests/cases/compiler/node_modules/c.js (0 errors) ====
exports.a = 10;
c = 10;

View File

@ -0,0 +1,25 @@
=== tests/cases/compiler/moduleA/a.js ===
import {a} from "b";
>a : Symbol(a, Decl(a.js, 1, 8))
a++;
>a : Symbol(a, Decl(a.js, 1, 8))
import {c} from "c";
>c : Symbol(c, Decl(a.js, 3, 8))
c++;
>c : Symbol(c, Decl(a.js, 3, 8))
=== tests/cases/compiler/node_modules/b.ts ===
var a = 10;
>a : Symbol(a, Decl(b.ts, 0, 3))
=== tests/cases/compiler/node_modules/c.js ===
exports.a = 10;
>exports : Symbol(a, Decl(c.js, 0, 0))
>a : Symbol(a, Decl(c.js, 0, 0))
c = 10;

View File

@ -0,0 +1,34 @@
=== tests/cases/compiler/moduleA/a.js ===
import {a} from "b";
>a : any
a++;
>a++ : number
>a : any
import {c} from "c";
>c : any
c++;
>c++ : number
>c : any
=== tests/cases/compiler/node_modules/b.ts ===
var a = 10;
>a : number
>10 : number
=== tests/cases/compiler/node_modules/c.js ===
exports.a = 10;
>exports.a = 10 : number
>exports.a : any
>exports : any
>a : any
>10 : number
c = 10;
>c = 10 : number
>c : any
>10 : number

View File

@ -1,6 +1,14 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"======== 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/'",
"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'",
"File '/a/b/node_modules/jquery.ts' does not exist.",
"File '/a/b/node_modules/jquery.d.ts' does not exist.",

View File

@ -1,6 +1,14 @@
[
"======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"======== 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/'",
"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'",
"File '/a/b/node_modules/jquery.ts' does not exist.",
"File '/a/b/node_modules/jquery.d.ts' does not exist.",

View File

@ -1,5 +1,24 @@
[
"======== Resolving type reference directive 'jquery', containing file not set, root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder."
"======== 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. ========"
]

View File

@ -1,44 +1,30 @@
[
"======== Resolving type reference directive 'foo', containing file '/src/root.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"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.",
"======== 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/'",
"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: false. ========",
"======== Resolving type reference directive 'bar', containing file '/src/root.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"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.",
"======== 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/'",
"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: false. ========",
"======== Resolving type reference directive 'alpha', containing file '/node_modules/foo/index.d.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"======== 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.",
"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.",
@ -46,8 +32,16 @@
"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 not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"======== 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.",
"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,6 +1,14 @@
[
"======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========",
"Root directory cannot be determined, skipping primary search paths.",
"======== 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/'",
"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'",
"File '/src/node_modules/jquery.ts' does not exist.",
"File '/src/node_modules/jquery.d.ts' does not exist.",

View File

@ -1,14 +0,0 @@
tests/cases/compiler/b.ts(1,20): error TS2656: Exported external package typings file 'tests/cases/compiler/node_modules/a.d.ts' is not a module. Please contact the package author to update the package definition.
==== tests/cases/compiler/b.ts (1 errors) ====
import y = require("a");
~~~
!!! error TS2656: Exported external package typings file 'a.d.ts' is not a module. Please contact the package author to update the package definition.
==== tests/cases/compiler/node_modules/a.d.ts (0 errors) ====
declare module "a" {
var x: number;
}

View File

@ -0,0 +1,11 @@
=== tests/cases/compiler/b.ts ===
import y = require("a");
>y : Symbol(y, Decl(b.ts, 0, 0))
=== tests/cases/compiler/node_modules/a.d.ts ===
declare module "a" {
var x: number;
>x : Symbol(x, Decl(a.d.ts, 2, 7))
}

View File

@ -0,0 +1,11 @@
=== tests/cases/compiler/b.ts ===
import y = require("a");
>y : typeof y
=== tests/cases/compiler/node_modules/a.d.ts ===
declare module "a" {
var x: number;
>x : number
}

View File

@ -1,17 +0,0 @@
tests/cases/compiler/node_modules/a.d.ts(1,1): error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.
==== tests/cases/compiler/b.ts (0 errors) ====
import y = require("a");
==== tests/cases/compiler/node_modules/ref.ts (0 errors) ====
var x = 1;
==== tests/cases/compiler/node_modules/a.d.ts (1 errors) ====
/// <reference path="ref.ts"/>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.
export declare var y;

View File

@ -0,0 +1,15 @@
=== tests/cases/compiler/b.ts ===
import y = require("a");
>y : Symbol(y, Decl(b.ts, 0, 0))
=== tests/cases/compiler/node_modules/ref.ts ===
var x = 1;
>x : Symbol(x, Decl(ref.ts, 1, 3))
=== tests/cases/compiler/node_modules/a.d.ts ===
/// <reference path="ref.ts"/>
export declare var y;
>y : Symbol(y, Decl(a.d.ts, 1, 18))

View File

@ -0,0 +1,16 @@
=== tests/cases/compiler/b.ts ===
import y = require("a");
>y : typeof y
=== tests/cases/compiler/node_modules/ref.ts ===
var x = 1;
>x : number
>1 : number
=== tests/cases/compiler/node_modules/a.d.ts ===
/// <reference path="ref.ts"/>
export declare var y;
>y : any

View File

@ -1,14 +0,0 @@
tests/cases/compiler/b.ts(1,20): error TS2656: Exported external package typings file 'tests/cases/compiler/node_modules/a/index.d.ts' is not a module. Please contact the package author to update the package definition.
==== tests/cases/compiler/b.ts (1 errors) ====
import y = require("a");
~~~
!!! error TS2656: Exported external package typings file 'index.d.ts' is not a module. Please contact the package author to update the package definition.
==== tests/cases/compiler/node_modules/a/index.d.ts (0 errors) ====
declare module "a" {
var x: number;
}

View File

@ -0,0 +1,11 @@
=== tests/cases/compiler/b.ts ===
import y = require("a");
>y : Symbol(y, Decl(b.ts, 0, 0))
=== tests/cases/compiler/node_modules/a/index.d.ts ===
declare module "a" {
var x: number;
>x : Symbol(x, Decl(index.d.ts, 2, 7))
}

View File

@ -0,0 +1,11 @@
=== tests/cases/compiler/b.ts ===
import y = require("a");
>y : typeof y
=== tests/cases/compiler/node_modules/a/index.d.ts ===
declare module "a" {
var x: number;
>x : number
}

View File

@ -1,16 +0,0 @@
tests/cases/compiler/node_modules/a/index.d.ts(1,1): error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.
==== tests/cases/compiler/b.ts (0 errors) ====
import y = require("a");
==== tests/cases/compiler/node_modules/a/ref.ts (0 errors) ====
var x = 1;
==== tests/cases/compiler/node_modules/a/index.d.ts (1 errors) ====
/// <reference path="ref.ts"/>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.
export declare var y;

View File

@ -0,0 +1,15 @@
=== tests/cases/compiler/b.ts ===
import y = require("a");
>y : Symbol(y, Decl(b.ts, 0, 0))
=== tests/cases/compiler/node_modules/a/ref.ts ===
var x = 1;
>x : Symbol(x, Decl(ref.ts, 1, 3))
=== tests/cases/compiler/node_modules/a/index.d.ts ===
/// <reference path="ref.ts"/>
export declare var y;
>y : Symbol(y, Decl(index.d.ts, 1, 18))

View File

@ -0,0 +1,16 @@
=== tests/cases/compiler/b.ts ===
import y = require("a");
>y : typeof y
=== tests/cases/compiler/node_modules/a/ref.ts ===
var x = 1;
>x : number
>1 : number
=== tests/cases/compiler/node_modules/a/index.d.ts ===
/// <reference path="ref.ts"/>
export declare var y;
>y : any

View File

@ -1,12 +1,12 @@
[
"======== Resolving type reference directive 'lib', containing file not set, root directory '/'. ========",
"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 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.",
"======== Module name './mod1' was successfully resolved to '/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/'",
"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,12 +1,12 @@
[
"======== Resolving type reference directive 'lib', containing file not set, root directory '/'. ========",
"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 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.",
"======== Module name './mod1' was successfully resolved to '/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/'",
"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

@ -0,0 +1,11 @@
//// [tests/cases/conformance/typings/typingsLookup1.ts] ////
//// [index.d.ts]
declare var $: { x: any };
//// [a.ts]
$.x;
//// [a.js]
$.x;

View File

@ -0,0 +1,11 @@
=== tests/cases/conformance/typings/a.ts ===
$.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 ===
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,11 @@
=== tests/cases/conformance/typings/a.ts ===
$.x;
>$.x : any
>$ : { x: any; }
>x : any
=== tests/cases/conformance/typings/node_modules/@types/jquery/index.d.ts ===
declare var $: { x: any };
>$ : { x: any; }
>x : any

View File

@ -1,5 +1,6 @@
// @noImplicitReferences: true
// @traceResolution: true
// @currentDirectory: /
// package.json in a secondary reference can refer to another file

View File

@ -1,5 +1,6 @@
// @noImplicitReferences: true
// @traceResolution: true
// @currentDirectory: /
// package.json in a secondary reference can refer to another file

View File

@ -1,6 +1,7 @@
// @noImplicitReferences: true
// @traceResolution: true
// @types: jquery
// @currentDirectory: /
// @filename: /a/types/jquery/index.d.ts
declare var $: { foo(): void };

View File

@ -1,5 +1,6 @@
// @noImplicitReferences: true
// @traceResolution: true
// @currentDirectory: /
// Secondary references may not be duplicated if they disagree in content

View File

@ -1,5 +1,6 @@
// @noImplicitReferences: true
// @traceResolution: true
// @currentDirectory: /
// Secondary references are possible

View File

@ -0,0 +1,10 @@
// @noImplicitReferences: true
// @filename: tsconfig.json
{ "files": "a.ts" }
// @filename: node_modules/@types/jquery/index.d.ts
declare var $: { x: any };
// @filename: a.ts
$.x;

View File

@ -46,6 +46,7 @@ namespace ts {
getCurrentDirectory: (): string => {
return "";
},
getDirectories: (path: string) => [],
readDirectory: (path: string, extension?: string, exclude?: string[]): string[] => {
throw new Error("NYI");
},

View File

@ -14,6 +14,7 @@ namespace ts.server {
resolvePath(): string { return void 0; },
fileExists: () => false,
directoryExists: () => false,
getDirectories: () => [],
createDirectory(): void {},
getExecutingFilePath(): string { return void 0; },
getCurrentDirectory(): string { return void 0; },