From d6a3a944d780a9d336a52e449a371268fc21ef59 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 12 Sep 2019 20:13:11 -0700 Subject: [PATCH 1/6] Add test that fails to emit declarations correctly --- src/testRunner/tsconfig.json | 1 + .../unittests/tsc/declarationEmit.ts | 73 +++++++++++++++++++ ...gh-source-and-another-symlinked-package.js | 24 ++++++ 3 files changed, 98 insertions(+) create mode 100644 src/testRunner/unittests/tsc/declarationEmit.ts create mode 100644 tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 5f8b3e87ec955..76bda69000929 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -109,6 +109,7 @@ "unittests/tsbuild/transitiveReferences.ts", "unittests/tsbuild/watchEnvironment.ts", "unittests/tsbuild/watchMode.ts", + "unittests/tsc/declarationEmit.ts", "unittests/tscWatch/consoleClearing.ts", "unittests/tscWatch/emit.ts", "unittests/tscWatch/emitAndErrorUpdates.ts", diff --git a/src/testRunner/unittests/tsc/declarationEmit.ts b/src/testRunner/unittests/tsc/declarationEmit.ts new file mode 100644 index 0000000000000..4ec2819a73491 --- /dev/null +++ b/src/testRunner/unittests/tsc/declarationEmit.ts @@ -0,0 +1,73 @@ +namespace ts { + describe("unittests:: tsc:: declarationEmit::", () => { + verifyTsc({ + scenario: "declarationEmit", + subScenario: "when same version is referenced through source and another symlinked package", + fs: () => { + const fsaPackageJson = utils.dedent` + { + "name": "typescript-fsa", + "version": "3.0.0-beta-2" + }`; + const fsaIndex = utils.dedent` + export interface Action { + type: string; + payload: Payload; + } + export declare type ActionCreator = { + type: string; + (payload: Payload): Action; + } + export interface ActionCreatorFactory { + (type: string): ActionCreator; + } + export declare function actionCreatorFactory(prefix?: string | null): ActionCreatorFactory; + export default actionCreatorFactory;`; + return loadProjectFromFiles({ + "/plugin-two/index.d.ts": utils.dedent` + declare const _default: { + features: { + featureOne: { + actions: { + featureOne: { + (payload: { + name: string; + order: number; + }, meta?: { + [key: string]: any; + }): import("typescript-fsa").Action<{ + name: string; + order: number; + }>; + }; + }; + path: string; + }; + }; + }; + export default _default;`, + "/plugin-two/node_modules/typescript-fsa/package.json": fsaPackageJson, + "/plugin-two/node_modules/typescript-fsa/index.d.ts": fsaIndex, + "/plugin-one/tsconfig.json": utils.dedent` + { + "compilerOptions": { + "target": "es5", + "declaration": true, + }, + }`, + "/plugin-one/index.ts": utils.dedent` + import pluginTwo from "plugin-two"; // include this to add reference to symlink`, + "/plugin-one/action.ts": utils.dedent` + import { actionCreatorFactory } from "typescript-fsa"; // Include version of shared lib + const action = actionCreatorFactory("somekey"); + const featureOne = action<{ route: string }>("feature-one"); + export const actions = { featureOne };`, + "/plugin-one/node_modules/typescript-fsa/package.json": fsaPackageJson, + "/plugin-one/node_modules/typescript-fsa/index.d.ts": fsaIndex, + "/plugin-one/node_modules/plugin-two": new vfs.Symlink("/plugin-two"), + }); + }, + commandLineArgs: ["-p", "plugin-one"] + }); + }); +} diff --git a/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js b/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js new file mode 100644 index 0000000000000..c7ccb8014c39f --- /dev/null +++ b/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js @@ -0,0 +1,24 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc -p plugin-one +plugin-one/action.ts(4,14): error TS2742: The inferred type of 'actions' cannot be named without a reference to 'plugin-two/node_modules/typescript-fsa'. This is likely not portable. A type annotation is necessary. +exitCode:: 1 + + +//// [/plugin-one/action.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var typescript_fsa_1 = require("typescript-fsa"); // Include version of shared lib +var action = typescript_fsa_1.actionCreatorFactory("somekey"); +var featureOne = action("feature-one"); +exports.actions = { featureOne: featureOne }; + + +//// [/plugin-one/index.d.ts] +export {}; + + +//// [/plugin-one/index.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + + From 2d62050b8f63162ac6050998253be61259c78d09 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 20 Sep 2019 14:23:04 -0700 Subject: [PATCH 2/6] Show redirected files in --listFiles --- src/compiler/watch.ts | 6 +++++- src/testRunner/unittests/tsc/declarationEmit.ts | 2 +- ...renced-through-source-and-another-symlinked-package.js | 8 +++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index 652b85d000d50..9634f5477f142 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -122,7 +122,11 @@ namespace ts { export function listFiles(program: ProgramToEmitFilesAndReportErrors, writeFileName: (s: string) => void) { if (program.getCompilerOptions().listFiles) { forEach(program.getSourceFiles(), file => { - writeFileName(file.fileName); + writeFileName( + !file.redirectInfo ? + file.fileName : + `${file.fileName} -> ${file.redirectInfo.redirectTarget.fileName}` + ); }); } } diff --git a/src/testRunner/unittests/tsc/declarationEmit.ts b/src/testRunner/unittests/tsc/declarationEmit.ts index 4ec2819a73491..75a40debb6782 100644 --- a/src/testRunner/unittests/tsc/declarationEmit.ts +++ b/src/testRunner/unittests/tsc/declarationEmit.ts @@ -67,7 +67,7 @@ namespace ts { "/plugin-one/node_modules/plugin-two": new vfs.Symlink("/plugin-two"), }); }, - commandLineArgs: ["-p", "plugin-one"] + commandLineArgs: ["-p", "plugin-one", "--listFiles"] }); }); } diff --git a/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js b/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js index c7ccb8014c39f..ec612b65f170d 100644 --- a/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js +++ b/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js @@ -1,6 +1,12 @@ //// [/lib/initial-buildOutput.txt] -/lib/tsc -p plugin-one +/lib/tsc -p plugin-one --listFiles plugin-one/action.ts(4,14): error TS2742: The inferred type of 'actions' cannot be named without a reference to 'plugin-two/node_modules/typescript-fsa'. This is likely not portable. A type annotation is necessary. +/lib/lib.d.ts +/plugin-one/node_modules/typescript-fsa/index.d.ts +/plugin-one/action.ts +/plugin-two/node_modules/typescript-fsa/index.d.ts -> /plugin-one/node_modules/typescript-fsa/index.d.ts +/plugin-two/index.d.ts +/plugin-one/index.ts exitCode:: 1 From c67c68e1490aa7248b44fea0aaa189ce13ca430b Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 23 Sep 2019 13:15:40 -0700 Subject: [PATCH 3/6] Sort the paths for module specifier by closeness to importing file path Fixes #32970 --- src/compiler/moduleSpecifiers.ts | 39 ++++++++++++++++++- ...gh-source-and-another-symlinked-package.js | 11 +++++- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/compiler/moduleSpecifiers.ts b/src/compiler/moduleSpecifiers.ts index cd566c0e6e840..fbb832400c24f 100644 --- a/src/compiler/moduleSpecifiers.ts +++ b/src/compiler/moduleSpecifiers.ts @@ -186,6 +186,18 @@ namespace ts.moduleSpecifiers { return result; } + function numberOfDirectorySeparators(str: string) { + const match = str.match(/\//g); + return match ? match.length : 0; + } + + function comparePathsByNumberOfDirectrorySeparators(a: string, b: string) { + return compareValues( + numberOfDirectorySeparators(a), + numberOfDirectorySeparators(b) + ); + } + /** * Looks for existing imports that use symlinks to this module. * Symlinks will be returned first so they are preferred over the real path. @@ -214,7 +226,32 @@ namespace ts.moduleSpecifiers { } }); result.push(...targets); - return result; + if (result.length < 2) return result; + + // Sort by paths closest to importing file Name directory + const allFileNames = arrayToMap(result, identity, getCanonicalFileName); + const sortedPaths: string[] = []; + for ( + let directory = getDirectoryPath(toPath(importingFileName, cwd, getCanonicalFileName)); + allFileNames.size !== 0; + directory = getDirectoryPath(directory) + ) { + const directoryStart = ensureTrailingDirectorySeparator(directory); + let pathsInDirectory: string[] | undefined; + allFileNames.forEach((canonicalFileName, fileName) => { + if (startsWith(canonicalFileName, directoryStart)) { + (pathsInDirectory || (pathsInDirectory = [])).push(fileName); + allFileNames.delete(fileName); + } + }); + if (pathsInDirectory) { + if (pathsInDirectory.length > 1) { + pathsInDirectory.sort(comparePathsByNumberOfDirectrorySeparators); + } + sortedPaths.push(...pathsInDirectory); + } + } + return sortedPaths; } function tryGetModuleNameFromAmbientModule(moduleSymbol: Symbol): string | undefined { diff --git a/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js b/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js index ec612b65f170d..5db17df5e9814 100644 --- a/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js +++ b/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js @@ -1,13 +1,20 @@ //// [/lib/initial-buildOutput.txt] /lib/tsc -p plugin-one --listFiles -plugin-one/action.ts(4,14): error TS2742: The inferred type of 'actions' cannot be named without a reference to 'plugin-two/node_modules/typescript-fsa'. This is likely not portable. A type annotation is necessary. /lib/lib.d.ts /plugin-one/node_modules/typescript-fsa/index.d.ts /plugin-one/action.ts /plugin-two/node_modules/typescript-fsa/index.d.ts -> /plugin-one/node_modules/typescript-fsa/index.d.ts /plugin-two/index.d.ts /plugin-one/index.ts -exitCode:: 1 +exitCode:: 0 + + +//// [/plugin-one/action.d.ts] +export declare const actions: { + featureOne: import("typescript-fsa").ActionCreator<{ + route: string; + }>; +}; //// [/plugin-one/action.js] From bf0fc858c184115f993f6d550a202fcda0f68410 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 24 Sep 2019 09:55:50 -0700 Subject: [PATCH 4/6] Fix after merging latest baselining branch --- .../unittests/tsc/declarationEmit.ts | 20 +++++++++---------- ...gh-source-and-another-symlinked-package.js | 20 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/testRunner/unittests/tsc/declarationEmit.ts b/src/testRunner/unittests/tsc/declarationEmit.ts index 75a40debb6782..5ff85a92f34fd 100644 --- a/src/testRunner/unittests/tsc/declarationEmit.ts +++ b/src/testRunner/unittests/tsc/declarationEmit.ts @@ -24,7 +24,7 @@ namespace ts { export declare function actionCreatorFactory(prefix?: string | null): ActionCreatorFactory; export default actionCreatorFactory;`; return loadProjectFromFiles({ - "/plugin-two/index.d.ts": utils.dedent` + "/src/plugin-two/index.d.ts": utils.dedent` declare const _default: { features: { featureOne: { @@ -46,28 +46,28 @@ namespace ts { }; }; export default _default;`, - "/plugin-two/node_modules/typescript-fsa/package.json": fsaPackageJson, - "/plugin-two/node_modules/typescript-fsa/index.d.ts": fsaIndex, - "/plugin-one/tsconfig.json": utils.dedent` + "/src/plugin-two/node_modules/typescript-fsa/package.json": fsaPackageJson, + "/src/plugin-two/node_modules/typescript-fsa/index.d.ts": fsaIndex, + "/src/plugin-one/tsconfig.json": utils.dedent` { "compilerOptions": { "target": "es5", "declaration": true, }, }`, - "/plugin-one/index.ts": utils.dedent` + "/src/plugin-one/index.ts": utils.dedent` import pluginTwo from "plugin-two"; // include this to add reference to symlink`, - "/plugin-one/action.ts": utils.dedent` + "/src/plugin-one/action.ts": utils.dedent` import { actionCreatorFactory } from "typescript-fsa"; // Include version of shared lib const action = actionCreatorFactory("somekey"); const featureOne = action<{ route: string }>("feature-one"); export const actions = { featureOne };`, - "/plugin-one/node_modules/typescript-fsa/package.json": fsaPackageJson, - "/plugin-one/node_modules/typescript-fsa/index.d.ts": fsaIndex, - "/plugin-one/node_modules/plugin-two": new vfs.Symlink("/plugin-two"), + "/src/plugin-one/node_modules/typescript-fsa/package.json": fsaPackageJson, + "/src/plugin-one/node_modules/typescript-fsa/index.d.ts": fsaIndex, + "/src/plugin-one/node_modules/plugin-two": new vfs.Symlink("/src/plugin-two"), }); }, - commandLineArgs: ["-p", "plugin-one", "--listFiles"] + commandLineArgs: ["-p", "src/plugin-one", "--listFiles"] }); }); } diff --git a/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js b/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js index 5db17df5e9814..910b9d1db3aaf 100644 --- a/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js +++ b/tests/baselines/reference/tsc/declarationEmit/initial-build/when-same-version-is-referenced-through-source-and-another-symlinked-package.js @@ -1,15 +1,15 @@ //// [/lib/initial-buildOutput.txt] -/lib/tsc -p plugin-one --listFiles +/lib/tsc -p src/plugin-one --listFiles /lib/lib.d.ts -/plugin-one/node_modules/typescript-fsa/index.d.ts -/plugin-one/action.ts -/plugin-two/node_modules/typescript-fsa/index.d.ts -> /plugin-one/node_modules/typescript-fsa/index.d.ts -/plugin-two/index.d.ts -/plugin-one/index.ts +/src/plugin-one/node_modules/typescript-fsa/index.d.ts +/src/plugin-one/action.ts +/src/plugin-one/node_modules/plugin-two/node_modules/typescript-fsa/index.d.ts -> /src/plugin-one/node_modules/typescript-fsa/index.d.ts +/src/plugin-one/node_modules/plugin-two/index.d.ts +/src/plugin-one/index.ts exitCode:: 0 -//// [/plugin-one/action.d.ts] +//// [/src/plugin-one/action.d.ts] export declare const actions: { featureOne: import("typescript-fsa").ActionCreator<{ route: string; @@ -17,7 +17,7 @@ export declare const actions: { }; -//// [/plugin-one/action.js] +//// [/src/plugin-one/action.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var typescript_fsa_1 = require("typescript-fsa"); // Include version of shared lib @@ -26,11 +26,11 @@ var featureOne = action("feature-one"); exports.actions = { featureOne: featureOne }; -//// [/plugin-one/index.d.ts] +//// [/src/plugin-one/index.d.ts] export {}; -//// [/plugin-one/index.js] +//// [/src/plugin-one/index.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); From 3d6a1828573a68dbfc5100a697ddde45ae766e27 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 25 Sep 2019 09:07:51 -0700 Subject: [PATCH 5/6] Accept change in existing baseline --- ...EmitReexportedSymlinkReference3.errors.txt | 60 ------------------- ...larationEmitReexportedSymlinkReference3.js | 3 + 2 files changed, 3 insertions(+), 60 deletions(-) delete mode 100644 tests/baselines/reference/declarationEmitReexportedSymlinkReference3.errors.txt diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.errors.txt b/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.errors.txt deleted file mode 100644 index 1981ce63c9282..0000000000000 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.errors.txt +++ /dev/null @@ -1,60 +0,0 @@ -tests/cases/compiler/monorepo/pkg3/src/keys.ts(3,14): error TS2742: The inferred type of 'ADMIN' cannot be named without a reference to '../../pkg2/node_modules/@raymondfeng/pkg1/dist'. This is likely not portable. A type annotation is necessary. - - -==== tests/cases/compiler/monorepo/pkg3/tsconfig.json (0 errors) ==== - { - "compilerOptions": { - "outDir": "dist", - "rootDir": "src", - "target": "es5", - "module": "commonjs", - "strict": true, - "esModuleInterop": true, - "declaration": true - } - } - -==== tests/cases/compiler/monorepo/pkg1/dist/index.d.ts (0 errors) ==== - export * from './types'; -==== tests/cases/compiler/monorepo/pkg1/dist/types.d.ts (0 errors) ==== - export declare type A = { - id: string; - }; - export declare type B = { - id: number; - }; - export declare type IdType = A | B; - export declare class MetadataAccessor { - readonly key: string; - private constructor(); - toString(): string; - static create(key: string): MetadataAccessor; - } -==== tests/cases/compiler/monorepo/pkg1/package.json (0 errors) ==== - { - "name": "@raymondfeng/pkg1", - "version": "1.0.0", - "description": "", - "main": "dist/index.js", - "typings": "dist/index.d.ts" - } -==== tests/cases/compiler/monorepo/pkg2/dist/index.d.ts (0 errors) ==== - export * from './types'; -==== tests/cases/compiler/monorepo/pkg2/dist/types.d.ts (0 errors) ==== - export {MetadataAccessor} from '@raymondfeng/pkg1'; -==== tests/cases/compiler/monorepo/pkg2/package.json (0 errors) ==== - { - "name": "@raymondfeng/pkg2", - "version": "1.0.0", - "description": "", - "main": "dist/index.js", - "typings": "dist/index.d.ts" - } -==== tests/cases/compiler/monorepo/pkg3/src/index.ts (0 errors) ==== - export * from './keys'; -==== tests/cases/compiler/monorepo/pkg3/src/keys.ts (1 errors) ==== - import {MetadataAccessor} from "@raymondfeng/pkg2"; - - export const ADMIN = MetadataAccessor.create('1'); - ~~~~~ -!!! error TS2742: The inferred type of 'ADMIN' cannot be named without a reference to '../../pkg2/node_modules/@raymondfeng/pkg1/dist'. This is likely not portable. A type annotation is necessary. \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js b/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js index 2ac5a9fffbd0c..46b3eded6341d 100644 --- a/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js +++ b/tests/baselines/reference/declarationEmitReexportedSymlinkReference3.js @@ -57,5 +57,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); __export(require("./keys")); +//// [keys.d.ts] +import { MetadataAccessor } from "@raymondfeng/pkg2"; +export declare const ADMIN: MetadataAccessor; //// [index.d.ts] export * from './keys'; From 91c66a09635dabb3b20a5c2b50332d8803fef02d Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 25 Sep 2019 10:05:10 -0700 Subject: [PATCH 6/6] Add tsc baselining test for scenario that changed. --- .../unittests/tsc/declarationEmit.ts | 63 +++++++++++++++++++ ...ibling-package-through-indirect-symlink.js | 33 ++++++++++ 2 files changed, 96 insertions(+) create mode 100644 tests/baselines/reference/tsc/declarationEmit/initial-build/when-pkg-references-sibling-package-through-indirect-symlink.js diff --git a/src/testRunner/unittests/tsc/declarationEmit.ts b/src/testRunner/unittests/tsc/declarationEmit.ts index 5ff85a92f34fd..5577ad2202314 100644 --- a/src/testRunner/unittests/tsc/declarationEmit.ts +++ b/src/testRunner/unittests/tsc/declarationEmit.ts @@ -69,5 +69,68 @@ namespace ts { }, commandLineArgs: ["-p", "src/plugin-one", "--listFiles"] }); + + verifyTsc({ + scenario: "declarationEmit", + subScenario: "when pkg references sibling package through indirect symlink", + fs: () => loadProjectFromFiles({ + "/src/pkg1/dist/index.d.ts": utils.dedent` + export * from './types';`, + "/src/pkg1/dist/types.d.ts": utils.dedent` + export declare type A = { + id: string; + }; + export declare type B = { + id: number; + }; + export declare type IdType = A | B; + export declare class MetadataAccessor { + readonly key: string; + private constructor(); + toString(): string; + static create(key: string): MetadataAccessor; + }`, + "/src/pkg1/package.json": utils.dedent` + { + "name": "@raymondfeng/pkg1", + "version": "1.0.0", + "description": "", + "main": "dist/index.js", + "typings": "dist/index.d.ts" + }`, + "/src/pkg2/dist/index.d.ts": utils.dedent` + export * from './types';`, + "/src/pkg2/dist/types.d.ts": utils.dedent` + export {MetadataAccessor} from '@raymondfeng/pkg1';`, + "/src/pkg2/package.json": utils.dedent` + { + "name": "@raymondfeng/pkg2", + "version": "1.0.0", + "description": "", + "main": "dist/index.js", + "typings": "dist/index.d.ts" + }`, + "/src/pkg3/src/index.ts": utils.dedent` + export * from './keys';`, + "/src/pkg3/src/keys.ts": utils.dedent` + import {MetadataAccessor} from "@raymondfeng/pkg2"; + export const ADMIN = MetadataAccessor.create('1');`, + "/src/pkg3/tsconfig.json": utils.dedent` + { + "compilerOptions": { + "outDir": "dist", + "rootDir": "src", + "target": "es5", + "module": "commonjs", + "strict": true, + "esModuleInterop": true, + "declaration": true + } + }`, + "/src/pkg2/node_modules/@raymondfeng/pkg1": new vfs.Symlink("/src/pkg1"), + "/src/pkg3/node_modules/@raymondfeng/pkg2": new vfs.Symlink("/src/pkg2"), + }), + commandLineArgs: ["-p", "src/pkg3", "--listFiles"] + }); }); } diff --git a/tests/baselines/reference/tsc/declarationEmit/initial-build/when-pkg-references-sibling-package-through-indirect-symlink.js b/tests/baselines/reference/tsc/declarationEmit/initial-build/when-pkg-references-sibling-package-through-indirect-symlink.js new file mode 100644 index 0000000000000..42cb6cf78c8ad --- /dev/null +++ b/tests/baselines/reference/tsc/declarationEmit/initial-build/when-pkg-references-sibling-package-through-indirect-symlink.js @@ -0,0 +1,33 @@ +//// [/lib/initial-buildOutput.txt] +/lib/tsc -p src/pkg3 --listFiles +src/pkg3/src/keys.ts(2,14): error TS2742: The inferred type of 'ADMIN' cannot be named without a reference to '@raymondfeng/pkg2/node_modules/@raymondfeng/pkg1'. This is likely not portable. A type annotation is necessary. +/lib/lib.d.ts +/src/pkg3/node_modules/@raymondfeng/pkg2/node_modules/@raymondfeng/pkg1/dist/types.d.ts +/src/pkg3/node_modules/@raymondfeng/pkg2/node_modules/@raymondfeng/pkg1/dist/index.d.ts +/src/pkg3/node_modules/@raymondfeng/pkg2/dist/types.d.ts +/src/pkg3/node_modules/@raymondfeng/pkg2/dist/index.d.ts +/src/pkg3/src/keys.ts +/src/pkg3/src/index.ts +exitCode:: 1 + + +//// [/src/pkg3/dist/index.d.ts] +export * from './keys'; + + +//// [/src/pkg3/dist/index.js] +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("./keys")); + + +//// [/src/pkg3/dist/keys.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var pkg2_1 = require("@raymondfeng/pkg2"); +exports.ADMIN = pkg2_1.MetadataAccessor.create('1'); + +