Skip to content

When resolving type reference directive use baseUrl and other resolution settings #39646

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
wants to merge 5 commits into from

Conversation

sheetalkamat
Copy link
Member

This one ensures that we resolve type reference directive with baseUrl since #32878 started using baseUrl considerations to generate ///<reference types instead of ```///<reference path` and accounting for baseUrl

This is one possible fix for the issue wherein we use baseUrl when resolving type reference name.
Other could be to generate ///<reference path when file is referenced only throught ```//reference path` and relative import path tree from root file.
Possibly Fixes #37928

@sheetalkamat
Copy link
Member Author

@RyanCavanaugh @weswigham @DanielRosenwasser can you please comment on what you think is better approach.
As mentioned in the description the declaration emit prefers type reference directive over reference path and uses baseUrl to determine that portion. But our type reference directive resolution doesnt use baseUrl.

Does declaration emit need to be better (use relative paths when file is referenced through tree of relative paths.. Old branhc for this which doesnt handle tree case https://github.com/microsoft/TypeScript/compare/experimentRelativePaths ) or resolution which this PR tries to fix?

@weswigham
Copy link
Member

I think we should, generally speaking, strive to make declaration emit use "the most portable" paths for things (certainly, emitting things which only work with a specific compiler option configuration isn't very portable).

Base automatically changed from declarationInComposite to master July 17, 2020 23:25


//// [/src/solution/lib/src/common/nominal.d.ts]
/// <reference types="types" />
Copy link
Contributor

@timocov timocov Jul 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be reference path instead? How <reference types="types" /> will be resolved by another project referencing to this one? I mean, afaik reference types means "load types from types-like package (from both typesRoot or node_modules/@types) with specific name", but this is the local file, why we should refer to it with types instead of path?

@sheetalkamat sheetalkamat deleted the typeReferenceUsingBaseUrl branch July 21, 2020 21:34
@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Declaration file has wrong reference path for composite projects
4 participants