|
| 1 | +namespace ts { |
| 2 | + describe("unittests:: tsc:: declarationEmit::", () => { |
| 3 | + verifyTsc({ |
| 4 | + scenario: "declarationEmit", |
| 5 | + subScenario: "when same version is referenced through source and another symlinked package", |
| 6 | + fs: () => { |
| 7 | + const fsaPackageJson = utils.dedent` |
| 8 | + { |
| 9 | + "name": "typescript-fsa", |
| 10 | + "version": "3.0.0-beta-2" |
| 11 | + }`; |
| 12 | + const fsaIndex = utils.dedent` |
| 13 | + export interface Action<Payload> { |
| 14 | + type: string; |
| 15 | + payload: Payload; |
| 16 | + } |
| 17 | + export declare type ActionCreator<Payload> = { |
| 18 | + type: string; |
| 19 | + (payload: Payload): Action<Payload>; |
| 20 | + } |
| 21 | + export interface ActionCreatorFactory { |
| 22 | + <Payload = void>(type: string): ActionCreator<Payload>; |
| 23 | + } |
| 24 | + export declare function actionCreatorFactory(prefix?: string | null): ActionCreatorFactory; |
| 25 | + export default actionCreatorFactory;`; |
| 26 | + return loadProjectFromFiles({ |
| 27 | + "/plugin-two/index.d.ts": utils.dedent` |
| 28 | + declare const _default: { |
| 29 | + features: { |
| 30 | + featureOne: { |
| 31 | + actions: { |
| 32 | + featureOne: { |
| 33 | + (payload: { |
| 34 | + name: string; |
| 35 | + order: number; |
| 36 | + }, meta?: { |
| 37 | + [key: string]: any; |
| 38 | + }): import("typescript-fsa").Action<{ |
| 39 | + name: string; |
| 40 | + order: number; |
| 41 | + }>; |
| 42 | + }; |
| 43 | + }; |
| 44 | + path: string; |
| 45 | + }; |
| 46 | + }; |
| 47 | + }; |
| 48 | + export default _default;`, |
| 49 | + "/plugin-two/node_modules/typescript-fsa/package.json": fsaPackageJson, |
| 50 | + "/plugin-two/node_modules/typescript-fsa/index.d.ts": fsaIndex, |
| 51 | + "/plugin-one/tsconfig.json": utils.dedent` |
| 52 | + { |
| 53 | + "compilerOptions": { |
| 54 | + "target": "es5", |
| 55 | + "declaration": true, |
| 56 | + }, |
| 57 | + }`, |
| 58 | + "/plugin-one/index.ts": utils.dedent` |
| 59 | + import pluginTwo from "plugin-two"; // include this to add reference to symlink`, |
| 60 | + "/plugin-one/action.ts": utils.dedent` |
| 61 | + import { actionCreatorFactory } from "typescript-fsa"; // Include version of shared lib |
| 62 | + const action = actionCreatorFactory("somekey"); |
| 63 | + const featureOne = action<{ route: string }>("feature-one"); |
| 64 | + export const actions = { featureOne };`, |
| 65 | + "/plugin-one/node_modules/typescript-fsa/package.json": fsaPackageJson, |
| 66 | + "/plugin-one/node_modules/typescript-fsa/index.d.ts": fsaIndex, |
| 67 | + "/plugin-one/node_modules/plugin-two": new vfs.Symlink("/plugin-two"), |
| 68 | + }); |
| 69 | + }, |
| 70 | + commandLineArgs: ["-p", "plugin-one"] |
| 71 | + }); |
| 72 | + }); |
| 73 | +} |
0 commit comments