diff --git a/.mailmap b/.mailmap index b246515e467..bc99382425f 100644 --- a/.mailmap +++ b/.mailmap @@ -291,14 +291,13 @@ Zeeshan Ahmed Orta # Orta Therox IdeaHunter # @IdeaHunter kujon # Jakub Korzeniowski -Matt @begincalendar +Matt # @begincalendar meyer # @meyer micbou # @micbou Alan Agius Alex Khomchenko Oussama Ben Brahim benbraou Cameron Taggart -csigs csigs Eugene Timokhov Kris Zyp Jing Ma @@ -312,4 +311,9 @@ Stanislav Iliev Wenlu Wang <805037171@163.com> wenlu.wang <805037171@163.com> kingwl <805037171@163.com> Wilson Hobbs Yuval Greenfield -Daniel # @nieltg \ No newline at end of file +Daniel # @nieltg +Adnan Chowdhury +Esakki Raj +Jack Williams +Philippe Voinov +Stephan Ginthör <26004708+Lazarus535@users.noreply.github.com> \ No newline at end of file diff --git a/AUTHORS.md b/AUTHORS.md index 7662a5642e7..839971f37eb 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -3,6 +3,7 @@ TypeScript is authored by: * Abubaker Bashir * Adam Freidin * Adi Dahiya +* Adnan Chowdhury * Adrian Leonhard * Ahmad Farid * Akshar Patel @@ -36,6 +37,7 @@ TypeScript is authored by: * Asad Saeeduddin * Avery Morin * Basarat Ali Syed +* @begincalendar * Ben Duffield * Ben Mosher * Benjamin Bock @@ -59,7 +61,6 @@ TypeScript is authored by: * Colby Russell * Colin Snover * Cotton Hou -* csigs * Cyrus Najmabadi * Dafrok Zhang * Dahan Gong @@ -87,6 +88,7 @@ TypeScript is authored by: * Eric Tsang * Erik Edrosa * Erik McClenney +* Esakki Raj * Ethan Resnick * Ethan Rubio * Eugene Timokhov @@ -124,6 +126,7 @@ TypeScript is authored by: * Ivan Enderlin * Ivo Gabe de Wolff * Iwata Hidetaka +* Jack Williams * Jakub Korzeniowski * Jakub Młokosiewicz * James Henry @@ -182,7 +185,6 @@ TypeScript is authored by: * Martin Hiller * Martin Vseticka * Masahiro Wakame -* Matt * Matt Bierner * Matt McCutchen * Matt Mitchell @@ -224,6 +226,7 @@ TypeScript is authored by: * Perry Jiang * Peter Burns * Philip Bulley +* Philippe Voinov * Piero Cangianiello * @piloopin * Prayag Verma @@ -261,6 +264,7 @@ TypeScript is authored by: * Stanislav Iliev * Stanislav Sysoev * Stas Vilchik +* Stephan Ginthör * Steve Lucco * Sudheesh Singanamalla * Sébastien Arod diff --git a/Gulpfile.ts b/Gulpfile.ts index bc5eb3a2d38..dc2766e3ade 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -1151,7 +1151,7 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: const fileMatcher = cmdLineOptions.files; const files = fileMatcher ? `src/**/${fileMatcher}` - : "Gulpfile.ts 'scripts/generateLocalizedDiagnosticMessages.ts' 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude 'src/lib/*.d.ts'"; + : `Gulpfile.ts "scripts/generateLocalizedDiagnosticMessages.ts" "scripts/tslint/**/*.ts" "src/**/*.ts" --exclude "src/lib/*.d.ts"`; const cmd = `node node_modules/tslint/bin/tslint ${files} --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish`; console.log("Linting: " + cmd); child_process.execSync(cmd, { stdio: [0, 1, 2] }); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ba3c3e6b83c..16b2091733a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8330,11 +8330,18 @@ namespace ts { function instantiateList(items: T[], mapper: TypeMapper, instantiator: (item: T, mapper: TypeMapper) => T): T[] { if (items && items.length) { - const result: T[] = []; - for (const v of items) { - result.push(instantiator(v, mapper)); + for (let i = 0; i < items.length; i++) { + const item = items[i]; + const mapped = instantiator(item, mapper); + if (item !== mapped) { + const result = i === 0 ? [] : items.slice(0, i); + result.push(mapped); + for (i++; i < items.length; i++) { + result.push(instantiator(items[i], mapper)); + } + return result; + } } - return result; } return items; } @@ -8456,8 +8463,13 @@ namespace ts { } function instantiateSymbol(symbol: Symbol, mapper: TypeMapper): Symbol { + const links = getSymbolLinks(symbol); + if (links.type && !maybeTypeOfKind(links.type, TypeFlags.Object | TypeFlags.TypeVariable | TypeFlags.Index)) { + // If the type of the symbol is already resolved, and if that type could not possibly + // be affected by instantiation, simply return the symbol itself. + return symbol; + } if (getCheckFlags(symbol) & CheckFlags.Instantiated) { - const links = getSymbolLinks(symbol); // If symbol being instantiated is itself a instantiation, fetch the original target and combine the // type mappers. This ensures that original type identities are properly preserved and that aliases // always reference a non-aliases. @@ -8600,14 +8612,20 @@ namespace ts { return getAnonymousTypeInstantiation(type, mapper); } if ((type).objectFlags & ObjectFlags.Reference) { - return createTypeReference((type).target, instantiateTypes((type).typeArguments, mapper)); + const typeArguments = (type).typeArguments; + const newTypeArguments = instantiateTypes(typeArguments, mapper); + return newTypeArguments !== typeArguments ? createTypeReference((type).target, newTypeArguments) : type; } } if (type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Primitive)) { - return getUnionType(instantiateTypes((type).types, mapper), UnionReduction.Literal, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + const types = (type).types; + const newTypes = instantiateTypes(types, mapper); + return newTypes !== types ? getUnionType(newTypes, UnionReduction.Literal, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } if (type.flags & TypeFlags.Intersection) { - return getIntersectionType(instantiateTypes((type).types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + const types = (type).types; + const newTypes = instantiateTypes(types, mapper); + return newTypes !== types ? getIntersectionType(newTypes, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)) : type; } if (type.flags & TypeFlags.Index) { return getIndexType(instantiateType((type).type, mapper)); @@ -20255,6 +20273,8 @@ namespace ts { case SyntaxKind.ClassDeclaration: case SyntaxKind.EnumDeclaration: return DeclarationSpaces.ExportType | DeclarationSpaces.ExportValue; + case SyntaxKind.SourceFile: + return DeclarationSpaces.ExportType | DeclarationSpaces.ExportValue | DeclarationSpaces.ExportNamespace; // The below options all declare an Alias, which is allowed to merge with other values within the importing module case SyntaxKind.ImportEqualsDeclaration: case SyntaxKind.NamespaceImport: diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 9c30cb87a4d..b254bfc1031 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1425,9 +1425,9 @@ namespace ts { } function directoryOfCombinedPath(fileName: string, basePath: string) { - // Use the `identity` function to avoid canonicalizing the path, as it must remain noncanonical + // Use the `getNormalizedAbsolutePath` function to avoid canonicalizing the path, as it must remain noncanonical // until consistient casing errors are reported - return getDirectoryPath(toPath(fileName, basePath, identity)); + return getDirectoryPath(getNormalizedAbsolutePath(fileName, basePath)); } /** @@ -1452,8 +1452,7 @@ namespace ts { Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined)); const errors: Diagnostic[] = []; - const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames); - const parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, getCanonicalFileName, resolutionStack, errors); + const parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors); const { raw } = parsedConfig; const options = extend(existingOptions, parsedConfig.options || {}); options.configFilePath = configFileName; @@ -1547,7 +1546,10 @@ namespace ts { raw: any; options?: CompilerOptions; typeAcquisition?: TypeAcquisition; - extendedConfigPath?: Path; + /** + * Note that the case of the config path has not yet been normalized, as no files have been imported into the project yet + */ + extendedConfigPath?: string; } function isSuccessfulParsedTsconfig(value: ParsedTsconfig) { @@ -1564,12 +1566,11 @@ namespace ts { host: ParseConfigHost, basePath: string, configFileName: string, - getCanonicalFileName: GetCanonicalFileName, - resolutionStack: Path[], + resolutionStack: string[], errors: Push, ): ParsedTsconfig { basePath = normalizeSlashes(basePath); - const resolvedPath = toPath(configFileName || "", basePath, getCanonicalFileName); + const resolvedPath = getNormalizedAbsolutePath(configFileName || "", basePath); if (resolutionStack.indexOf(resolvedPath) >= 0) { errors.push(createCompilerDiagnostic(Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, [...resolutionStack, resolvedPath].join(" -> "))); @@ -1577,14 +1578,13 @@ namespace ts { } const ownConfig = json ? - parseOwnConfigOfJson(json, host, basePath, getCanonicalFileName, configFileName, errors) : - parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, getCanonicalFileName, configFileName, errors); + parseOwnConfigOfJson(json, host, basePath, configFileName, errors) : + parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors); if (ownConfig.extendedConfigPath) { // copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios. resolutionStack = resolutionStack.concat([resolvedPath]); - const extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, getCanonicalFileName, - resolutionStack, errors); + const extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, basePath, resolutionStack, errors); if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) { const baseRaw = extendedConfig.raw; const raw = ownConfig.raw; @@ -1612,7 +1612,6 @@ namespace ts { json: any, host: ParseConfigHost, basePath: string, - getCanonicalFileName: GetCanonicalFileName, configFileName: string | undefined, errors: Push ): ParsedTsconfig { @@ -1625,7 +1624,7 @@ namespace ts { // It should be removed in future releases - use typeAcquisition instead. const typeAcquisition = convertTypeAcquisitionFromJsonWorker(json.typeAcquisition || json.typingOptions, basePath, errors, configFileName); json.compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); - let extendedConfigPath: Path; + let extendedConfigPath: string; if (json.extends) { if (!isString(json.extends)) { @@ -1633,7 +1632,7 @@ namespace ts { } else { const newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; - extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, getCanonicalFileName, errors, createCompilerDiagnostic); + extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, errors, createCompilerDiagnostic); } } return { raw: json, options, typeAcquisition, extendedConfigPath }; @@ -1643,13 +1642,12 @@ namespace ts { sourceFile: JsonSourceFile, host: ParseConfigHost, basePath: string, - getCanonicalFileName: GetCanonicalFileName, configFileName: string | undefined, errors: Push ): ParsedTsconfig { const options = getDefaultCompilerOptions(configFileName); let typeAcquisition: TypeAcquisition, typingOptionstypeAcquisition: TypeAcquisition; - let extendedConfigPath: Path; + let extendedConfigPath: string; const optionsIterator: JsonConversionNotifier = { onSetValidOptionKeyValueInParent(parentOption: string, option: CommandLineOption, value: CompilerOptionsValue) { @@ -1670,7 +1668,6 @@ namespace ts { value, host, newBase, - getCanonicalFileName, errors, (message, arg0) => createDiagnosticForNodeInSourceFile(sourceFile, valueNode, message, arg0) @@ -1712,7 +1709,6 @@ namespace ts { extendedConfig: string, host: ParseConfigHost, basePath: string, - getCanonicalFileName: GetCanonicalFileName, errors: Push, createDiagnostic: (message: DiagnosticMessage, arg1?: string) => Diagnostic) { extendedConfig = normalizeSlashes(extendedConfig); @@ -1721,9 +1717,9 @@ namespace ts { errors.push(createDiagnostic(Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig)); return undefined; } - let extendedConfigPath = toPath(extendedConfig, basePath, getCanonicalFileName); + let extendedConfigPath = getNormalizedAbsolutePath(extendedConfig, basePath); if (!host.fileExists(extendedConfigPath) && !endsWith(extendedConfigPath, Extension.Json)) { - extendedConfigPath = `${extendedConfigPath}.json` as Path; + extendedConfigPath = `${extendedConfigPath}.json`; if (!host.fileExists(extendedConfigPath)) { errors.push(createDiagnostic(Diagnostics.File_0_does_not_exist, extendedConfig)); return undefined; @@ -1734,11 +1730,10 @@ namespace ts { function getExtendedConfig( sourceFile: JsonSourceFile, - extendedConfigPath: Path, + extendedConfigPath: string, host: ts.ParseConfigHost, basePath: string, - getCanonicalFileName: GetCanonicalFileName, - resolutionStack: Path[], + resolutionStack: string[], errors: Push, ): ParsedTsconfig | undefined { const extendedResult = readJsonConfigFile(extendedConfigPath, path => host.readFile(path)); @@ -1752,14 +1747,14 @@ namespace ts { const extendedDirname = getDirectoryPath(extendedConfigPath); const extendedConfig = parseConfig(/*json*/ undefined, extendedResult, host, extendedDirname, - getBaseFileName(extendedConfigPath), getCanonicalFileName, resolutionStack, errors); + getBaseFileName(extendedConfigPath), resolutionStack, errors); if (sourceFile) { sourceFile.extendedSourceFiles.push(...extendedResult.extendedSourceFiles); } if (isSuccessfulParsedTsconfig(extendedConfig)) { // Update the paths to reflect base path - const relativeDifference = convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); + const relativeDifference = convertToRelativePath(extendedDirname, basePath, identity); const updatePath = (path: string) => isRootedDiskPath(path) ? path : combinePaths(relativeDifference, path); const mapPropertiesInRawIfNotUndefined = (propertyName: string) => { if (raw[propertyName]) { diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index f72876bd5fc..50181bb98e4 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -801,7 +801,7 @@ namespace ts { } const resolvedFromFile = loadModuleFromFile(extensions, candidate, failedLookupLocations, onlyRecordFailures, state); if (resolvedFromFile) { - const nm = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile.path) : undefined; + const nm = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined; const packageId = nm && getPackageJsonInfo(nm.packageDirectory, nm.subModuleName, failedLookupLocations, /*onlyRecordFailures*/ false, state).packageId; return withPackageId(packageId, resolvedFromFile); } @@ -826,12 +826,13 @@ namespace ts { * * packageDirectory is the directory of the package itself. * subModuleName is the path within the package. - * For `blah/node_modules/foo/index.d.ts` this is { packageDirectory: "foo", subModuleName: "" }. (Part before "/node_modules/" is ignored.) - * For `/node_modules/foo/bar.d.ts` this is { packageDirectory: "foo", subModuleName": "bar" }. - * For `/node_modules/@types/foo/bar/index.d.ts` this is { packageDirectory: "@types/foo", subModuleName: "bar" }. + * For `blah/node_modules/foo/index.d.ts` this is { packageDirectory: "foo", subModuleName: "index.d.ts" }. (Part before "/node_modules/" is ignored.) + * For `/node_modules/foo/bar.d.ts` this is { packageDirectory: "foo", subModuleName": "bar/index.d.ts" }. + * For `/node_modules/@types/foo/bar/index.d.ts` this is { packageDirectory: "@types/foo", subModuleName: "bar/index.d.ts" }. + * For `/node_modules/foo/bar/index.d.ts` this is { packageDirectory: "foo", subModuleName": "bar/index.d.ts" }. */ - function parseNodeModuleFromPath(path: string): { packageDirectory: string, subModuleName: string } | undefined { - path = normalizePath(path); + function parseNodeModuleFromPath(resolved: PathAndExtension): { packageDirectory: string, subModuleName: string } | undefined { + const path = normalizePath(resolved.path); const idx = path.lastIndexOf(nodeModulesPathPart); if (idx === -1) { return undefined; @@ -843,7 +844,7 @@ namespace ts { indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName); } const packageDirectory = path.slice(0, indexAfterPackageName); - const subModuleName = removeExtensionAndIndex(path.slice(indexAfterPackageName + 1)); + const subModuleName = removeExtension(path.slice(indexAfterPackageName + 1), resolved.ext) + Extension.Dts; return { packageDirectory, subModuleName }; } @@ -852,9 +853,17 @@ namespace ts { return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex; } - function removeExtensionAndIndex(path: string): string { - const noExtension = removeFileExtension(path); - return noExtension === "index" ? "" : removeSuffix(noExtension, "/index"); + function addExtensionAndIndex(path: string): string { + if (path === "") { + return "index.d.ts"; + } + if (endsWith(path, ".d.ts")) { + return path; + } + if (endsWith(path, "/index")) { + return path + ".d.ts"; + } + return path + "/index.d.ts"; } /* @internal */ @@ -955,12 +964,31 @@ namespace ts { subModuleName: string, failedLookupLocations: Push, onlyRecordFailures: boolean, - { host, traceEnabled }: ModuleResolutionState, + state: ModuleResolutionState, ): { found: boolean, packageJsonContent: PackageJsonPathFields | undefined, packageId: PackageId | undefined } { + const { host, traceEnabled } = state; const directoryExists = !onlyRecordFailures && directoryProbablyExists(nodeModuleDirectory, host); const packageJsonPath = pathToPackageJson(nodeModuleDirectory); if (directoryExists && host.fileExists(packageJsonPath)) { const packageJsonContent = readJson(packageJsonPath, host); + if (subModuleName === "") { // looking up the root - need to handle types/typings/main redirects for subModuleName + const path = tryReadPackageJsonFields(/*readTypes*/ true, packageJsonContent, nodeModuleDirectory, state); + if (typeof path === "string") { + subModuleName = addExtensionAndIndex(path.substring(nodeModuleDirectory.length + 1)); + } + else { + const jsPath = tryReadPackageJsonFields(/*readTypes*/ false, packageJsonContent, nodeModuleDirectory, state); + if (typeof jsPath === "string") { + subModuleName = removeExtension(removeExtension(jsPath.substring(nodeModuleDirectory.length + 1), Extension.Js), Extension.Jsx) + Extension.Dts; + } + else { + subModuleName = "index.d.ts"; + } + } + } + if (!endsWith(subModuleName, Extension.Dts)) { + subModuleName = addExtensionAndIndex(subModuleName); + } const packageId: PackageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string" ? { name: packageJsonContent.name, subModuleName, version: packageJsonContent.version } : undefined; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 23f9b08aa79..6ea50b30f6f 100755 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2363,9 +2363,30 @@ namespace ts { return false; } - return forEachEmittedFile(getEmitHost(), ({ jsFilePath, declarationFilePath }) => - isSameFile(jsFilePath, file) || - (declarationFilePath && isSameFile(declarationFilePath, file))); + // If this is source file, its not emitted file + const filePath = toPath(file); + if (getSourceFileByPath(filePath)) { + return false; + } + + // If options have --outFile or --out just check that + const out = options.outFile || options.out; + if (out) { + return isSameFile(filePath, out) || isSameFile(filePath, removeFileExtension(out) + Extension.Dts); + } + + // If --outDir, check if file is in that directory + if (options.outDir) { + return containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); + } + + if (fileExtensionIsOneOf(filePath, supportedJavascriptExtensions) || fileExtensionIs(filePath, Extension.Dts)) { + // Otherwise just check if sourceFile with the name exists + const filePathWithoutExtension = removeFileExtension(filePath); + return !!getSourceFileByPath(combinePaths(filePathWithoutExtension, Extension.Ts) as Path) || + !!getSourceFileByPath(combinePaths(filePathWithoutExtension, Extension.Tsx) as Path); + } + return false; } function isSameFile(file1: string, file2: string) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index f4ddf1d8319..f2874b6b665 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -681,10 +681,21 @@ namespace ts { return getSpanOfTokenAtPosition(sourceFile, node.pos); } - const pos = nodeIsMissing(errorNode) + const isMissing = nodeIsMissing(errorNode); + const pos = isMissing ? errorNode.pos : skipTrivia(sourceFile.text, errorNode.pos); + // These asserts should all be satisfied for a properly constructed `errorNode`. + if (isMissing) { + Debug.assert(pos === errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + Debug.assert(pos === errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + } + else { + Debug.assert(pos >= errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + Debug.assert(pos <= errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + } + return createTextSpanFromBounds(pos, errorNode.end); } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 7e141e2d6fe..d64fd2c2ce2 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -6883,4 +6883,48 @@ namespace ts.projectSystem { }); }); }); + + describe("tsserverProjectSystem forceConsistentCasingInFileNames", () => { + it("works when extends is specified with a case insensitive file system", () => { + const rootPath = "/Users/username/dev/project"; + const file1: FileOrFolder = { + path: `${rootPath}/index.ts`, + content: 'import {x} from "file2";', + }; + const file2: FileOrFolder = { + path: `${rootPath}/file2.js`, + content: "", + }; + const file2Dts: FileOrFolder = { + path: `${rootPath}/types/file2/index.d.ts`, + content: "export declare const x: string;", + }; + const tsconfigAll: FileOrFolder = { + path: `${rootPath}/tsconfig.all.json`, + content: JSON.stringify({ + compilerOptions: { + baseUrl: ".", + paths: { file2: ["./file2.js"] }, + typeRoots: ["./types"], + forceConsistentCasingInFileNames: true, + }, + }), + }; + const tsconfig: FileOrFolder = { + path: `${rootPath}/tsconfig.json`, + content: JSON.stringify({ extends: "./tsconfig.all.json" }), + }; + + const host = createServerHost([file1, file2, file2Dts, libFile, tsconfig, tsconfigAll], { useCaseSensitiveFileNames: false }); + const session = createSession(host); + + openFilesForSession([file1], session); + const projectService = session.getProjectService(); + + checkNumberOfProjects(projectService, { configuredProjects: 1 }); + + const diagnostics = configuredProjectAt(projectService, 0).getLanguageService().getCompilerOptionsDiagnostics(); + assert.deepEqual(diagnostics, []); + }); + }); } diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 5d67c5c6cdc..363a0ac6a41 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -14,7 +14,7 @@ - + @@ -5103,6 +5103,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index c7e02a6c2cc..f45c317dcdd 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -14,7 +14,7 @@ - + @@ -5103,6 +5103,15 @@ + + + + + + + + + @@ -8647,7 +8656,7 @@ - + diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index 3747e00c1f9..ffaf6621ac5 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -19,7 +19,7 @@ - + @@ -5112,6 +5112,15 @@ + + + + + + + + + @@ -8656,7 +8665,7 @@ - + diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index 4d8f2721a08..6251fa14008 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -14,7 +14,7 @@ - + @@ -5100,6 +5100,15 @@ + + + + + + + + + @@ -8638,7 +8647,7 @@ - + diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 517b05df202..acf7b098177 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -19,7 +19,7 @@ - + @@ -5112,6 +5112,15 @@ + + + + + + + + + @@ -8656,7 +8665,7 @@ - + diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index 99776a461cc..3507c91d278 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -19,7 +19,7 @@ - + @@ -5112,6 +5112,15 @@ + + + + + + + + + @@ -8656,7 +8665,7 @@ - + diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index e13e8191eb2..a2ee47c3620 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -14,7 +14,7 @@ - + @@ -5103,6 +5103,15 @@ + + + + + + + + + @@ -8647,7 +8656,7 @@ - + diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 1a892b757cb..a0888bc8397 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -14,7 +14,7 @@ - + @@ -5103,6 +5103,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index b534bf56365..9e337e473dc 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -14,7 +14,7 @@ - + @@ -5103,6 +5103,15 @@ + + + + + + + + + @@ -8647,7 +8656,7 @@ - + diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index c5473f41421..9b7661ee541 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -7,7 +7,7 @@ - + @@ -5093,6 +5093,15 @@ + + + + + + + + + @@ -8631,7 +8640,7 @@ - + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index 080b2e11402..dc5a7d359d5 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -7,7 +7,7 @@ - + @@ -5093,6 +5093,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index bb0b07794a3..1bcd0308ab4 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -13,7 +13,7 @@ - + @@ -5102,6 +5102,15 @@ + + + + + + + + + @@ -8646,7 +8655,7 @@ - + diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 44a9f695fca..343994d2cab 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -7,7 +7,7 @@ - + @@ -5096,6 +5096,15 @@ + + + + + + + + + diff --git a/src/server/server.ts b/src/server/server.ts index 8e53c4d5109..722193829f9 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -33,6 +33,7 @@ namespace ts.server { const os: { homedir?(): string; tmpdir(): string; + platform(): string; } = require("os"); interface NodeSocket { @@ -824,8 +825,9 @@ namespace ts.server { const logger = createLogger(); const sys = ts.sys; + const nodeVersion = getNodeMajorVersion(); // use watchGuard process on Windows when node version is 4 or later - const useWatchGuard = process.platform === "win32" && getNodeMajorVersion() >= 4; + const useWatchGuard = process.platform === "win32" && nodeVersion >= 4; const originalWatchDirectory: ServerHost["watchDirectory"] = sys.watchDirectory.bind(sys); const noopWatcher: FileWatcher = { close: noop }; // This is the function that catches the exceptions when watching directory, and yet lets project service continue to function @@ -980,8 +982,9 @@ namespace ts.server { }; logger.info(`Starting TS Server`); - logger.info(`Version: ${versionMajorMinor}`); + logger.info(`Version: ${version}`); logger.info(`Arguments: ${process.argv.join(" ")}`); + logger.info(`Platform: ${os.platform()} NodeVersion: ${nodeVersion} CaseSensitive: ${sys.useCaseSensitiveFileNames}`); const ioSession = new IOSession(options); process.on("uncaughtException", err => { diff --git a/src/server/typesMap.json b/src/server/typesMap.json index 93e9c2502f8..cfe7f6483c4 100644 --- a/src/server/typesMap.json +++ b/src/server/typesMap.json @@ -22,6 +22,15 @@ "References": { "match": "^(.*\\/_references\\.js)$", "exclude": [["^", 1, "$"]] + }, + "Datatables.net": { + "match": "^.*\\/(jquery\\.)?dataTables(\\.all)?(\\.min)?\\.js$", + "types": ["datatables.net"] + }, + "Ace": { + "match": "^(.*)\\/ace.js", + "exclude": [["^", 1, "/.*"]], + "types": ["ace"] } }, "simpleMap": { @@ -352,6 +361,7 @@ "passport": "passport", "passport-local": "passport-local", "path": "pathjs", + "pdfkit":"pdfkit", "peer": "peerjs", "peg": "pegjs", "photoswipe": "photoswipe", diff --git a/src/services/codefixes/fixForgottenThisPropertyAccess.ts b/src/services/codefixes/fixForgottenThisPropertyAccess.ts index 19610da0b15..837487f1b8c 100644 --- a/src/services/codefixes/fixForgottenThisPropertyAccess.ts +++ b/src/services/codefixes/fixForgottenThisPropertyAccess.ts @@ -21,6 +21,8 @@ namespace ts.codefix { } function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, token: Identifier): void { - changes.replaceNode(sourceFile, token, createPropertyAccess(createThis(), token)); + // TODO (https://github.com/Microsoft/TypeScript/issues/21246): use shared helper + suppressLeadingAndTrailingTrivia(token); + changes.replaceRange(sourceFile, { pos: token.getStart(), end: token.end }, createPropertyAccess(createThis(), token)); } } \ No newline at end of file diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index e3a2763b783..74a944077ec 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -335,6 +335,13 @@ namespace ts.refactor.extractSymbol { Continue = 1 << 1, Return = 1 << 2 } + + // We believe it's true because the node is from the (unmodified) tree. + Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + + // For understanding how skipTrivia functioned: + Debug.assert(!positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809"); + if (!isStatement(nodeToCheck) && !(isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)]; } diff --git a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json index ae3917e931a..d592022e2e1 100644 --- a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json +++ b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage.trace.json @@ -2,7 +2,7 @@ "======== Resolving module 'foo/use' from '/index.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo/use' from 'node_modules' folder, target file type 'TypeScript'.", - "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/use@1.2.3'.", + "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/use/index.d.ts@1.2.3'.", "File '/node_modules/foo/use.ts' does not exist.", "File '/node_modules/foo/use.tsx' does not exist.", "File '/node_modules/foo/use.d.ts' exist - use it as a name resolution result.", @@ -26,12 +26,15 @@ "File '/node_modules/foo/index.ts' does not exist.", "File '/node_modules/foo/index.tsx' does not exist.", "File '/node_modules/foo/index.d.ts' exist - use it as a name resolution result.", - "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo@1.2.3'.", + "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/index.d.ts@1.2.3'.", "======== Module name './index' was successfully resolved to '/node_modules/foo/index.d.ts'. ========", "======== Resolving module 'foo' from '/node_modules/a/index.d.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", - "Found 'package.json' at '/node_modules/a/node_modules/foo/package.json'. Package ID is 'foo@1.2.3'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", + "Found 'package.json' at '/node_modules/a/node_modules/foo/package.json'. Package ID is 'foo/index.d.ts@1.2.3'.", "File '/node_modules/a/node_modules/foo.ts' does not exist.", "File '/node_modules/a/node_modules/foo.tsx' does not exist.", "File '/node_modules/a/node_modules/foo.d.ts' does not exist.", diff --git a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json index a753e3dfb9a..108873d70f9 100644 --- a/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json +++ b/tests/baselines/reference/duplicatePackage_relativeImportWithinPackage_scoped.trace.json @@ -2,7 +2,7 @@ "======== Resolving module '@foo/bar/use' from '/index.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module '@foo/bar/use' from 'node_modules' folder, target file type 'TypeScript'.", - "Found 'package.json' at '/node_modules/@foo/bar/package.json'. Package ID is '@foo/bar/use@1.2.3'.", + "Found 'package.json' at '/node_modules/@foo/bar/package.json'. Package ID is '@foo/bar/use/index.d.ts@1.2.3'.", "File '/node_modules/@foo/bar/use.ts' does not exist.", "File '/node_modules/@foo/bar/use.tsx' does not exist.", "File '/node_modules/@foo/bar/use.d.ts' exist - use it as a name resolution result.", @@ -26,12 +26,15 @@ "File '/node_modules/@foo/bar/index.ts' does not exist.", "File '/node_modules/@foo/bar/index.tsx' does not exist.", "File '/node_modules/@foo/bar/index.d.ts' exist - use it as a name resolution result.", - "Found 'package.json' at '/node_modules/@foo/bar/package.json'. Package ID is '@foo/bar@1.2.3'.", + "Found 'package.json' at '/node_modules/@foo/bar/package.json'. Package ID is '@foo/bar/index.d.ts@1.2.3'.", "======== Module name './index' was successfully resolved to '/node_modules/@foo/bar/index.d.ts'. ========", "======== Resolving module '@foo/bar' from '/node_modules/a/index.d.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module '@foo/bar' from 'node_modules' folder, target file type 'TypeScript'.", - "Found 'package.json' at '/node_modules/a/node_modules/@foo/bar/package.json'. Package ID is '@foo/bar@1.2.3'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' does not have a 'main' field.", + "Found 'package.json' at '/node_modules/a/node_modules/@foo/bar/package.json'. Package ID is '@foo/bar/index.d.ts@1.2.3'.", "File '/node_modules/a/node_modules/@foo/bar.ts' does not exist.", "File '/node_modules/a/node_modules/@foo/bar.tsx' does not exist.", "File '/node_modules/a/node_modules/@foo/bar.d.ts' does not exist.", diff --git a/tests/baselines/reference/library-reference-10.trace.json b/tests/baselines/reference/library-reference-10.trace.json index ada939d8129..ad34c0b1dc3 100644 --- a/tests/baselines/reference/library-reference-10.trace.json +++ b/tests/baselines/reference/library-reference-10.trace.json @@ -1,6 +1,7 @@ [ "======== Resolving type reference directive 'jquery', containing file '/foo/consumer.ts', root directory './types'. ========", "Resolving with primary search path './types'.", + "'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.", "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.", @@ -8,6 +9,7 @@ "======== Type reference directive 'jquery' was successfully resolved to '/foo/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'.", + "'package.json' has 'typings' field 'jquery.d.ts' that references 'types/jquery/jquery.d.ts'.", "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.", diff --git a/tests/baselines/reference/library-reference-11.trace.json b/tests/baselines/reference/library-reference-11.trace.json index ef99bb8912f..be260b6bc6e 100644 --- a/tests/baselines/reference/library-reference-11.trace.json +++ b/tests/baselines/reference/library-reference-11.trace.json @@ -3,6 +3,7 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/a/b'.", "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", + "'package.json' has 'typings' field 'jquery.d.ts' that references '/a/node_modules/jquery/jquery.d.ts'.", "Found 'package.json' at '/a/node_modules/jquery/package.json'.", "File '/a/node_modules/jquery.d.ts' does not exist.", "'package.json' has 'typings' field 'jquery.d.ts' that references '/a/node_modules/jquery/jquery.d.ts'.", diff --git a/tests/baselines/reference/library-reference-12.trace.json b/tests/baselines/reference/library-reference-12.trace.json index 22b1232d30b..26361703708 100644 --- a/tests/baselines/reference/library-reference-12.trace.json +++ b/tests/baselines/reference/library-reference-12.trace.json @@ -3,6 +3,8 @@ "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/a/b'.", "Directory '/a/b/node_modules' does not exist, skipping all lookups in it.", + "'package.json' does not have a 'typings' field.", + "'package.json' has 'types' field 'dist/jquery.d.ts' that references '/a/node_modules/jquery/dist/jquery.d.ts'.", "Found 'package.json' at '/a/node_modules/jquery/package.json'.", "File '/a/node_modules/jquery.d.ts' does not exist.", "'package.json' does not have a 'typings' field.", diff --git a/tests/baselines/reference/library-reference-2.trace.json b/tests/baselines/reference/library-reference-2.trace.json index d48ca68145d..649189fbbdd 100644 --- a/tests/baselines/reference/library-reference-2.trace.json +++ b/tests/baselines/reference/library-reference-2.trace.json @@ -1,6 +1,8 @@ [ "======== Resolving type reference directive 'jquery', containing file '/consumer.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "'package.json' does not have a 'typings' field.", + "'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.", "Found 'package.json' at '/types/jquery/package.json'.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.", @@ -9,6 +11,8 @@ "======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/jquery.d.ts', primary: true. ========", "======== Resolving type reference directive 'jquery', containing file '/test/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'.", + "'package.json' does not have a 'typings' field.", + "'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.", "Found 'package.json' at '/types/jquery/package.json'.", "'package.json' does not have a 'typings' field.", "'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.", diff --git a/tests/baselines/reference/moduleLocalImportNotIncorrectlyRedirected.js b/tests/baselines/reference/moduleLocalImportNotIncorrectlyRedirected.js new file mode 100644 index 00000000000..88a0f5a10f5 --- /dev/null +++ b/tests/baselines/reference/moduleLocalImportNotIncorrectlyRedirected.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/moduleLocalImportNotIncorrectlyRedirected.ts] //// + +//// [package.json] +{ +"name": "troublesome-lib", +"typings": "lib/index.d.ts", +"version": "0.0.1" +} +//// [index.d.ts] +import { Position } from './utilities/positioning'; +export interface ISpinButton {} +//// [positioning.d.ts] +export * from './positioning/index'; +//// [index.d.ts] +export declare enum Position { + top, +} +//// [index.ts] +import { ISpinButton } from "troublesome-lib"; + +//// [index.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/moduleLocalImportNotIncorrectlyRedirected.symbols b/tests/baselines/reference/moduleLocalImportNotIncorrectlyRedirected.symbols new file mode 100644 index 00000000000..aa2fb0375ed --- /dev/null +++ b/tests/baselines/reference/moduleLocalImportNotIncorrectlyRedirected.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/index.ts === +import { ISpinButton } from "troublesome-lib"; +>ISpinButton : Symbol(ISpinButton, Decl(index.ts, 0, 8)) + +=== tests/cases/compiler/node_modules/troublesome-lib/lib/index.d.ts === +import { Position } from './utilities/positioning'; +>Position : Symbol(Position, Decl(index.d.ts, 0, 8)) + +export interface ISpinButton {} +>ISpinButton : Symbol(ISpinButton, Decl(index.d.ts, 0, 51)) + +=== tests/cases/compiler/node_modules/troublesome-lib/lib/utilities/positioning.d.ts === +export * from './positioning/index'; +No type information for this code.=== tests/cases/compiler/node_modules/troublesome-lib/lib/utilities/positioning/index.d.ts === +export declare enum Position { +>Position : Symbol(Position, Decl(index.d.ts, 0, 0)) + + top, +>top : Symbol(Position.top, Decl(index.d.ts, 0, 30)) +} diff --git a/tests/baselines/reference/moduleLocalImportNotIncorrectlyRedirected.types b/tests/baselines/reference/moduleLocalImportNotIncorrectlyRedirected.types new file mode 100644 index 00000000000..f3186505cc8 --- /dev/null +++ b/tests/baselines/reference/moduleLocalImportNotIncorrectlyRedirected.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/index.ts === +import { ISpinButton } from "troublesome-lib"; +>ISpinButton : any + +=== tests/cases/compiler/node_modules/troublesome-lib/lib/index.d.ts === +import { Position } from './utilities/positioning'; +>Position : typeof Position + +export interface ISpinButton {} +>ISpinButton : ISpinButton + +=== tests/cases/compiler/node_modules/troublesome-lib/lib/utilities/positioning.d.ts === +export * from './positioning/index'; +No type information for this code.=== tests/cases/compiler/node_modules/troublesome-lib/lib/utilities/positioning/index.d.ts === +export declare enum Position { +>Position : Position + + top, +>top : Position +} diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json index b619535487b..5f32a4bf511 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected.trace.json @@ -2,6 +2,9 @@ "======== Resolving module 'normalize.css' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'normalize.css' from 'node_modules' folder, target file type 'TypeScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'normalize.css' that references '/node_modules/normalize.css/normalize.css'.", "Found 'package.json' at '/node_modules/normalize.css/package.json'.", "File '/node_modules/normalize.css.ts' does not exist.", "File '/node_modules/normalize.css.tsx' does not exist.", @@ -13,6 +16,9 @@ "File '/node_modules/normalize.css/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'normalize.css' from 'node_modules' folder, target file type 'JavaScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'normalize.css' that references '/node_modules/normalize.css/normalize.css'.", "Found 'package.json' at '/node_modules/normalize.css/package.json'.", "File '/node_modules/normalize.css.js' does not exist.", "File '/node_modules/normalize.css.jsx' does not exist.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json index 50e7fa685a6..bab6be18d39 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions_unexpected2.trace.json @@ -2,6 +2,8 @@ "======== Resolving module 'foo' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' has 'types' field 'foo.js' that references '/node_modules/foo/foo.js'.", "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.ts' does not exist.", "File '/node_modules/foo.tsx' does not exist.", @@ -24,6 +26,8 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' has 'types' field 'foo.js' that references '/node_modules/foo/foo.js'.", "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", diff --git a/tests/baselines/reference/moduleResolution_packageJson_notAtPackageRoot.trace.json b/tests/baselines/reference/moduleResolution_packageJson_notAtPackageRoot.trace.json index bf5f0b0bbef..3473f33c1f2 100644 --- a/tests/baselines/reference/moduleResolution_packageJson_notAtPackageRoot.trace.json +++ b/tests/baselines/reference/moduleResolution_packageJson_notAtPackageRoot.trace.json @@ -2,6 +2,8 @@ "======== Resolving module 'foo/bar' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo/bar' from 'node_modules' folder, target file type 'TypeScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' has 'types' field 'types.d.ts' that references '/node_modules/foo/bar/types.d.ts'.", "Found 'package.json' at '/node_modules/foo/bar/package.json'.", "File '/node_modules/foo/bar.ts' does not exist.", "File '/node_modules/foo/bar.tsx' does not exist.", diff --git a/tests/baselines/reference/moduleResolution_packageJson_notAtPackageRoot_fakeScopedPackage.trace.json b/tests/baselines/reference/moduleResolution_packageJson_notAtPackageRoot_fakeScopedPackage.trace.json index 72d413d0b2c..07dc908b745 100644 --- a/tests/baselines/reference/moduleResolution_packageJson_notAtPackageRoot_fakeScopedPackage.trace.json +++ b/tests/baselines/reference/moduleResolution_packageJson_notAtPackageRoot_fakeScopedPackage.trace.json @@ -2,6 +2,8 @@ "======== Resolving module 'foo/@bar' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo/@bar' from 'node_modules' folder, target file type 'TypeScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' has 'types' field 'types.d.ts' that references '/node_modules/foo/@bar/types.d.ts'.", "Found 'package.json' at '/node_modules/foo/@bar/package.json'.", "File '/node_modules/foo/@bar.ts' does not exist.", "File '/node_modules/foo/@bar.tsx' does not exist.", diff --git a/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.trace.json b/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.trace.json index 69dcfca4eb6..77ea6a244c1 100644 --- a/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.trace.json +++ b/tests/baselines/reference/moduleResolution_packageJson_scopedPackage.trace.json @@ -2,6 +2,8 @@ "======== Resolving module '@foo/bar' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module '@foo/bar' from 'node_modules' folder, target file type 'TypeScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' has 'types' field 'types.d.ts' that references '/node_modules/@foo/bar/types.d.ts'.", "Found 'package.json' at '/node_modules/@foo/bar/package.json'.", "File '/node_modules/@foo/bar.ts' does not exist.", "File '/node_modules/@foo/bar.tsx' does not exist.", diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot.trace.json b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot.trace.json index e852d58f2b3..453f5c088a3 100644 --- a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot.trace.json +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot.trace.json @@ -3,7 +3,7 @@ "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo/bar' from 'node_modules' folder, target file type 'TypeScript'.", "File '/node_modules/foo/bar/package.json' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/bar@1.2.3'.", + "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/bar/index.d.ts@1.2.3'.", "File '/node_modules/foo/bar.ts' does not exist.", "File '/node_modules/foo/bar.tsx' does not exist.", "File '/node_modules/foo/bar.d.ts' does not exist.", @@ -13,7 +13,7 @@ "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo/bar' from 'node_modules' folder, target file type 'JavaScript'.", "File '/node_modules/foo/bar/package.json' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/bar@1.2.3'.", + "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/bar/index.d.ts@1.2.3'.", "File '/node_modules/foo/bar.js' does not exist.", "File '/node_modules/foo/bar.jsx' does not exist.", "File '/node_modules/foo/bar/index.js' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json index 19fe1f125bc..b84bac8993a 100644 --- a/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json +++ b/tests/baselines/reference/moduleResolution_packageJson_yesAtPackageRoot_fakeScopedPackage.trace.json @@ -3,7 +3,7 @@ "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo/@bar' from 'node_modules' folder, target file type 'TypeScript'.", "File '/node_modules/foo/@bar/package.json' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/@bar@1.2.3'.", + "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/@bar/index.d.ts@1.2.3'.", "File '/node_modules/foo/@bar.ts' does not exist.", "File '/node_modules/foo/@bar.tsx' does not exist.", "File '/node_modules/foo/@bar.d.ts' does not exist.", @@ -13,7 +13,7 @@ "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo/@bar' from 'node_modules' folder, target file type 'JavaScript'.", "File '/node_modules/foo/@bar/package.json' does not exist.", - "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/@bar@1.2.3'.", + "Found 'package.json' at '/node_modules/foo/package.json'. Package ID is 'foo/@bar/index.d.ts@1.2.3'.", "File '/node_modules/foo/@bar.js' does not exist.", "File '/node_modules/foo/@bar.jsx' does not exist.", "File '/node_modules/foo/@bar/index.js' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.errors.txt b/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.errors.txt new file mode 100644 index 00000000000..748bb587807 --- /dev/null +++ b/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.errors.txt @@ -0,0 +1,25 @@ +tests/cases/compiler/file1.ts(5,1): error TS2708: Cannot use namespace 'Library' as a value. +tests/cases/compiler/file2.ts(1,8): error TS2440: Import declaration conflicts with local declaration of 'Lib'. +tests/cases/compiler/file2.ts(6,12): error TS2694: Namespace 'Lib' has no exported member 'Bar'. + + +==== tests/cases/compiler/file1.ts (1 errors) ==== + export namespace Library { + export type Bar = { a: number }; + } + var x: Library.Bar; // should work + Library.foo; // should be an error + ~~~~~~~ +!!! error TS2708: Cannot use namespace 'Library' as a value. +==== tests/cases/compiler/file2.ts (2 errors) ==== + import * as Lib from './file1'; + ~~~~~~~~ +!!! error TS2440: Import declaration conflicts with local declaration of 'Lib'. + namespace Lib { // should fail to merge + export const foo: string = ""; + } + Lib.foo; // should work + var x: Lib.Bar; // should be an error + ~~~ +!!! error TS2694: Namespace 'Lib' has no exported member 'Bar'. + export { Lib } \ No newline at end of file diff --git a/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.js b/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.js new file mode 100644 index 00000000000..866aa225db9 --- /dev/null +++ b/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.js @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/namespaceMergedWithImportAliasNoCrash.ts] //// + +//// [file1.ts] +export namespace Library { + export type Bar = { a: number }; +} +var x: Library.Bar; // should work +Library.foo; // should be an error +//// [file2.ts] +import * as Lib from './file1'; +namespace Lib { // should fail to merge + export const foo: string = ""; +} +Lib.foo; // should work +var x: Lib.Bar; // should be an error +export { Lib } + +//// [file1.js] +"use strict"; +exports.__esModule = true; +var x; // should work +Library.foo; // should be an error +//// [file2.js] +"use strict"; +exports.__esModule = true; +var Lib; +(function (Lib) { + Lib.foo = ""; +})(Lib || (Lib = {})); +exports.Lib = Lib; +Lib.foo; // should work +var x; // should be an error diff --git a/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.symbols b/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.symbols new file mode 100644 index 00000000000..6e4fa919e2e --- /dev/null +++ b/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/file1.ts === +export namespace Library { +>Library : Symbol(Library, Decl(file1.ts, 0, 0)) + + export type Bar = { a: number }; +>Bar : Symbol(Bar, Decl(file1.ts, 0, 26)) +>a : Symbol(a, Decl(file1.ts, 1, 23)) +} +var x: Library.Bar; // should work +>x : Symbol(x, Decl(file1.ts, 3, 3)) +>Library : Symbol(Library, Decl(file1.ts, 0, 0)) +>Bar : Symbol(Library.Bar, Decl(file1.ts, 0, 26)) + +Library.foo; // should be an error +=== tests/cases/compiler/file2.ts === +import * as Lib from './file1'; +>Lib : Symbol(Lib, Decl(file2.ts, 0, 6), Decl(file2.ts, 0, 31)) + +namespace Lib { // should fail to merge +>Lib : Symbol(Lib, Decl(file2.ts, 0, 6), Decl(file2.ts, 0, 31)) + + export const foo: string = ""; +>foo : Symbol(foo, Decl(file2.ts, 2, 16)) +} +Lib.foo; // should work +>Lib.foo : Symbol(Lib.foo, Decl(file2.ts, 2, 16)) +>Lib : Symbol(Lib, Decl(file2.ts, 0, 6), Decl(file2.ts, 0, 31)) +>foo : Symbol(Lib.foo, Decl(file2.ts, 2, 16)) + +var x: Lib.Bar; // should be an error +>x : Symbol(x, Decl(file2.ts, 5, 3)) +>Lib : Symbol(Lib, Decl(file2.ts, 0, 6), Decl(file2.ts, 0, 31)) + +export { Lib } +>Lib : Symbol(Lib, Decl(file2.ts, 6, 8)) + diff --git a/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.types b/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.types new file mode 100644 index 00000000000..f0fe207b5a5 --- /dev/null +++ b/tests/baselines/reference/namespaceMergedWithImportAliasNoCrash.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/file1.ts === +export namespace Library { +>Library : any + + export type Bar = { a: number }; +>Bar : Bar +>a : number +} +var x: Library.Bar; // should work +>x : Library.Bar +>Library : any +>Bar : Library.Bar + +Library.foo; // should be an error +>Library.foo : any +>Library : any +>foo : any + +=== tests/cases/compiler/file2.ts === +import * as Lib from './file1'; +>Lib : typeof Lib + +namespace Lib { // should fail to merge +>Lib : typeof Lib + + export const foo: string = ""; +>foo : string +>"" : "" +} +Lib.foo; // should work +>Lib.foo : string +>Lib : typeof Lib +>foo : string + +var x: Lib.Bar; // should be an error +>x : any +>Lib : any +>Bar : No type information available! + +export { Lib } +>Lib : typeof Lib + diff --git a/tests/baselines/reference/packageJsonMain.trace.json b/tests/baselines/reference/packageJsonMain.trace.json index 842f70c3a02..6d39b9d4a7b 100644 --- a/tests/baselines/reference/packageJsonMain.trace.json +++ b/tests/baselines/reference/packageJsonMain.trace.json @@ -2,6 +2,9 @@ "======== Resolving module 'foo' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.ts' does not exist.", "File '/node_modules/foo.tsx' does not exist.", @@ -13,6 +16,9 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", @@ -25,6 +31,9 @@ "======== Resolving module 'bar' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'bar' from 'node_modules' folder, target file type 'TypeScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'rab.js' that references '/node_modules/bar/rab.js'.", "Found 'package.json' at '/node_modules/bar/package.json'.", "File '/node_modules/bar.ts' does not exist.", "File '/node_modules/bar.tsx' does not exist.", @@ -36,6 +45,9 @@ "File '/node_modules/bar/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'bar' from 'node_modules' folder, target file type 'JavaScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'rab.js' that references '/node_modules/bar/rab.js'.", "Found 'package.json' at '/node_modules/bar/package.json'.", "File '/node_modules/bar.js' does not exist.", "File '/node_modules/bar.jsx' does not exist.", @@ -46,6 +58,9 @@ "======== Resolving module 'baz' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'baz' from 'node_modules' folder, target file type 'TypeScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'zab' that references '/node_modules/baz/zab'.", "Found 'package.json' at '/node_modules/baz/package.json'.", "File '/node_modules/baz.ts' does not exist.", "File '/node_modules/baz.tsx' does not exist.", @@ -57,6 +72,9 @@ "File '/node_modules/baz/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'baz' from 'node_modules' folder, target file type 'JavaScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'zab' that references '/node_modules/baz/zab'.", "Found 'package.json' at '/node_modules/baz/package.json'.", "File '/node_modules/baz.js' does not exist.", "File '/node_modules/baz.jsx' does not exist.", diff --git a/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json b/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json index 763c86730ba..81f5be11a6d 100644 --- a/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json +++ b/tests/baselines/reference/packageJsonMain_isNonRecursive.trace.json @@ -2,6 +2,9 @@ "======== Resolving module 'foo' from '/a.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module 'foo' from 'node_modules' folder, target file type 'TypeScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.ts' does not exist.", "File '/node_modules/foo.tsx' does not exist.", @@ -13,6 +16,9 @@ "File '/node_modules/foo/index.d.ts' does not exist.", "Directory '/node_modules/@types' does not exist, skipping all lookups in it.", "Loading module 'foo' from 'node_modules' folder, target file type 'JavaScript'.", + "'package.json' does not have a 'typings' field.", + "'package.json' does not have a 'types' field.", + "'package.json' has 'main' field 'oof' that references '/node_modules/foo/oof'.", "Found 'package.json' at '/node_modules/foo/package.json'.", "File '/node_modules/foo.js' does not exist.", "File '/node_modules/foo.jsx' does not exist.", diff --git a/tests/baselines/reference/typingsLookup4.trace.json b/tests/baselines/reference/typingsLookup4.trace.json index 133ea49c22a..6cd025d099a 100644 --- a/tests/baselines/reference/typingsLookup4.trace.json +++ b/tests/baselines/reference/typingsLookup4.trace.json @@ -5,6 +5,7 @@ "File '/node_modules/jquery.ts' does not exist.", "File '/node_modules/jquery.tsx' does not exist.", "File '/node_modules/jquery.d.ts' does not exist.", + "'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.", "Found 'package.json' at '/node_modules/@types/jquery/package.json'.", "File '/node_modules/@types/jquery.d.ts' does not exist.", "'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.", @@ -17,6 +18,7 @@ "File '/node_modules/kquery.ts' does not exist.", "File '/node_modules/kquery.tsx' does not exist.", "File '/node_modules/kquery.d.ts' does not exist.", + "'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.", "Found 'package.json' at '/node_modules/@types/kquery/package.json'.", "File '/node_modules/@types/kquery.d.ts' does not exist.", "'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.", @@ -33,6 +35,7 @@ "File '/node_modules/lquery.ts' does not exist.", "File '/node_modules/lquery.tsx' does not exist.", "File '/node_modules/lquery.d.ts' does not exist.", + "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", "Found 'package.json' at '/node_modules/@types/lquery/package.json'.", "File '/node_modules/@types/lquery.d.ts' does not exist.", "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", @@ -47,6 +50,7 @@ "File '/node_modules/mquery.ts' does not exist.", "File '/node_modules/mquery.tsx' does not exist.", "File '/node_modules/mquery.d.ts' does not exist.", + "'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.", "Found 'package.json' at '/node_modules/@types/mquery/package.json'.", "File '/node_modules/@types/mquery.d.ts' does not exist.", "'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.", @@ -61,6 +65,7 @@ "======== Module name 'mquery' was successfully resolved to '/node_modules/@types/mquery/mquery/index.tsx'. ========", "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.", "Found 'package.json' at '/node_modules/@types/jquery/package.json'.", "'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.", "File '/node_modules/@types/jquery/jquery.d.ts' exist - use it as a name resolution result.", @@ -68,6 +73,7 @@ "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/jquery.d.ts', primary: true. ========", "======== Resolving type reference directive 'kquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.", "Found 'package.json' at '/node_modules/@types/kquery/package.json'.", "'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.", "File '/node_modules/@types/kquery/kquery' does not exist.", @@ -79,6 +85,7 @@ "======== Type reference directive 'kquery' was successfully resolved to '/node_modules/@types/kquery/kquery.d.ts', primary: true. ========", "======== Resolving type reference directive 'lquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", "Found 'package.json' at '/node_modules/@types/lquery/package.json'.", "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", "File '/node_modules/@types/lquery/lquery' does not exist.", @@ -88,6 +95,7 @@ "======== Type reference directive 'lquery' was successfully resolved to '/node_modules/@types/lquery/lquery.ts', primary: true. ========", "======== Resolving type reference directive 'mquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'.", + "'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.", "Found 'package.json' at '/node_modules/@types/mquery/package.json'.", "'package.json' has 'typings' field 'mquery' that references '/node_modules/@types/mquery/mquery'.", "File '/node_modules/@types/mquery/mquery' does not exist.", diff --git a/tests/cases/compiler/moduleLocalImportNotIncorrectlyRedirected.ts b/tests/cases/compiler/moduleLocalImportNotIncorrectlyRedirected.ts new file mode 100644 index 00000000000..89d967a32cd --- /dev/null +++ b/tests/cases/compiler/moduleLocalImportNotIncorrectlyRedirected.ts @@ -0,0 +1,18 @@ +// @noImplicitReferences: true +// @filename: node_modules/troublesome-lib/package.json +{ +"name": "troublesome-lib", +"typings": "lib/index.d.ts", +"version": "0.0.1" +} +// @filename: node_modules/troublesome-lib/lib/index.d.ts +import { Position } from './utilities/positioning'; +export interface ISpinButton {} +// @filename: node_modules/troublesome-lib/lib/utilities/positioning.d.ts +export * from './positioning/index'; +// @filename: node_modules/troublesome-lib/lib/utilities/positioning/index.d.ts +export declare enum Position { + top, +} +// @filename: index.ts +import { ISpinButton } from "troublesome-lib"; \ No newline at end of file diff --git a/tests/cases/compiler/namespaceMergedWithImportAliasNoCrash.ts b/tests/cases/compiler/namespaceMergedWithImportAliasNoCrash.ts new file mode 100644 index 00000000000..8242c22dd7a --- /dev/null +++ b/tests/cases/compiler/namespaceMergedWithImportAliasNoCrash.ts @@ -0,0 +1,14 @@ +// @filename: file1.ts +export namespace Library { + export type Bar = { a: number }; +} +var x: Library.Bar; // should work +Library.foo; // should be an error +// @filename: file2.ts +import * as Lib from './file1'; +namespace Lib { // should fail to merge + export const foo: string = ""; +} +Lib.foo; // should work +var x: Lib.Bar; // should be an error +export { Lib } \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixForgottenThisPropertyAccess03.ts b/tests/cases/fourslash/codeFixForgottenThisPropertyAccess03.ts new file mode 100644 index 00000000000..2dd1c47b6f7 --- /dev/null +++ b/tests/cases/fourslash/codeFixForgottenThisPropertyAccess03.ts @@ -0,0 +1,15 @@ +/// + +////class C { +//// foo: number; +//// constructor() {[| +//// /* a comment */foo = 10; +//// |]} +////} + +verify.codeFix({ + description: "Add 'this.' to unresolved variable", + newRangeContent: ` + /* a comment */this.foo = 10; + ` +});