Skip to content

[project-references] TS2307 with direct file imports (imports that bypass an index) #26823

@rosskevin

Description

@rosskevin

TypeScript Version: 3.1.0-dev.20180831

Search Terms:
TS2307 with direct file imports (imports that bypass an index)

Code
Starting from the yarn workspaces learn-a example, change pkg2/index.ts to import the pkg1/foo class directly.

Reproduction: https://github.com/rosskevin/learn-a/tree/yarn-workspaces-TS2307-direct-file-import

// import * as p1 from '@ryancavanaugh/pkg1'; // works
import { fn } from '@ryancavanaugh/pkg1/foo'; // does not work

export function fn4() {
  // p1.fn();
  fn();
}

yields:

packages/pkg2/src/index.ts:2:20 - error TS2307: Cannot find module '@ryancavanaugh/pkg1/foo'.

2 import { fn } from '@ryancavanaugh/pkg1/foo';

Expected behavior:
All direct paths are accessible, just like any standard file resolution.

Actual behavior:
error TS2307: Cannot find module '@ryancavanaugh/pkg1/foo'.

Related Issues:
#26819 is similar (may be the same) but it is focused on esnext usage
#25600

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions