Collect _all_ symlinks a file may have witnessed when attempting to generate specifiers (#31571)

This commit is contained in:
Wesley Wigham 2019-05-23 17:17:24 -07:00 committed by GitHub
parent 8ab0a25211
commit bb4080c175
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 284 additions and 3 deletions

View File

@ -175,9 +175,9 @@ namespace ts.moduleSpecifiers {
function discoverProbableSymlinks(files: ReadonlyArray<SourceFile>, getCanonicalFileName: GetCanonicalFileName, cwd: string): ReadonlyMap<string> {
const result = createMap<string>();
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 symlinks = flatten<readonly [string, string]>(mapDefined(files, sf =>
sf.resolvedModules && compact(arrayFrom(mapIterator(sf.resolvedModules.values(), res =>
res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] as const : undefined)))));
for (const [resolvedPath, originalPath] of symlinks) {
const [commonResolved, commonOriginal] = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName);
result.set(commonOriginal, commonResolved);

View File

@ -0,0 +1,45 @@
//// [tests/cases/compiler/declarationEmitForGlobalishSpecifierSymlink.ts] ////
//// [impl.d.ts]
export function getA(): A;
export enum A {
Val
}
//// [index.d.ts]
export * from "./src/impl";
//// [package.json]
{
"name": "typescript-fsa",
"version": "1.0.0"
}
//// [impl.d.ts]
export function getA(): A;
export enum A {
Val
}
//// [index.d.ts]
export * from "./src/impl";
//// [package.json]
{
"name": "typescript-fsa",
"version": "1.0.0"
}
//// [index.ts]
import * as _whatever from "p2";
import { getA } from "typescript-fsa";
export const a = getA();
//// [index.d.ts]
export const a: import("typescript-fsa").A;
//// [index.js]
"use strict";
exports.__esModule = true;
var typescript_fsa_1 = require("typescript-fsa");
exports.a = typescript_fsa_1.getA();
//// [index.d.ts]
export declare const a: import("typescript-fsa").A;

View File

@ -0,0 +1,43 @@
=== /p1/node_modules/typescript-fsa/src/impl.d.ts ===
export function getA(): A;
>getA : Symbol(getA, Decl(impl.d.ts, 0, 0))
>A : Symbol(A, Decl(impl.d.ts, 0, 26))
export enum A {
>A : Symbol(A, Decl(impl.d.ts, 0, 26))
Val
>Val : Symbol(A.Val, Decl(impl.d.ts, 1, 15))
}
=== /p1/node_modules/typescript-fsa/index.d.ts ===
export * from "./src/impl";
No type information for this code.=== /p2/node_modules/typescript-fsa/src/impl.d.ts ===
export function getA(): A;
>getA : Symbol(getA, Decl(impl.d.ts, 0, 0))
>A : Symbol(A, Decl(impl.d.ts, 0, 26))
export enum A {
>A : Symbol(A, Decl(impl.d.ts, 0, 26))
Val
>Val : Symbol(A.Val, Decl(impl.d.ts, 1, 15))
}
=== /p2/node_modules/typescript-fsa/index.d.ts ===
export * from "./src/impl";
No type information for this code.=== /p1/index.ts ===
import * as _whatever from "p2";
>_whatever : Symbol(_whatever, Decl(index.ts, 0, 6))
import { getA } from "typescript-fsa";
>getA : Symbol(getA, Decl(index.ts, 1, 8))
export const a = getA();
>a : Symbol(a, Decl(index.ts, 3, 12))
>getA : Symbol(getA, Decl(index.ts, 1, 8))
=== /p2/index.d.ts ===
export const a: import("typescript-fsa").A;
>a : Symbol(a, Decl(index.d.ts, 0, 12))
>A : Symbol(A, Decl(impl.d.ts, 0, 26))

View File

@ -0,0 +1,41 @@
=== /p1/node_modules/typescript-fsa/src/impl.d.ts ===
export function getA(): A;
>getA : () => A
export enum A {
>A : A
Val
>Val : A
}
=== /p1/node_modules/typescript-fsa/index.d.ts ===
export * from "./src/impl";
No type information for this code.=== /p2/node_modules/typescript-fsa/src/impl.d.ts ===
export function getA(): A;
>getA : () => A
export enum A {
>A : A
Val
>Val : A
}
=== /p2/node_modules/typescript-fsa/index.d.ts ===
export * from "./src/impl";
No type information for this code.=== /p1/index.ts ===
import * as _whatever from "p2";
>_whatever : typeof _whatever
import { getA } from "typescript-fsa";
>getA : () => import("/p1/node_modules/typescript-fsa/index").A
export const a = getA();
>a : import("/p1/node_modules/typescript-fsa/index").A
>getA() : import("/p1/node_modules/typescript-fsa/index").A
>getA : () => import("/p1/node_modules/typescript-fsa/index").A
=== /p2/index.d.ts ===
export const a: import("typescript-fsa").A;
>a : import("/p2/node_modules/typescript-fsa/index").A

View File

@ -0,0 +1,33 @@
//// [tests/cases/compiler/declarationEmitForGlobalishSpecifierSymlink2.ts] ////
//// [impl.d.ts]
export function getA(): A;
export enum A {
Val
}
//// [index.d.ts]
export * from "./src/impl";
//// [package.json]
{
"name": "typescript-fsa",
"version": "1.0.0"
}
//// [index.ts]
import * as _whatever from "p2";
import { getA } from "typescript-fsa";
export const a = getA();
//// [index.d.ts]
export const a: import("typescript-fsa").A;
//// [index.js]
"use strict";
exports.__esModule = true;
var typescript_fsa_1 = require("typescript-fsa");
exports.a = typescript_fsa_1.getA();
//// [index.d.ts]
export declare const a: import("typescript-fsa").A;

View File

@ -0,0 +1,30 @@
=== /cache/typescript-fsa/src/impl.d.ts ===
export function getA(): A;
>getA : Symbol(getA, Decl(impl.d.ts, 0, 0))
>A : Symbol(A, Decl(impl.d.ts, 0, 26))
export enum A {
>A : Symbol(A, Decl(impl.d.ts, 0, 26))
Val
>Val : Symbol(A.Val, Decl(impl.d.ts, 1, 15))
}
=== /cache/typescript-fsa/index.d.ts ===
export * from "./src/impl";
No type information for this code.=== /p1/index.ts ===
import * as _whatever from "p2";
>_whatever : Symbol(_whatever, Decl(index.ts, 0, 6))
import { getA } from "typescript-fsa";
>getA : Symbol(getA, Decl(index.ts, 1, 8))
export const a = getA();
>a : Symbol(a, Decl(index.ts, 3, 12))
>getA : Symbol(getA, Decl(index.ts, 1, 8))
=== /p2/index.d.ts ===
export const a: import("typescript-fsa").A;
>a : Symbol(a, Decl(index.d.ts, 0, 12))
>A : Symbol(A, Decl(impl.d.ts, 0, 26))

View File

@ -0,0 +1,29 @@
=== /cache/typescript-fsa/src/impl.d.ts ===
export function getA(): A;
>getA : () => A
export enum A {
>A : A
Val
>Val : A
}
=== /cache/typescript-fsa/index.d.ts ===
export * from "./src/impl";
No type information for this code.=== /p1/index.ts ===
import * as _whatever from "p2";
>_whatever : typeof _whatever
import { getA } from "typescript-fsa";
>getA : () => import("/cache/typescript-fsa/index").A
export const a = getA();
>a : import("/cache/typescript-fsa/index").A
>getA() : import("/cache/typescript-fsa/index").A
>getA : () => import("/cache/typescript-fsa/index").A
=== /p2/index.d.ts ===
export const a: import("typescript-fsa").A;
>a : import("/cache/typescript-fsa/index").A

View File

@ -0,0 +1,35 @@
// @useCaseSensitiveFilenames: true
// @declaration: true
// @filename: /p1/node_modules/typescript-fsa/src/impl.d.ts
export function getA(): A;
export enum A {
Val
}
// @filename: /p1/node_modules/typescript-fsa/index.d.ts
export * from "./src/impl";
// @filename: /p1/node_modules/typescript-fsa/package.json
{
"name": "typescript-fsa",
"version": "1.0.0"
}
// @filename: /p2/node_modules/typescript-fsa/src/impl.d.ts
export function getA(): A;
export enum A {
Val
}
// @filename: /p2/node_modules/typescript-fsa/index.d.ts
export * from "./src/impl";
// @filename: /p2/node_modules/typescript-fsa/package.json
{
"name": "typescript-fsa",
"version": "1.0.0"
}
// @filename: /p1/index.ts
import * as _whatever from "p2";
import { getA } from "typescript-fsa";
export const a = getA();
// @filename: /p2/index.d.ts
export const a: import("typescript-fsa").A;
// @link: /p2 -> /p1/node_modules/p2

View File

@ -0,0 +1,25 @@
// @useCaseSensitiveFilenames: true
// @declaration: true
// @filename: /cache/typescript-fsa/src/impl.d.ts
export function getA(): A;
export enum A {
Val
}
// @filename: /cache/typescript-fsa/index.d.ts
export * from "./src/impl";
// @filename: /cache/typescript-fsa/package.json
{
"name": "typescript-fsa",
"version": "1.0.0"
}
// @filename: /p1/index.ts
import * as _whatever from "p2";
import { getA } from "typescript-fsa";
export const a = getA();
// @filename: /p2/index.d.ts
export const a: import("typescript-fsa").A;
// @link: /p2 -> /p1/node_modules/p2
// @link: /cache/typescript-fsa -> /p1/node_modules/typescript-fsa
// @link: /cache/typescript-fsa -> /p2/node_modules/typescript-fsa