Skip to content
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

[Feature] "reverseResolve", for TypeScript support #548

Closed
2 tasks
pauldraper opened this issue Oct 24, 2019 · 3 comments
Closed
2 tasks

[Feature] "reverseResolve", for TypeScript support #548

pauldraper opened this issue Oct 24, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@pauldraper
Copy link

pauldraper commented Oct 24, 2019

  • I'd be willing to implement this feature
  • This feature can already be implemented through a plugin

I'm not 100% sure what the right answer is, but there is a strong intersection here of pnp and TS expertise that should be able to arrive at it.

Describe the user story

AFAIK, pnp cannot (fully) support the TypeScript compiler needs in creating declaration files.

a/thing module

import { SomeType } from './some';

export const a = new SomeType();

b module

import { a } from 'a/thing';
export const b = a;

The TypeScript compiler produce the following typed declaration file for the b module:

declare export const b: import('a/some').SomeType;

The TypeScript compiler applies some heuristics to obtain this; sometimes a portable path is not possible and it produces an error.

Describe the solution you'd like

I think this requires a reverseResolve function or something similar.

Describe the drawbacks of your solution

Describe alternatives you've considered

Don't support inferred imports for TypeScript declaration files.

Additional context

Also my remarks in the TypeScript project: microsoft/TypeScript#28289 (comment)

@pauldraper pauldraper added the enhancement New feature or request label Oct 24, 2019
@arcanis
Copy link
Member

arcanis commented Oct 25, 2019

I'm not sure I fully understand the problem that happens (we publish TS type declarations and they seem to work fine) - do you have a reproduction repo to highlight the behavior that regressed?

@pauldraper
Copy link
Author

we publish TS type declarations and they seem to work fine

Yes it works with pnpify.

With pnpify, tsc still performs the same resolution and reverse resolution logic, so the output is of course the same.

If you wanted tsc to support PnP using pnpapi, you would soon find that it requires "reverse resolution" to synthesize type import() statements in declaration files.

@arcanis
Copy link
Member

arcanis commented Nov 28, 2019

I'm going to close this issue since I don't understand how to reproduce the problem (microsoft/TypeScript#28289 seemed to work just fine and was using the API directly).

If you get the chance to make a standalone repo I can clone and run a command in to see what should work and what doesn't, feel free to reopen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants