Skip to content

TypeScript types from internal packages are being imported from dist #10765

@jasongerbes

Description

@jasongerbes

Current Behavior

An Nx workspace with multiple TypeScript libraries can resolve implicit types to imports from dist, for example:

// libs/lib-2/src/lib/lib-2.ts
import { TestFunction } from '@nx-example/lib-1';

export const testFunction: TestFunction = (arg: string) => arg;
// libs/lib-2/src/lib/test.ts
import { testFunction } from './lib-2';

export const test = testFunction;
// dist/libs/lib-2/src/lib/test.d.ts
export declare const test: import("../../../../dist/libs/lib-1/src").TestFunction;

Expected Behavior

All types from internal libraries should be resolved to the relevant node module, for example:

// dist/libs/lib-2/src/lib/test.d.ts
import { TestFunction } from '@nx-example/lib-1';
export declare const test: TestFunction;

Steps to Reproduce

See the related nx-examples PR: nrwl/nx-examples#205

Environment

Node : 16.14.2
OS   : darwin x64
yarn : 1.22.18

nx : 14.2.0-rc.1
@nrwl/angular : 14.2.0-rc.1
@nrwl/cypress : 14.2.0-rc.1
@nrwl/detox : Not Found
@nrwl/devkit : 14.2.0-rc.1
@nrwl/eslint-plugin-nx : 14.2.0-rc.1
@nrwl/express : Not Found
@nrwl/jest : 14.2.0-rc.1
@nrwl/js : 14.2.0-rc.1
@nrwl/linter : 14.2.0-rc.1
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/nx-cloud : 14.0.5
@nrwl/nx-plugin : Not Found
@nrwl/react : 14.2.0-rc.1
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : 14.2.0-rc.1
@nrwl/web : 14.2.0-rc.1
@nrwl/workspace : 14.2.0-rc.1
typescript : 4.7.2
---------------------------------------
Community plugins:
    @ngrx/component-store: 13.2.0
    @ngrx/effects: 13.2.0
    @ngrx/entity: 13.2.0
    @ngrx/router-store: 13.2.0
    @ngrx/store: 13.2.0
    rxjs: 6.5.5
    @ngrx/store-devtools: 13.2.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions