Skip to content

TypeScript 2.9.x incorrectly emits relative imports for symbolically linked dependencies (lerna) #24829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
raymondfeng opened this issue Jun 9, 2018 · 6 comments
Assignees
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files

Comments

@raymondfeng
Copy link

raymondfeng commented Jun 9, 2018

TypeScript Version: 2.9.x

2.8.x works fine. It starts to break with TypeScript 2.9.x. It's not fixed by the latest build (typescript@next).

Search Terms:

import symbolic link lerna

Code

https://github.com/strongloop/loopback-next/blob/master/packages/core/src/keys.ts

keys.ts

import {Application, ControllerClass} from './application';

export const CONTROLLER_CLASS = BindingKey.create<ControllerClass>(
    'controller.current.ctor',
  );

Please note the ControllerClass is a type alias re-exported from another module @loopback/next which is symbolically linked to @loopback/core by lerna.

application.ts

import {Context, Binding, BindingScope, Constructor} from '@loopback/context';
export type ControllerClass = Constructor<any>;

Expected behavior:

TypeScript 2.8.x style:
keys.d.ts (emitted by tsc)

const CONTROLLER_CLASS: BindingKey<new (...args: any[]) => any>;

Or

import {Constructor} from '@loopback/context';

const CONTROLLER_CLASS: BindingKey<Constructor<any>>;

Actual behavior:

const CONTROLLER_CLASS: BindingKey<import("../../context/src/value-promise").Constructor<any>>;

Please note the relative link is only valid at development time. Once it's published as a npm module, the import cannot be resolved.

Playground Link:

Related Issues:

loopbackio/loopback-next#1405

@ajafff
Copy link
Contributor

ajafff commented Jun 10, 2018

This is also a problem for me when using the new feature to adjust imports after renaming a file.

@mhegazy mhegazy added the Bug A bug in TypeScript label Jun 11, 2018
@mhegazy mhegazy added this to the TypeScript 2.9.2 milestone Jun 11, 2018
@mhegazy mhegazy added the Domain: Declaration Emit The issue relates to the emission of d.ts files label Jun 11, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Jun 11, 2018

@weswigham can you take a look

@raymondfeng
Copy link
Author

I just tried 2.9.2 release and the issue is NOT fixed but getting worse:

See #24874 (comment)

@alan-agius4
Copy link
Contributor

alan-agius4 commented Jul 30, 2018

Is there update on this? I see that it has been merged but with TS 2.9.2 I still have the same issue.

@lukaszczernal
Copy link

I understand that Typescript 2 will not be fixed. We should all update to third version. Right?

@weswigham
Copy link
Member

weswigham commented Dec 21, 2018

Our team only maintains one version of the compiler actively, so yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files
Projects
None yet
Development

No branches or pull requests

6 participants