diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 432b63dca1e..e6970df6811 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2305,18 +2305,22 @@ namespace ts { } function setCommonJsModuleIndicator(node: Node) { + if (file.externalModuleIndicator) { + return false; + } if (!file.commonJsModuleIndicator) { file.commonJsModuleIndicator = node; - if (!file.externalModuleIndicator) { - bindSourceFileAsExternalModule(); - } + bindSourceFileAsExternalModule(); } + return true; } function bindExportsPropertyAssignment(node: BinaryExpression) { // When we create a property via 'exports.foo = bar', the 'exports.foo' property access // expression is the declaration - setCommonJsModuleIndicator(node); + if (!setCommonJsModuleIndicator(node)) { + return; + } const lhs = node.left as PropertyAccessEntityNameExpression; const symbol = forEachIdentifierInEntityName(lhs.expression, /*parent*/ undefined, (id, symbol) => { if (symbol) { @@ -2337,15 +2341,15 @@ namespace ts { // is still pointing to 'module.exports'. // We do not want to consider this as 'export=' since a module can have only one of these. // Similarly we do not want to treat 'module.exports = exports' as an 'export='. + if (!setCommonJsModuleIndicator(node)) { + return; + } const assignedExpression = getRightMostAssignedExpression(node.right); if (isEmptyObjectLiteral(assignedExpression) || container === file && isExportsOrModuleExportsOrAlias(file, assignedExpression)) { - // Mark it as a module in case there are no other exports in the file - setCommonJsModuleIndicator(node); return; } // 'module.exports = expr' assignment - setCommonJsModuleIndicator(node); const flags = exportAssignmentIsAlias(node) ? SymbolFlags.Alias // An export= with an EntityNameExpression or a ClassExpression exports all meanings of that identifier or class : SymbolFlags.Property | SymbolFlags.ExportValue | SymbolFlags.ValueModule; diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 1152e409e75..91ff766678a 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -2587,18 +2587,41 @@ namespace ts { return node; } - export function createUnparsedSourceFile(text: string, map?: string): UnparsedSource { + export function createUnparsedSourceFile(text: string): UnparsedSource; + export function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; + export function createUnparsedSourceFile(text: string, mapPath?: string, map?: string): UnparsedSource { const node = createNode(SyntaxKind.UnparsedSource); node.text = text; + node.sourceMapPath = mapPath; node.sourceMapText = map; return node; } - - export function createInputFiles(javascript: string, declaration: string, javascriptMapText?: string, declarationMapText?: string): InputFiles { + export function createInputFiles( + javascript: string, + declaration: string + ): InputFiles; + export function createInputFiles( + javascript: string, + declaration: string, + javascriptMapPath: string | undefined, + javascriptMapText: string | undefined, + declarationMapPath: string | undefined, + declarationMapText: string | undefined + ): InputFiles; + export function createInputFiles( + javascript: string, + declaration: string, + javascriptMapPath?: string, + javascriptMapText?: string, + declarationMapPath?: string, + declarationMapText?: string + ): InputFiles { const node = createNode(SyntaxKind.InputFiles); node.javascriptText = javascript; + node.javascriptMapPath = javascriptMapPath; node.javascriptMapText = javascriptMapText; node.declarationText = declaration; + node.declarationMapPath = declarationMapPath; node.declarationMapText = declarationMapText; return node; } diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index 40f3bb96e22..3ab03ecbbfc 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -133,15 +133,16 @@ namespace ts.moduleSpecifiers { return firstDefined(imports, ({ text }) => pathIsRelative(text) ? fileExtensionIs(text, Extension.Js) : undefined) || false; } - function discoverProbableSymlinks(files: ReadonlyArray) { + function discoverProbableSymlinks(files: ReadonlyArray, getCanonicalFileName: (file: string) => string, host: ModuleSpecifierResolutionHost) { const symlinks = mapDefined(files, sf => sf.resolvedModules && firstDefinedIterator(sf.resolvedModules.values(), res => res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined)); const result = createMap(); if (symlinks) { + const currentDirectory = host.getCurrentDirectory ? host.getCurrentDirectory() : ""; for (const [resolvedPath, originalPath] of symlinks) { - const resolvedParts = getPathComponents(resolvedPath); - const originalParts = getPathComponents(originalPath); + const resolvedParts = getPathComponents(toPath(resolvedPath, currentDirectory, getCanonicalFileName)); + const originalParts = getPathComponents(toPath(originalPath, currentDirectory, getCanonicalFileName)); while (resolvedParts[resolvedParts.length - 1] === originalParts[originalParts.length - 1]) { resolvedParts.pop(); originalParts.pop(); @@ -153,12 +154,13 @@ namespace ts.moduleSpecifiers { } function getAllModulePathsUsingIndirectSymlinks(files: ReadonlyArray, target: string, getCanonicalFileName: (file: string) => string, host: ModuleSpecifierResolutionHost) { - const links = discoverProbableSymlinks(files); + const links = discoverProbableSymlinks(files, getCanonicalFileName, host); const paths = arrayFrom(links.keys()); let options: string[] | undefined; + const compareStrings = (!host.useCaseSensitiveFileNames || host.useCaseSensitiveFileNames()) ? compareStringsCaseSensitive : compareStringsCaseInsensitive; for (const path of paths) { const resolved = links.get(path)!; - if (startsWith(target, resolved + "/")) { + if (compareStrings(target.slice(0, resolved.length + 1), resolved + "/") === Comparison.EqualTo) { const relative = getRelativePathFromDirectory(resolved, target, getCanonicalFileName); const option = resolvePath(path, relative); if (!host.fileExists || host.fileExists(option)) { @@ -167,12 +169,11 @@ namespace ts.moduleSpecifiers { } } } - const resolvedtarget = host.getCurrentDirectory ? resolvePath(host.getCurrentDirectory(), target) : target; if (options) { - options.push(resolvedtarget); // Since these are speculative, we also include the original resolved name as a possibility + options.push(target); // Since these are speculative, we also include the original resolved name as a possibility return options; } - return [resolvedtarget]; + return [target]; } /** @@ -183,7 +184,7 @@ namespace ts.moduleSpecifiers { const symlinks = mapDefined(files, sf => sf.resolvedModules && firstDefinedIterator(sf.resolvedModules.values(), res => res && res.resolvedFileName === fileName ? res.originalPath : undefined)); - return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, fileName, getCanonicalFileName, host) : symlinks; + return symlinks.length === 0 ? getAllModulePathsUsingIndirectSymlinks(files, getNormalizedAbsolutePath(fileName, host.getCurrentDirectory ? host.getCurrentDirectory() : ""), getCanonicalFileName, host) : symlinks; } function getRelativePathNParents(relativePath: string): number { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 8a741cc93d0..0e65011e0e4 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1240,10 +1240,12 @@ namespace ts { const dtsFilename = changeExtension(resolvedRefOpts.options.outFile, ".d.ts"); const js = host.readFile(resolvedRefOpts.options.outFile) || `/* Input file ${resolvedRefOpts.options.outFile} was missing */\r\n`; - const jsMap = host.readFile(resolvedRefOpts.options.outFile + ".map"); // TODO: try to read sourceMappingUrl comment from the js file + const jsMapPath = resolvedRefOpts.options.outFile + ".map"; // TODO: try to read sourceMappingUrl comment from the file + const jsMap = host.readFile(jsMapPath); const dts = host.readFile(dtsFilename) || `/* Input file ${dtsFilename} was missing */\r\n`; - const dtsMap = host.readFile(dtsFilename + ".map"); - const node = createInputFiles(js, dts, jsMap, dtsMap); + const dtsMapPath = dtsFilename + ".map"; + const dtsMap = host.readFile(dtsMapPath); + const node = createInputFiles(js, dts, jsMap && jsMapPath, jsMap, dtsMap && dtsMapPath, dtsMap); nodes.push(node); } } diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index 8ef71ecf955..bd62d4c103b 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -99,10 +99,6 @@ namespace ts { let sourceMapDataList: SourceMapData[] | undefined; let disabled: boolean = !(compilerOptions.sourceMap || compilerOptions.inlineSourceMap); - let completedSections: SourceMapSectionDefinition[]; - let sectionStartLine: number; - let sectionStartColumn: number; - return { initialize, reset, @@ -150,9 +146,6 @@ namespace ts { lastEncodedNameIndex = 0; // Initialize source map data - completedSections = []; - sectionStartLine = 1; - sectionStartColumn = 1; sourceMapData = { sourceMapFilePath, jsSourceMappingURL: !compilerOptions.inlineSourceMap ? getBaseFileName(normalizeSlashes(sourceMapFilePath)) : undefined!, // TODO: GH#18217 @@ -221,9 +214,6 @@ namespace ts { lastEncodedNameIndex = undefined; sourceMapData = undefined!; sourceMapDataList = undefined!; - completedSections = undefined!; - sectionStartLine = undefined!; - sectionStartColumn = undefined!; } interface SourceMapSection { @@ -233,7 +223,7 @@ namespace ts { sources: string[]; names?: string[]; mappings: string; - sourcesContent?: string[]; + sourcesContent?: (string | null)[]; sections?: undefined; } @@ -261,26 +251,6 @@ namespace ts { }; } - function resetSectionalData(): void { - sourceMapData.sourceMapSources = []; - sourceMapData.sourceMapNames = []; - sourceMapData.sourceMapMappings = ""; - sourceMapData.sourceMapSourcesContent = compilerOptions.inlineSources ? [] : undefined; - } - - function generateMap(): SourceMap { - if (completedSections.length) { - captureSectionalSpanIfNeeded(/*reset*/ false); - return { - version: 3, - file: sourceMapData.sourceMapFile, - sections: completedSections - }; - } - else { - return captureSection(); - } - } // Encoding for sourcemap span function encodeLastRecordedSourceMapSpan() { @@ -350,8 +320,8 @@ namespace ts { sourceLinePos.line++; sourceLinePos.character++; - const emittedLine = writer.getLine() - sectionStartLine + 1; - const emittedColumn = emittedLine === 0 ? (writer.getColumn() - sectionStartColumn + 1) : writer.getColumn(); + const emittedLine = writer.getLine(); + const emittedColumn = writer.getColumn(); // If this location wasn't recorded or the location in source is going backwards, record the span if (!lastRecordedSourceMapSpan || @@ -386,13 +356,8 @@ namespace ts { } } - function captureSectionalSpanIfNeeded(reset: boolean) { - if (lastRecordedSourceMapSpan && lastRecordedSourceMapSpan === lastEncodedSourceMapSpan) { // If we've recorded some spans, save them - completedSections.push({ offset: { line: sectionStartLine - 1, column: sectionStartColumn - 1 }, map: captureSection() }); - if (reset) { - resetSectionalData(); - } - } + function isPossiblySourceMap(x: {}): x is SourceMapSection { + return typeof x === "object" && !!(x as any).mappings && typeof (x as any).mappings === "string" && !!(x as any).sources; } /** @@ -409,7 +374,6 @@ namespace ts { if (node) { if (isUnparsedSource(node) && node.sourceMapText !== undefined) { - captureSectionalSpanIfNeeded(/*reset*/ true); const text = node.sourceMapText; let parsed: {} | undefined; try { @@ -418,24 +382,41 @@ namespace ts { catch { // empty } - const offset = { line: writer.getLine() - 1, column: writer.getColumn() - 1 }; - completedSections.push(parsed - ? { - offset, - map: parsed as SourceMap - } - : { - offset, - // This is just passes the buck on sourcemaps we don't really understand, instead of issuing an error (which would be difficult this late) - url: `data:application/json;charset=utf-8;base64,${base64encode(sys, text)}` - } - ); - const emitResult = emitCallback(hint, node); - sectionStartLine = writer.getLine(); - sectionStartColumn = writer.getColumn(); - lastRecordedSourceMapSpan = undefined!; - lastEncodedSourceMapSpan = defaultLastEncodedSourceMapSpan; - return emitResult; + if (!parsed || !isPossiblySourceMap(parsed)) { + return emitCallback(hint, node); + } + const offsetLine = writer.getLine(); + const firstLineColumnOffset = writer.getColumn(); + // First, decode the old component sourcemap + const originalMap = parsed; + sourcemaps.calculateDecodedMappings(originalMap, (raw): void => { + // Apply offsets to each position and fixup source entries + const rawPath = originalMap.sources[raw.sourceIndex]; + const relativePath = originalMap.sourceRoot ? combinePaths(originalMap.sourceRoot, rawPath) : rawPath; + const combinedPath = combinePaths(getDirectoryPath(node.sourceMapPath!), relativePath); + const sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; + const resolvedPath = getRelativePathToDirectoryOrUrl( + sourcesDirectoryPath, + combinedPath, + host.getCurrentDirectory(), + host.getCanonicalFileName, + /*isAbsolutePathAnUrl*/ true + ); + const absolutePath = toPath(resolvedPath, sourcesDirectoryPath, host.getCanonicalFileName); + // tslint:disable-next-line:no-null-keyword + setupSourceEntry(absolutePath, originalMap.sourcesContent ? originalMap.sourcesContent[raw.sourceIndex] : null); // TODO: Lookup content for inlining? + const newIndex = sourceMapData.sourceMapSources.indexOf(resolvedPath); + // Then reencode all the updated spans into the overall map + encodeLastRecordedSourceMapSpan(); + lastRecordedSourceMapSpan = { + ...raw, + emittedLine: raw.emittedLine + offsetLine - 1, + emittedColumn: raw.emittedLine === 0 ? (raw.emittedColumn + firstLineColumnOffset - 1) : raw.emittedColumn, + sourceIndex: newIndex, + }; + }); + // And actually emit the text these sourcemaps are for + return emitCallback(hint, node); } const emitNode = node.emitNode; const emitFlags = emitNode && emitNode.flags || EmitFlags.None; @@ -529,13 +510,17 @@ namespace ts { return; } + setupSourceEntry(sourceFile.fileName, sourceFile.text); + } + + function setupSourceEntry(fileName: string, content: string | null) { // Add the file to tsFilePaths // If sourceroot option: Use the relative path corresponding to the common directory path // otherwise source locations relative to map file location const sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir; const source = getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, - currentSource.fileName, + fileName, host.getCurrentDirectory(), host.getCanonicalFileName, /*isAbsolutePathAnUrl*/ true); @@ -546,10 +531,10 @@ namespace ts { sourceMapData.sourceMapSources.push(source); // The one that can be used from program to get the actual source file - sourceMapData.inputSourceFileNames.push(currentSource.fileName); + sourceMapData.inputSourceFileNames.push(fileName); if (compilerOptions.inlineSources) { - sourceMapData.sourceMapSourcesContent!.push(currentSource.text); + sourceMapData.sourceMapSourcesContent!.push(content); } } } @@ -564,7 +549,7 @@ namespace ts { encodeLastRecordedSourceMapSpan(); - return JSON.stringify(generateMap()); + return JSON.stringify(captureSection()); } /** diff --git a/src/services/sourcemaps.ts b/src/compiler/sourcemapDecoder.ts similarity index 84% rename from src/services/sourcemaps.ts rename to src/compiler/sourcemapDecoder.ts index 4fae8167aac..b825b547250 100644 --- a/src/services/sourcemaps.ts +++ b/src/compiler/sourcemapDecoder.ts @@ -1,3 +1,33 @@ +/* @internal */ +namespace ts { + export interface SourceFileLikeCache { + get(path: Path): SourceFileLike | undefined; + } + + export function createSourceFileLikeCache(host: { readFile?: (path: string) => string | undefined, fileExists?: (path: string) => boolean }): SourceFileLikeCache { + const cached = createMap(); + return { + get(path: Path) { + if (cached.has(path)) { + return cached.get(path); + } + if (!host.fileExists || !host.readFile || !host.fileExists(path)) return; + // And failing that, check the disk + const text = host.readFile(path)!; // TODO: GH#18217 + const file = { + text, + lineMap: undefined, + getLineAndCharacterOfPosition(pos: number) { + return computeLineAndCharacterOfPosition(getLineStarts(this), pos); + } + } as SourceFileLike; + cached.set(path, file); + return file; + } + }; + } +} + /* @internal */ namespace ts.sourcemaps { export interface SourceMapData { @@ -5,7 +35,7 @@ namespace ts.sourcemaps { file?: string; sourceRoot?: string; sources: string[]; - sourcesContent?: string[]; + sourcesContent?: (string | null)[]; names?: string[]; mappings: string; } @@ -86,7 +116,7 @@ namespace ts.sourcemaps { } function getDecodedMappings() { - return decodedMappings || (decodedMappings = calculateDecodedMappings()); + return decodedMappings || (decodedMappings = calculateDecodedMappings(map, processPosition, host)); } function getSourceOrderedMappings() { @@ -97,30 +127,6 @@ namespace ts.sourcemaps { return generatedOrderedMappings || (generatedOrderedMappings = getDecodedMappings().slice().sort(compareProcessedPositionEmittedPositions)); } - function calculateDecodedMappings(): ProcessedSourceMapPosition[] { - const state: DecoderState = { - encodedText: map.mappings, - currentNameIndex: undefined, - sourceMapNamesLength: map.names ? map.names.length : undefined, - currentEmittedColumn: 0, - currentEmittedLine: 0, - currentSourceColumn: 0, - currentSourceLine: 0, - currentSourceIndex: 0, - positions: [], - decodingIndex: 0, - processPosition, - }; - while (!hasCompletedDecoding(state)) { - decodeSinglePosition(state); - if (state.error) { - host.log(`Encountered error while decoding sourcemap found at ${mapPath}: ${state.error}`); - return []; - } - } - return state.positions; - } - function compareProcessedPositionSourcePositions(a: ProcessedSourceMapPosition, b: ProcessedSourceMapPosition) { return comparePaths(a.sourcePath, b.sourcePath, sourceRoot) || compareValues(a.sourcePosition, b.sourcePosition); @@ -142,6 +148,32 @@ namespace ts.sourcemaps { } } + export function calculateDecodedMappings(map: SourceMapData, processPosition: (position: RawSourceMapPosition) => T, host?: { log?(s: string): void }): T[] { + const state: DecoderState = { + encodedText: map.mappings, + currentNameIndex: undefined, + sourceMapNamesLength: map.names ? map.names.length : undefined, + currentEmittedColumn: 0, + currentEmittedLine: 0, + currentSourceColumn: 0, + currentSourceLine: 0, + currentSourceIndex: 0, + positions: [], + decodingIndex: 0, + processPosition, + }; + while (!hasCompletedDecoding(state)) { + decodeSinglePosition(state); + if (state.error) { + if (host && host.log) { + host.log(`Encountered error while decoding sourcemap: ${state.error}`); + } + return []; + } + } + return state.positions; + } + interface ProcessedSourceMapPosition { emittedPosition: number; sourcePosition: number; diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 38ddd0067f0..8e2e3727c60 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -180,7 +180,7 @@ namespace ts { } ), mapDefined(node.prepends, prepend => { if (prepend.kind === SyntaxKind.InputFiles) { - return createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapText); + return createUnparsedSourceFile(prepend.declarationText, prepend.declarationMapPath, prepend.declarationMapText); } })); bundle.syntheticFileReferences = []; diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index b4421506357..6d41e3d36cd 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -100,7 +100,7 @@ namespace ts { function transformBundle(node: Bundle) { return createBundle(node.sourceFiles.map(transformSourceFile), mapDefined(node.prepends, prepend => { if (prepend.kind === SyntaxKind.InputFiles) { - return createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapText); + return createUnparsedSourceFile(prepend.javascriptText, prepend.javascriptMapPath, prepend.javascriptMapText); } return prepend; })); diff --git a/src/compiler/tsconfig.json b/src/compiler/tsconfig.json index 3fd5806d308..20b97c1b778 100644 --- a/src/compiler/tsconfig.json +++ b/src/compiler/tsconfig.json @@ -24,6 +24,7 @@ "checker.ts", "factory.ts", "visitor.ts", + "sourcemapDecoder.ts", "transformers/utilities.ts", "transformers/destructuring.ts", "transformers/ts.ts", diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 29a7e3d8842..7fb2dc0a94f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2615,14 +2615,17 @@ namespace ts { export interface InputFiles extends Node { kind: SyntaxKind.InputFiles; javascriptText: string; + javascriptMapPath?: string; javascriptMapText?: string; declarationText: string; + declarationMapPath?: string; declarationMapText?: string; } export interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; text: string; + sourceMapPath?: string; sourceMapText?: string; } @@ -2807,7 +2810,7 @@ namespace ts { sourceMapFile: string; // Source map's file field - .js file name sourceMapSourceRoot: string; // Source map's sourceRoot field - location where the sources will be present if not "" sourceMapSources: string[]; // Source map's sources field - list of sources that can be indexed in this source map - sourceMapSourcesContent?: string[]; // Source map's sourcesContent field - list of the sources' text to be embedded in the source map + sourceMapSourcesContent?: (string | null)[]; // Source map's sourcesContent field - list of the sources' text to be embedded in the source map inputSourceFileNames: string[]; // Input source file (which one can use on program to get the file), 1:1 mapping with the sourceMapSources list sourceMapNames?: string[]; // Source map's names field - list of names that can be indexed in this source map sourceMapMappings: string; // Source map's mapping field - encoded source map spans diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 7516fca73bb..587ed7be81d 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2715,7 +2715,7 @@ namespace ts { return getOperatorPrecedence(expression.kind, operator, hasArguments); } - export function getOperator(expression: Expression) { + export function getOperator(expression: Expression): SyntaxKind { if (expression.kind === SyntaxKind.BinaryExpression) { return (expression).operatorToken.kind; } diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index add68869804..b50ede11693 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -486,12 +486,18 @@ + + + + + + @@ -960,6 +966,15 @@ + + + + + + + + + @@ -1029,6 +1044,15 @@ + + + + + + + + + @@ -1773,18 +1797,27 @@ + + + + + + + + + @@ -2865,6 +2898,9 @@ + + + @@ -3327,6 +3363,9 @@ + + + @@ -5760,6 +5799,9 @@ + + + @@ -5802,6 +5844,9 @@ + + + @@ -6240,42 +6285,63 @@ + + + + + + + + + + + + + + + + + + + + + @@ -6291,6 +6357,9 @@ + + + @@ -6756,6 +6825,15 @@ + + + + + + + + + @@ -7332,6 +7410,9 @@ + + + @@ -7356,12 +7437,18 @@ + + + + + + @@ -8976,6 +9063,9 @@ + + + @@ -9531,6 +9621,9 @@ + + + diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index 1d250c68944..83593091330 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -492,6 +492,24 @@ + + + + + + + + + + + + + + + + + + @@ -957,6 +975,15 @@ + + + + + + + + + @@ -1026,6 +1053,15 @@ + + + + + + + + + @@ -1767,6 +1803,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2841,6 +2904,15 @@ + + + + + + + + + @@ -3297,6 +3369,15 @@ + + + + + + + + + @@ -5724,6 +5805,15 @@ + + + + + + + + + @@ -5760,6 +5850,15 @@ + + + + + + + + + @@ -6192,6 +6291,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -6201,6 +6363,15 @@ + + + + + + + + + @@ -6663,6 +6834,15 @@ + + + + + + + + + @@ -7236,6 +7416,15 @@ + + + + + + + + + @@ -7254,6 +7443,24 @@ + + + + + + + + + + + + + + + + + + @@ -8862,6 +9069,15 @@ + + + + + + + + + @@ -9411,6 +9627,15 @@ + + + + + + + + + diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index 2a1883d8c1e..0ff080e40e2 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -486,12 +486,18 @@ + + + + + + @@ -957,6 +963,15 @@ + + + + + + + + + @@ -1026,6 +1041,15 @@ + + + + + + + + + @@ -1770,18 +1794,27 @@ + + + + + + + + + @@ -2862,6 +2895,9 @@ + + + @@ -3324,6 +3360,9 @@ + + + @@ -5757,6 +5796,9 @@ + + + @@ -5799,6 +5841,9 @@ + + + @@ -6234,42 +6279,63 @@ + + + + + + + + + + + + + + + + + + + + + @@ -6285,6 +6351,9 @@ + + + @@ -6750,6 +6819,15 @@ + + + + + + + + + @@ -7326,6 +7404,9 @@ + + + @@ -7350,12 +7431,18 @@ + + + + + + @@ -8970,6 +9057,9 @@ + + + @@ -9525,6 +9615,9 @@ + + + diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index e77d6f627be..53d9f253606 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -486,12 +486,18 @@ + + + + + + @@ -960,6 +966,15 @@ + + + + + + + + + @@ -1029,6 +1044,15 @@ + + + + + + + + + @@ -1773,18 +1797,27 @@ + + + + + + + + + @@ -2865,6 +2898,9 @@ + + + @@ -3327,6 +3363,9 @@ + + + @@ -5760,6 +5799,9 @@ + + + @@ -5802,6 +5844,9 @@ + + + @@ -6240,42 +6285,63 @@ + + + + + + + + + + + + + + + + + + + + + @@ -6291,6 +6357,9 @@ + + + @@ -6756,6 +6825,15 @@ + + + + + + + + + @@ -7332,6 +7410,9 @@ + + + @@ -7356,12 +7437,18 @@ + + + + + + @@ -8976,6 +9063,9 @@ + + + @@ -9531,6 +9621,9 @@ + + + diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 44a886375ac..e3d5959f0c7 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -486,12 +486,18 @@ + + + + + + @@ -960,6 +966,15 @@ + + + + + + + + + @@ -1029,6 +1044,15 @@ + + + + + + + + + @@ -1773,18 +1797,27 @@ + + + + + + + + + @@ -2865,6 +2898,9 @@ + + + @@ -3327,6 +3363,9 @@ + + + @@ -5760,6 +5799,9 @@ + + + @@ -5802,6 +5844,9 @@ + + + @@ -6240,42 +6285,63 @@ + + + + + + + + + + + + + + + + + + + + + @@ -6291,6 +6357,9 @@ + + + @@ -6756,6 +6825,15 @@ + + + + + + + + + @@ -7332,6 +7410,9 @@ + + + @@ -7356,12 +7437,18 @@ + + + + + + @@ -8976,6 +9063,9 @@ + + + @@ -9531,6 +9621,9 @@ + + + diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index b1b6f42bfd0..43e457e6907 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -479,12 +479,18 @@ + + + + + + @@ -1799,6 +1805,9 @@ + + + @@ -6308,6 +6317,9 @@ + + + @@ -7385,6 +7397,9 @@ + + + @@ -7418,6 +7433,9 @@ + + + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index 3d48517da31..54b82d0468e 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -479,12 +479,18 @@ + + + + + + @@ -950,6 +956,15 @@ + + + + + + + + + @@ -1022,6 +1037,15 @@ + + + + + + + + + @@ -1766,18 +1790,27 @@ + + + + + + + + + @@ -2858,6 +2891,9 @@ + + + @@ -3320,6 +3356,9 @@ + + + @@ -5753,6 +5792,9 @@ + + + @@ -5795,6 +5837,9 @@ + + + @@ -6230,42 +6275,63 @@ + + + + + + + + + + + + + + + + + + + + + @@ -6281,6 +6347,9 @@ + + + @@ -6746,6 +6815,15 @@ + + + + + + + + + @@ -7322,6 +7400,9 @@ + + + @@ -7346,12 +7427,18 @@ + + + + + + @@ -8966,6 +9053,9 @@ + + + @@ -9521,6 +9611,9 @@ + + + diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index 8afbc6c8d0b..f60ca0af9ef 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -485,12 +485,18 @@ + + + + + + @@ -962,6 +968,9 @@ + + + @@ -1037,6 +1046,9 @@ + + + @@ -1784,18 +1796,27 @@ + + + + + + + + + @@ -2876,6 +2897,9 @@ + + + @@ -3338,6 +3362,9 @@ + + + @@ -5771,6 +5798,9 @@ + + + @@ -5813,6 +5843,9 @@ + + + @@ -6251,42 +6284,63 @@ + + + + + + + + + + + + + + + + + + + + + @@ -6302,6 +6356,9 @@ + + + @@ -6770,6 +6827,9 @@ + + + @@ -7349,6 +7409,9 @@ + + + @@ -7373,12 +7436,18 @@ + + + + + + @@ -8993,6 +9062,9 @@ + + + @@ -9548,6 +9620,9 @@ + + + diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 04335da0e83..a3e1086594a 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -479,12 +479,18 @@ + + + + + + @@ -953,6 +959,15 @@ + + + + + + + + + @@ -1022,6 +1037,15 @@ + + + + + + + + + @@ -1766,18 +1790,27 @@ + + + + + + + + + @@ -2858,6 +2891,9 @@ + + + @@ -3320,6 +3356,9 @@ + + + @@ -5753,6 +5792,9 @@ + + + @@ -5795,6 +5837,9 @@ + + + @@ -6233,42 +6278,63 @@ + + + + + + + + + + + + + + + + + + + + + @@ -6284,6 +6350,9 @@ + + + @@ -6749,6 +6818,15 @@ + + + + + + + + + @@ -7325,6 +7403,9 @@ + + + @@ -7349,12 +7430,18 @@ + + + + + + @@ -8969,6 +9056,9 @@ + + + @@ -9524,6 +9614,9 @@ + + + diff --git a/src/services/services.ts b/src/services/services.ts index db0213ed88a..24feaac17c6 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1111,35 +1111,6 @@ namespace ts { } } - /* @internal */ - export interface SourceFileLikeCache { - get(path: Path): SourceFileLike | undefined; - } - - /* @internal */ - export function createSourceFileLikeCache(host: { readFile?: (path: string) => string | undefined, fileExists?: (path: string) => boolean }): SourceFileLikeCache { - const cached = createMap(); - return { - get(path: Path) { - if (cached.has(path)) { - return cached.get(path); - } - if (!host.fileExists || !host.readFile || !host.fileExists(path)) return; - // And failing that, check the disk - const text = host.readFile(path)!; // TODO: GH#18217 - const file: SourceFileLike = { - text, - lineMap: undefined, - getLineAndCharacterOfPosition(pos) { - return computeLineAndCharacterOfPosition(getLineStarts(this), pos); - } - }; - cached.set(path, file); - return file; - } - }; - } - export function createLanguageService( host: LanguageServiceHost, documentRegistry: DocumentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()), diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 8f89c72f502..9318bbe4469 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -76,7 +76,6 @@ "refactors/generateGetAccessorAndSetAccessor.ts", "refactors/moveToNewFile.ts", "refactors/addOrRemoveBracesToArrowFunction.ts", - "sourcemaps.ts", "services.ts", "breakpoints.ts", "transform.ts", diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 6b7e62d9269..1652f2f0739 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2365,13 +2365,16 @@ declare namespace ts { interface InputFiles extends Node { kind: SyntaxKind.InputFiles; javascriptText: string; + javascriptMapPath?: string; javascriptMapText?: string; declarationText: string; + declarationMapPath?: string; declarationMapText?: string; } interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; text: string; + sourceMapPath?: string; sourceMapText?: string; } interface JsonSourceFile extends SourceFile { @@ -2510,7 +2513,7 @@ declare namespace ts { sourceMapFile: string; sourceMapSourceRoot: string; sourceMapSources: string[]; - sourceMapSourcesContent?: string[]; + sourceMapSourcesContent?: (string | null)[]; inputSourceFileNames: string[]; sourceMapNames?: string[]; sourceMapMappings: string; @@ -6350,7 +6353,7 @@ declare namespace ts { function getExpressionAssociativity(expression: Expression): Associativity; function getOperatorAssociativity(kind: SyntaxKind, operator: SyntaxKind, hasArguments?: boolean): Associativity; function getExpressionPrecedence(expression: Expression): number; - function getOperator(expression: Expression): SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia | SyntaxKind.NumericLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral | SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail | SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.BarBarToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken | SyntaxKind.Identifier | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.LetKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.StaticKeyword | SyntaxKind.YieldKeyword | SyntaxKind.AbstractKeyword | SyntaxKind.AsKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.GetKeyword | SyntaxKind.InferKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.RequireKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.SetKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.TypeKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.FromKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.OfKeyword | SyntaxKind.QualifiedName | SyntaxKind.ComputedPropertyName | SyntaxKind.TypeParameter | SyntaxKind.Parameter | SyntaxKind.Decorator | SyntaxKind.PropertySignature | SyntaxKind.PropertyDeclaration | SyntaxKind.MethodSignature | SyntaxKind.MethodDeclaration | SyntaxKind.Constructor | SyntaxKind.GetAccessor | SyntaxKind.SetAccessor | SyntaxKind.CallSignature | SyntaxKind.ConstructSignature | SyntaxKind.IndexSignature | SyntaxKind.TypePredicate | SyntaxKind.TypeReference | SyntaxKind.FunctionType | SyntaxKind.ConstructorType | SyntaxKind.TypeQuery | SyntaxKind.TypeLiteral | SyntaxKind.ArrayType | SyntaxKind.TupleType | SyntaxKind.UnionType | SyntaxKind.IntersectionType | SyntaxKind.ConditionalType | SyntaxKind.InferType | SyntaxKind.ParenthesizedType | SyntaxKind.ThisType | SyntaxKind.TypeOperator | SyntaxKind.IndexedAccessType | SyntaxKind.MappedType | SyntaxKind.LiteralType | SyntaxKind.ImportType | SyntaxKind.ObjectBindingPattern | SyntaxKind.ArrayBindingPattern | SyntaxKind.BindingElement | SyntaxKind.ArrayLiteralExpression | SyntaxKind.ObjectLiteralExpression | SyntaxKind.PropertyAccessExpression | SyntaxKind.ElementAccessExpression | SyntaxKind.CallExpression | SyntaxKind.NewExpression | SyntaxKind.TaggedTemplateExpression | SyntaxKind.TypeAssertionExpression | SyntaxKind.ParenthesizedExpression | SyntaxKind.FunctionExpression | SyntaxKind.ArrowFunction | SyntaxKind.DeleteExpression | SyntaxKind.TypeOfExpression | SyntaxKind.VoidExpression | SyntaxKind.AwaitExpression | SyntaxKind.ConditionalExpression | SyntaxKind.TemplateExpression | SyntaxKind.YieldExpression | SyntaxKind.SpreadElement | SyntaxKind.ClassExpression | SyntaxKind.OmittedExpression | SyntaxKind.ExpressionWithTypeArguments | SyntaxKind.AsExpression | SyntaxKind.NonNullExpression | SyntaxKind.MetaProperty | SyntaxKind.TemplateSpan | SyntaxKind.SemicolonClassElement | SyntaxKind.Block | SyntaxKind.VariableStatement | SyntaxKind.EmptyStatement | SyntaxKind.ExpressionStatement | SyntaxKind.IfStatement | SyntaxKind.DoStatement | SyntaxKind.WhileStatement | SyntaxKind.ForStatement | SyntaxKind.ForInStatement | SyntaxKind.ForOfStatement | SyntaxKind.ContinueStatement | SyntaxKind.BreakStatement | SyntaxKind.ReturnStatement | SyntaxKind.WithStatement | SyntaxKind.SwitchStatement | SyntaxKind.LabeledStatement | SyntaxKind.ThrowStatement | SyntaxKind.TryStatement | SyntaxKind.DebuggerStatement | SyntaxKind.VariableDeclaration | SyntaxKind.VariableDeclarationList | SyntaxKind.FunctionDeclaration | SyntaxKind.ClassDeclaration | SyntaxKind.InterfaceDeclaration | SyntaxKind.TypeAliasDeclaration | SyntaxKind.EnumDeclaration | SyntaxKind.ModuleDeclaration | SyntaxKind.ModuleBlock | SyntaxKind.CaseBlock | SyntaxKind.NamespaceExportDeclaration | SyntaxKind.ImportEqualsDeclaration | SyntaxKind.ImportDeclaration | SyntaxKind.ImportClause | SyntaxKind.NamespaceImport | SyntaxKind.NamedImports | SyntaxKind.ImportSpecifier | SyntaxKind.ExportAssignment | SyntaxKind.ExportDeclaration | SyntaxKind.NamedExports | SyntaxKind.ExportSpecifier | SyntaxKind.MissingDeclaration | SyntaxKind.ExternalModuleReference | SyntaxKind.JsxElement | SyntaxKind.JsxSelfClosingElement | SyntaxKind.JsxOpeningElement | SyntaxKind.JsxClosingElement | SyntaxKind.JsxFragment | SyntaxKind.JsxOpeningFragment | SyntaxKind.JsxClosingFragment | SyntaxKind.JsxAttribute | SyntaxKind.JsxAttributes | SyntaxKind.JsxSpreadAttribute | SyntaxKind.JsxExpression | SyntaxKind.CaseClause | SyntaxKind.DefaultClause | SyntaxKind.HeritageClause | SyntaxKind.CatchClause | SyntaxKind.PropertyAssignment | SyntaxKind.ShorthandPropertyAssignment | SyntaxKind.SpreadAssignment | SyntaxKind.EnumMember | SyntaxKind.SourceFile | SyntaxKind.Bundle | SyntaxKind.UnparsedSource | SyntaxKind.InputFiles | SyntaxKind.JSDocTypeExpression | SyntaxKind.JSDocAllType | SyntaxKind.JSDocUnknownType | SyntaxKind.JSDocNullableType | SyntaxKind.JSDocNonNullableType | SyntaxKind.JSDocOptionalType | SyntaxKind.JSDocFunctionType | SyntaxKind.JSDocVariadicType | SyntaxKind.JSDocComment | SyntaxKind.JSDocTypeLiteral | SyntaxKind.JSDocSignature | SyntaxKind.JSDocTag | SyntaxKind.JSDocAugmentsTag | SyntaxKind.JSDocClassTag | SyntaxKind.JSDocCallbackTag | SyntaxKind.JSDocParameterTag | SyntaxKind.JSDocReturnTag | SyntaxKind.JSDocThisTag | SyntaxKind.JSDocTypeTag | SyntaxKind.JSDocTemplateTag | SyntaxKind.JSDocTypedefTag | SyntaxKind.JSDocPropertyTag | SyntaxKind.SyntaxList | SyntaxKind.NotEmittedStatement | SyntaxKind.PartiallyEmittedExpression | SyntaxKind.CommaListExpression | SyntaxKind.MergeDeclarationMarker | SyntaxKind.EndOfDeclarationMarker | SyntaxKind.Count; + function getOperator(expression: Expression): SyntaxKind; function getOperatorPrecedence(nodeKind: SyntaxKind, operatorKind: SyntaxKind, hasArguments?: boolean): number; function getBinaryOperatorPrecedence(kind: SyntaxKind): number; function createDiagnosticCollection(): DiagnosticCollection; @@ -8002,8 +8005,10 @@ declare namespace ts { function createCommaList(elements: ReadonlyArray): CommaListExpression; function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; - function createUnparsedSourceFile(text: string, map?: string): UnparsedSource; - function createInputFiles(javascript: string, declaration: string, javascriptMapText?: string, declarationMapText?: string): InputFiles; + function createUnparsedSourceFile(text: string): UnparsedSource; + function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; + function createInputFiles(javascript: string, declaration: string): InputFiles; + function createInputFiles(javascript: string, declaration: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; @@ -8492,6 +8497,56 @@ declare namespace ts { function enableDebugInfo(): void; } } +declare namespace ts { + interface SourceFileLikeCache { + get(path: Path): SourceFileLike | undefined; + } + function createSourceFileLikeCache(host: { + readFile?: (path: string) => string | undefined; + fileExists?: (path: string) => boolean; + }): SourceFileLikeCache; +} +declare namespace ts.sourcemaps { + interface SourceMapData { + version?: number; + file?: string; + sourceRoot?: string; + sources: string[]; + sourcesContent?: (string | null)[]; + names?: string[]; + mappings: string; + } + interface SourceMappableLocation { + fileName: string; + position: number; + } + interface SourceMapper { + getOriginalPosition(input: SourceMappableLocation): SourceMappableLocation; + getGeneratedPosition(input: SourceMappableLocation): SourceMappableLocation; + } + const identitySourceMapper: { + getOriginalPosition: typeof identity; + getGeneratedPosition: typeof identity; + }; + interface SourceMapDecodeHost { + readFile(path: string): string | undefined; + fileExists(path: string): boolean; + getCanonicalFileName(path: string): string; + log(text: string): void; + } + function decode(host: SourceMapDecodeHost, mapPath: string, map: SourceMapData, program?: Program, fallbackCache?: SourceFileLikeCache): SourceMapper; + function calculateDecodedMappings(map: SourceMapData, processPosition: (position: RawSourceMapPosition) => T, host?: { + log?(s: string): void; + }): T[]; + interface RawSourceMapPosition { + emittedLine: number; + emittedColumn: number; + sourceLine: number; + sourceColumn: number; + sourceIndex: number; + nameIndex?: number; + } +} declare namespace ts { function getOriginalNodeId(node: Node): number; interface ExternalModuleInfo { @@ -11656,36 +11711,6 @@ declare namespace ts.refactor { } declare namespace ts.refactor.addOrRemoveBracesToArrowFunction { } -declare namespace ts.sourcemaps { - interface SourceMapData { - version?: number; - file?: string; - sourceRoot?: string; - sources: string[]; - sourcesContent?: string[]; - names?: string[]; - mappings: string; - } - interface SourceMappableLocation { - fileName: string; - position: number; - } - interface SourceMapper { - getOriginalPosition(input: SourceMappableLocation): SourceMappableLocation; - getGeneratedPosition(input: SourceMappableLocation): SourceMappableLocation; - } - const identitySourceMapper: { - getOriginalPosition: typeof identity; - getGeneratedPosition: typeof identity; - }; - interface SourceMapDecodeHost { - readFile(path: string): string | undefined; - fileExists(path: string): boolean; - getCanonicalFileName(path: string): string; - log(text: string): void; - } - function decode(host: SourceMapDecodeHost, mapPath: string, map: SourceMapData, program?: Program, fallbackCache?: SourceFileLikeCache): SourceMapper; -} declare namespace ts { /** The version of the language service API */ const servicesVersion = "0.8"; @@ -11709,13 +11734,6 @@ declare namespace ts { isCancellationRequested(): boolean; throwIfCancellationRequested(): void; } - interface SourceFileLikeCache { - get(path: Path): SourceFileLike | undefined; - } - function createSourceFileLikeCache(host: { - readFile?: (path: string) => string | undefined; - fileExists?: (path: string) => boolean; - }): SourceFileLikeCache; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry, syntaxOnly?: boolean): LanguageService; /** Names in the name table are escaped, so an identifier `__foo` will have a name table entry `___foo`. */ function getNameTable(sourceFile: SourceFile): UnderscoreEscapedMap; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index eb536b3fcd5..8957458e10a 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -1674,13 +1674,16 @@ declare namespace ts { interface InputFiles extends Node { kind: SyntaxKind.InputFiles; javascriptText: string; + javascriptMapPath?: string; javascriptMapText?: string; declarationText: string; + declarationMapPath?: string; declarationMapText?: string; } interface UnparsedSource extends Node { kind: SyntaxKind.UnparsedSource; text: string; + sourceMapPath?: string; sourceMapText?: string; } interface JsonSourceFile extends SourceFile { @@ -1787,7 +1790,7 @@ declare namespace ts { sourceMapFile: string; sourceMapSourceRoot: string; sourceMapSources: string[]; - sourceMapSourcesContent?: string[]; + sourceMapSourcesContent?: (string | null)[]; inputSourceFileNames: string[]; sourceMapNames?: string[]; sourceMapMappings: string; @@ -3909,8 +3912,10 @@ declare namespace ts { function createCommaList(elements: ReadonlyArray): CommaListExpression; function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; function createBundle(sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; - function createUnparsedSourceFile(text: string, map?: string): UnparsedSource; - function createInputFiles(javascript: string, declaration: string, javascriptMapText?: string, declarationMapText?: string): InputFiles; + function createUnparsedSourceFile(text: string): UnparsedSource; + function createUnparsedSourceFile(text: string, mapPath: string | undefined, map: string | undefined): UnparsedSource; + function createInputFiles(javascript: string, declaration: string): InputFiles; + function createInputFiles(javascript: string, declaration: string, javascriptMapPath: string | undefined, javascriptMapText: string | undefined, declarationMapPath: string | undefined, declarationMapText: string | undefined): InputFiles; function updateBundle(node: Bundle, sourceFiles: ReadonlyArray, prepends?: ReadonlyArray): Bundle; function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray): CallExpression; function createImmediatelyInvokedFunctionExpression(statements: ReadonlyArray, param: ParameterDeclaration, paramValue: Expression): CallExpression; diff --git a/tests/baselines/reference/conflictingCommonJSES2015Exports.symbols b/tests/baselines/reference/conflictingCommonJSES2015Exports.symbols new file mode 100644 index 00000000000..b022439bf31 --- /dev/null +++ b/tests/baselines/reference/conflictingCommonJSES2015Exports.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/salsa/bug24934.js === +export function abc(a, b, c) { return 5; } +>abc : Symbol(abc, Decl(bug24934.js, 0, 0)) +>a : Symbol(a, Decl(bug24934.js, 0, 20)) +>b : Symbol(b, Decl(bug24934.js, 0, 22)) +>c : Symbol(c, Decl(bug24934.js, 0, 25)) + +module.exports = { abc }; +>module : Symbol(module) +>abc : Symbol(abc, Decl(bug24934.js, 1, 18)) + +=== tests/cases/conformance/salsa/use.js === +import { abc } from './bug24934'; +>abc : Symbol(abc, Decl(use.js, 0, 8)) + +abc(1, 2, 3); +>abc : Symbol(abc, Decl(use.js, 0, 8)) + diff --git a/tests/baselines/reference/conflictingCommonJSES2015Exports.types b/tests/baselines/reference/conflictingCommonJSES2015Exports.types new file mode 100644 index 00000000000..a9dc1ce80bd --- /dev/null +++ b/tests/baselines/reference/conflictingCommonJSES2015Exports.types @@ -0,0 +1,27 @@ +=== tests/cases/conformance/salsa/bug24934.js === +export function abc(a, b, c) { return 5; } +>abc : (a: any, b: any, c: any) => number +>a : any +>b : any +>c : any +>5 : 5 + +module.exports = { abc }; +>module.exports = { abc } : { [x: string]: any; abc: (a: any, b: any, c: any) => number; } +>module.exports : any +>module : any +>exports : any +>{ abc } : { [x: string]: any; abc: (a: any, b: any, c: any) => number; } +>abc : (a: any, b: any, c: any) => number + +=== tests/cases/conformance/salsa/use.js === +import { abc } from './bug24934'; +>abc : (a: any, b: any, c: any) => number + +abc(1, 2, 3); +>abc(1, 2, 3) : number +>abc : (a: any, b: any, c: any) => number +>1 : 1 +>2 : 2 +>3 : 3 + diff --git a/tests/baselines/reference/outfile-concat.js b/tests/baselines/reference/outfile-concat.js index 22c69281e13..9c1c1e39f11 100644 --- a/tests/baselines/reference/outfile-concat.js +++ b/tests/baselines/reference/outfile-concat.js @@ -80,7 +80,7 @@ declare var c: C; //# sourceMappingURL=third-output.d.ts.map //// [/src/third/thirdjs/output/third-output.d.ts.map] -{"version":3,"file":"third-output.d.ts","sections":[{"offset":{"line":0,"column":0},"map":{"version":3,"file":"first-output.d.ts","sourceRoot":"","sources":["../first_part1.ts","../first_part2.ts","../first_part3.ts"],"names":[],"mappings":"AAAA,UAAU,QAAQ;IACd,IAAI,EAAE,GAAG,CAAC;CACb;AAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;AAEzB,UAAU,iBAAiB;IACvB,IAAI,EAAE,GAAG,CAAC;CACb;AERD,6BAEC"}},{"offset":{"line":9,"column":0},"map":{"version":3,"file":"second-output.d.ts","sourceRoot":"","sources":["../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAAA,kBAAU,CAAC,CAAC;CAEX;AAED,kBAAU,CAAC,CAAC;CAMX;ACVD;IACI,WAAW;CAGd"}},{"offset":{"line":16,"column":43},"map":{"version":3,"file":"third-output.d.ts","sourceRoot":"","sources":["../../third_part1.ts"],"names":[],"mappings":";AAAA,QAAA,IAAI,CAAC,GAAU,CAAC"}}]} +{"version":3,"file":"third-output.d.ts","sourceRoot":"","sources":["../../third_part1.ts","../../../first/first_part1.ts","../../../first/first_part3.ts","../../../second/second_part1.ts","../../../second/second_part2.ts"],"names":[],"mappings":"DCDD,UAAU,QAAQ;GACd,IAAI,EAAE,GAAG,CAAC;AACb;DAED,QAAA,MAAM,CAAC,iBAAiB,CAAC;DAEzB,UAAU,iBAAiB;GACvB,IAAI,EAAE,GAAG,CAAC;AACb;DCRD,6BAEC;;DCFD,kBAAU,CAAC,CAAC;AAEX;DAED,kBAAU,CAAC,CAAC;AAMX;DCVD;GACI,WAAW;AAGd;;;AJHA,QAAA,IAAI,CAAC,GAAU,CAAC"} //// [/src/third/thirdjs/output/third-output.js] var s = "Hello, world"; @@ -111,5 +111,5 @@ c.doSomething(); //# sourceMappingURL=third-output.js.map //// [/src/third/thirdjs/output/third-output.js.map] -{"version":3,"file":"third-output.js","sections":[{"offset":{"line":0,"column":0},"map":{"version":3,"file":"first-output.js","sourceRoot":"","sources":["../first_part1.ts","../first_part2.ts","../first_part3.ts"],"names":[],"mappings":"AAIA,IAAM,CAAC,GAAG,cAAc,CAAC;AAMzB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;ACVf,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;ACAjB;IACI,OAAO,gBAAgB,CAAC;AAC5B,CAAC"}},{"offset":{"line":7,"column":0},"map":{"version":3,"file":"second-output.js","sourceRoot":"","sources":["../second/second_part1.ts","../second/second_part2.ts"],"names":[],"mappings":"AAIA,IAAU,CAAC,CAMV;AAND,WAAU,CAAC;IACP;QACI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAED,CAAC,EAAE,CAAC;AACR,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;ACVD;IAAA;IAIA,CAAC;IAHG,uBAAW,GAAX;QACI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACtC,CAAC;IACL,QAAC;AAAD,CAAC,AAJD,IAIC"}},{"offset":{"line":22,"column":41},"map":{"version":3,"file":"third-output.js","sourceRoot":"","sources":["../../third_part1.ts"],"names":[],"mappings":";AAAA,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AAChB,CAAC,CAAC,WAAW,EAAE,CAAC"}}]} +{"version":3,"file":"third-output.js","sourceRoot":"","sources":["../../third_part1.ts","../../../first/first_part1.ts","../../../first/first_part2.ts","../../../first/first_part3.ts","../../../second/second_part1.ts","../../../second/second_part2.ts"],"names":[],"mappings":"DCGD,IAAM,CAAC,GAAG,cAAc,CAAC;DAMzB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;DCVf,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;DCAjB;GACI,OAAO,gBAAgB,CAAC;DAC5B,CAAC;;DCED,IAAU,CAAC,CAMV;DAND,WAAU,CAAC;GACP;OACI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;GAC3B,CAAC;GAED,CAAC,EAAE,CAAC;DACR,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;DCVD;GAAA;GAIA,CAAC;GAHG,uBAAW,GAAX;OACI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;GACtC,CAAC;GACL,QAAC;DAAD,CAAC,AAJD,IAIC;;;ALHA,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AAChB,CAAC,CAAC,WAAW,EAAE,CAAC"} diff --git a/tests/baselines/reference/symbolLinkDeclarationEmitModuleNamesRootDir.js b/tests/baselines/reference/symbolLinkDeclarationEmitModuleNamesRootDir.js new file mode 100644 index 00000000000..a95fb2c694d --- /dev/null +++ b/tests/baselines/reference/symbolLinkDeclarationEmitModuleNamesRootDir.js @@ -0,0 +1,87 @@ +//// [tests/cases/compiler/symbolLinkDeclarationEmitModuleNamesRootDir.ts] //// + +//// [value-promise.d.ts] +export type Constructor = (...args: any[]) => T; +//// [bindingkey.d.ts] +import { Constructor } from "./value-promise" +export declare class BindingKey { + readonly __type: T; + static create>(ctor: T): BindingKey; +} + +//// [index.d.ts] +export * from "./src/value-promise"; +export * from "./src/bindingkey"; + +//// [application.ts] +import { Constructor } from "@loopback/context"; +export type ControllerClass = Constructor; + +//// [usage.ts] +import { ControllerClass } from './application'; +import { BindingKey } from '@loopback/context'; + +export const CONTROLLER_CLASS = BindingKey.create(null as any); // line in question + + +//// [application.js] +"use strict"; +exports.__esModule = true; +//// [usage.js] +"use strict"; +exports.__esModule = true; +var context_1 = require("@loopback/context"); +exports.CONTROLLER_CLASS = context_1.BindingKey.create(null); // line in question + + +//// [application.d.ts] +import { Constructor } from "@loopback/context"; +export declare type ControllerClass = Constructor; +//// [usage.d.ts] +import { BindingKey } from '@loopback/context'; +export declare const CONTROLLER_CLASS: BindingKey>; + + +//// [DtsFileErrors] + + +tests/cases/compiler/monorepo/core/dist/src/application.d.ts(1,29): error TS2307: Cannot find module '@loopback/context'. +tests/cases/compiler/monorepo/core/dist/src/usage.d.ts(1,28): error TS2307: Cannot find module '@loopback/context'. +tests/cases/compiler/monorepo/core/dist/src/usage.d.ts(2,51): error TS2307: Cannot find module '@loopback/context/src/value-promise'. + + +==== tests/cases/compiler/monorepo/core/tsconfig.json (0 errors) ==== + { + "compilerOptions": { + "rootDir": ".", + "declaration": true, + "outDir": "./dist" + } + } +==== tests/cases/compiler/monorepo/context/src/value-promise.d.ts (0 errors) ==== + export type Constructor = (...args: any[]) => T; +==== tests/cases/compiler/monorepo/context/src/bindingkey.d.ts (0 errors) ==== + import { Constructor } from "./value-promise" + export declare class BindingKey { + readonly __type: T; + static create>(ctor: T): BindingKey; + } + +==== tests/cases/compiler/monorepo/context/index.d.ts (0 errors) ==== + export * from "./src/value-promise"; + export * from "./src/bindingkey"; + +==== tests/cases/compiler/monorepo/core/dist/src/application.d.ts (1 errors) ==== + import { Constructor } from "@loopback/context"; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module '@loopback/context'. + export declare type ControllerClass = Constructor; + +==== tests/cases/compiler/monorepo/core/dist/src/usage.d.ts (2 errors) ==== + import { BindingKey } from '@loopback/context'; + ~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module '@loopback/context'. + export declare const CONTROLLER_CLASS: BindingKey>; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find module '@loopback/context/src/value-promise'. + \ No newline at end of file diff --git a/tests/baselines/reference/symbolLinkDeclarationEmitModuleNamesRootDir.symbols b/tests/baselines/reference/symbolLinkDeclarationEmitModuleNamesRootDir.symbols new file mode 100644 index 00000000000..a00e7c438b1 --- /dev/null +++ b/tests/baselines/reference/symbolLinkDeclarationEmitModuleNamesRootDir.symbols @@ -0,0 +1,55 @@ +=== tests/cases/compiler/monorepo/context/src/value-promise.d.ts === +export type Constructor = (...args: any[]) => T; +>Constructor : Symbol(Constructor, Decl(value-promise.d.ts, 0, 0)) +>T : Symbol(T, Decl(value-promise.d.ts, 0, 24)) +>args : Symbol(args, Decl(value-promise.d.ts, 0, 30)) +>T : Symbol(T, Decl(value-promise.d.ts, 0, 24)) + +=== tests/cases/compiler/monorepo/context/src/bindingkey.d.ts === +import { Constructor } from "./value-promise" +>Constructor : Symbol(Constructor, Decl(bindingkey.d.ts, 0, 8)) + +export declare class BindingKey { +>BindingKey : Symbol(BindingKey, Decl(bindingkey.d.ts, 0, 45)) +>T : Symbol(T, Decl(bindingkey.d.ts, 1, 32)) + + readonly __type: T; +>__type : Symbol(BindingKey.__type, Decl(bindingkey.d.ts, 1, 36)) +>T : Symbol(T, Decl(bindingkey.d.ts, 1, 32)) + + static create>(ctor: T): BindingKey; +>create : Symbol(BindingKey.create, Decl(bindingkey.d.ts, 2, 21)) +>T : Symbol(T, Decl(bindingkey.d.ts, 3, 16)) +>Constructor : Symbol(Constructor, Decl(bindingkey.d.ts, 0, 8)) +>ctor : Symbol(ctor, Decl(bindingkey.d.ts, 3, 44)) +>T : Symbol(T, Decl(bindingkey.d.ts, 3, 16)) +>BindingKey : Symbol(BindingKey, Decl(bindingkey.d.ts, 0, 45)) +>T : Symbol(T, Decl(bindingkey.d.ts, 3, 16)) +} + +=== tests/cases/compiler/monorepo/context/index.d.ts === +export * from "./src/value-promise"; +No type information for this code.export * from "./src/bindingkey"; +No type information for this code. +No type information for this code.=== tests/cases/compiler/monorepo/core/src/application.ts === +import { Constructor } from "@loopback/context"; +>Constructor : Symbol(Constructor, Decl(application.ts, 0, 8)) + +export type ControllerClass = Constructor; +>ControllerClass : Symbol(ControllerClass, Decl(application.ts, 0, 48)) +>Constructor : Symbol(Constructor, Decl(application.ts, 0, 8)) + +=== tests/cases/compiler/monorepo/core/src/usage.ts === +import { ControllerClass } from './application'; +>ControllerClass : Symbol(ControllerClass, Decl(usage.ts, 0, 8)) + +import { BindingKey } from '@loopback/context'; +>BindingKey : Symbol(BindingKey, Decl(usage.ts, 1, 8)) + +export const CONTROLLER_CLASS = BindingKey.create(null as any); // line in question +>CONTROLLER_CLASS : Symbol(CONTROLLER_CLASS, Decl(usage.ts, 3, 12)) +>BindingKey.create : Symbol(BindingKey.create, Decl(bindingkey.d.ts, 2, 21)) +>BindingKey : Symbol(BindingKey, Decl(usage.ts, 1, 8)) +>create : Symbol(BindingKey.create, Decl(bindingkey.d.ts, 2, 21)) +>ControllerClass : Symbol(ControllerClass, Decl(usage.ts, 0, 8)) + diff --git a/tests/baselines/reference/symbolLinkDeclarationEmitModuleNamesRootDir.types b/tests/baselines/reference/symbolLinkDeclarationEmitModuleNamesRootDir.types new file mode 100644 index 00000000000..c708cdb94be --- /dev/null +++ b/tests/baselines/reference/symbolLinkDeclarationEmitModuleNamesRootDir.types @@ -0,0 +1,58 @@ +=== tests/cases/compiler/monorepo/context/src/value-promise.d.ts === +export type Constructor = (...args: any[]) => T; +>Constructor : Constructor +>T : T +>args : any[] +>T : T + +=== tests/cases/compiler/monorepo/context/src/bindingkey.d.ts === +import { Constructor } from "./value-promise" +>Constructor : any + +export declare class BindingKey { +>BindingKey : BindingKey +>T : T + + readonly __type: T; +>__type : T +>T : T + + static create>(ctor: T): BindingKey; +>create : >(ctor: T) => BindingKey +>T : T +>Constructor : Constructor +>ctor : T +>T : T +>BindingKey : BindingKey +>T : T +} + +=== tests/cases/compiler/monorepo/context/index.d.ts === +export * from "./src/value-promise"; +No type information for this code.export * from "./src/bindingkey"; +No type information for this code. +No type information for this code.=== tests/cases/compiler/monorepo/core/src/application.ts === +import { Constructor } from "@loopback/context"; +>Constructor : any + +export type ControllerClass = Constructor; +>ControllerClass : Constructor +>Constructor : Constructor + +=== tests/cases/compiler/monorepo/core/src/usage.ts === +import { ControllerClass } from './application'; +>ControllerClass : any + +import { BindingKey } from '@loopback/context'; +>BindingKey : typeof BindingKey + +export const CONTROLLER_CLASS = BindingKey.create(null as any); // line in question +>CONTROLLER_CLASS : BindingKey> +>BindingKey.create(null as any) : BindingKey> +>BindingKey.create : >(ctor: T) => BindingKey +>BindingKey : typeof BindingKey +>create : >(ctor: T) => BindingKey +>ControllerClass : import("tests/cases/compiler/monorepo/context/src/value-promise").Constructor +>null as any : any +>null : null + diff --git a/tests/baselines/reference/third-output.js.map b/tests/baselines/reference/third-output.js.map new file mode 100644 index 00000000000..744f7f7483a --- /dev/null +++ b/tests/baselines/reference/third-output.js.map @@ -0,0 +1 @@ +{"version":3,"file":"third-output.js","sourceRoot":"","sources":["../../third_part1.ts","../../../../first_part1.ts","../../../../first_part2.ts","../../../../first_part3.ts","../../../../second/second_part1.ts","../../../../second/second_part2.ts"],"names":[],"mappings":"DCGD,IAAM,CAAC,GAAG,cAAc,CAAC;DAMzB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;DCVf,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;DCAjB;GACI,OAAO,gBAAgB,CAAC;DAC5B,CAAC;;DCED,IAAU,CAAC,CAMV;DAND,WAAU,CAAC;GACP;OACI,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;GAC3B,CAAC;GAED,CAAC,EAAE,CAAC;DACR,CAAC,EANS,CAAC,KAAD,CAAC,QAMV;DCVD;GAAA;GAIA,CAAC;GAHG,uBAAW,GAAX;OACI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;GACtC,CAAC;GACL,QAAC;DAAD,CAAC,AAJD,IAIC;;;ALHA,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AAChB,CAAC,CAAC,WAAW,EAAE,CAAC"} \ No newline at end of file diff --git a/tests/cases/compiler/symbolLinkDeclarationEmitModuleNamesRootDir.ts b/tests/cases/compiler/symbolLinkDeclarationEmitModuleNamesRootDir.ts new file mode 100644 index 00000000000..fd120ca1e85 --- /dev/null +++ b/tests/cases/compiler/symbolLinkDeclarationEmitModuleNamesRootDir.ts @@ -0,0 +1,33 @@ +// @currentDirectory: monorepo/core +// @filename: monorepo/context/src/value-promise.d.ts +export type Constructor = (...args: any[]) => T; +// @filename: monorepo/context/src/bindingkey.d.ts +import { Constructor } from "./value-promise" +export declare class BindingKey { + readonly __type: T; + static create>(ctor: T): BindingKey; +} + +// @filename: monorepo/context/index.d.ts +export * from "./src/value-promise"; +export * from "./src/bindingkey"; + +// @filename: monorepo/core/tsconfig.json +{ + "compilerOptions": { + "rootDir": ".", + "declaration": true, + "outDir": "./dist" + } +} +// @filename: monorepo/core/src/application.ts +import { Constructor } from "@loopback/context"; +export type ControllerClass = Constructor; + +// @filename: monorepo/core/src/usage.ts +import { ControllerClass } from './application'; +import { BindingKey } from '@loopback/context'; + +export const CONTROLLER_CLASS = BindingKey.create(null as any); // line in question + +// @link: tests/cases/compiler/monorepo/context -> tests/cases/compiler/monorepo/core/node_modules/@loopback/context \ No newline at end of file diff --git a/tests/cases/conformance/salsa/conflictingCommonJSES2015Exports.ts b/tests/cases/conformance/salsa/conflictingCommonJSES2015Exports.ts new file mode 100644 index 00000000000..35acd416e79 --- /dev/null +++ b/tests/cases/conformance/salsa/conflictingCommonJSES2015Exports.ts @@ -0,0 +1,9 @@ +// @checkJs: true +// @allowJS: true +// @noEmit: true +// @Filename: bug24934.js +export function abc(a, b, c) { return 5; } +module.exports = { abc }; +// @Filename: use.js +import { abc } from './bug24934'; +abc(1, 2, 3);