-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Fix the relative path reference resolution #1131
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8c2091b
Add tests to cover scenarios for relative path reference resolution
sheetalkamat 63a2086
Fix the relative path reference resolution
sheetalkamat 25abab8
Fixed the api for resolving script reference and getting source file …
sheetalkamat e5b0048
Renamed the tests files to more generic names
sheetalkamat 6d4e670
Enable baseline check and declaration emit for --noResolve case of files
sheetalkamat 264bd5d
Merge branch 'master' into relativePathReferenceResolution
sheetalkamat 7d103a1
Remove the --noResolve check when finding the file.
sheetalkamat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/project/referenceResolutionRelativePaths/amd/diskFile0.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/// <reference path="../src/ts/foo/foo.ts" /> | ||
// This is bar.ts | ||
var bar = (function () { | ||
function bar() { | ||
} | ||
return bar; | ||
})(); |
3 changes: 3 additions & 0 deletions
3
tests/baselines/reference/project/referenceResolutionRelativePaths/amd/diskFile1.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// <reference path="../src/ts/foo/foo.d.ts" /> | ||
declare class bar { | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/baselines/reference/project/referenceResolutionRelativePaths/amd/foo.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// <reference path="../../../bar/bar.d.ts" /> | ||
declare class foo { | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/baselines/reference/project/referenceResolutionRelativePaths/amd/foo.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/// <reference path="../../../bar/bar.ts" /> | ||
var foo = (function () { | ||
function foo() { | ||
} | ||
return foo; | ||
})(); |
20 changes: 20 additions & 0 deletions
20
...erence/project/referenceResolutionRelativePaths/amd/referenceResolutionRelativePaths.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"scenario": "referenceResolution1_FromFooFolder", | ||
"projectRoot": "tests/cases/projects/ReferenceResolution/src/ts/foo", | ||
"inputFiles": [ | ||
"foo.ts" | ||
], | ||
"declaration": true, | ||
"baselineCheck": true, | ||
"resolvedInputFiles": [ | ||
"lib.d.ts", | ||
"../../../bar/bar.ts", | ||
"foo.ts" | ||
], | ||
"emittedFiles": [ | ||
"../../../bar/bar.js", | ||
"../../../bar/bar.d.ts", | ||
"foo.js", | ||
"foo.d.ts" | ||
] | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/project/referenceResolutionRelativePaths/node/diskFile0.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/// <reference path="../src/ts/foo/foo.ts" /> | ||
// This is bar.ts | ||
var bar = (function () { | ||
function bar() { | ||
} | ||
return bar; | ||
})(); |
3 changes: 3 additions & 0 deletions
3
tests/baselines/reference/project/referenceResolutionRelativePaths/node/diskFile1.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// <reference path="../src/ts/foo/foo.d.ts" /> | ||
declare class bar { | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/baselines/reference/project/referenceResolutionRelativePaths/node/foo.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// <reference path="../../../bar/bar.d.ts" /> | ||
declare class foo { | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/baselines/reference/project/referenceResolutionRelativePaths/node/foo.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/// <reference path="../../../bar/bar.ts" /> | ||
var foo = (function () { | ||
function foo() { | ||
} | ||
return foo; | ||
})(); |
20 changes: 20 additions & 0 deletions
20
...rence/project/referenceResolutionRelativePaths/node/referenceResolutionRelativePaths.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"scenario": "referenceResolution1_FromFooFolder", | ||
"projectRoot": "tests/cases/projects/ReferenceResolution/src/ts/foo", | ||
"inputFiles": [ | ||
"foo.ts" | ||
], | ||
"declaration": true, | ||
"baselineCheck": true, | ||
"resolvedInputFiles": [ | ||
"lib.d.ts", | ||
"../../../bar/bar.ts", | ||
"foo.ts" | ||
], | ||
"emittedFiles": [ | ||
"../../../bar/bar.js", | ||
"../../../bar/bar.d.ts", | ||
"foo.js", | ||
"foo.d.ts" | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
...ines/reference/project/referenceResolutionRelativePathsFromRootDirectory/amd/bar/bar.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// <reference path="../src/ts/foo/foo.d.ts" /> | ||
declare class bar { | ||
} |
7 changes: 7 additions & 0 deletions
7
...elines/reference/project/referenceResolutionRelativePathsFromRootDirectory/amd/bar/bar.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/// <reference path="../src/ts/foo/foo.ts" /> | ||
// This is bar.ts | ||
var bar = (function () { | ||
function bar() { | ||
} | ||
return bar; | ||
})(); |
20 changes: 20 additions & 0 deletions
20
...RelativePathsFromRootDirectory/amd/referenceResolutionRelativePathsFromRootDirectory.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"scenario": "referenceResolution1_FromRootDirectory", | ||
"projectRoot": "tests/cases/projects/ReferenceResolution", | ||
"inputFiles": [ | ||
"src/ts/foo/foo.ts" | ||
], | ||
"declaration": true, | ||
"baselineCheck": true, | ||
"resolvedInputFiles": [ | ||
"lib.d.ts", | ||
"bar/bar.ts", | ||
"src/ts/foo/foo.ts" | ||
], | ||
"emittedFiles": [ | ||
"bar/bar.js", | ||
"bar/bar.d.ts", | ||
"src/ts/foo/foo.js", | ||
"src/ts/foo/foo.d.ts" | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
...ference/project/referenceResolutionRelativePathsFromRootDirectory/amd/src/ts/foo/foo.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// <reference path="../../../bar/bar.d.ts" /> | ||
declare class foo { | ||
} |
6 changes: 6 additions & 0 deletions
6
...reference/project/referenceResolutionRelativePathsFromRootDirectory/amd/src/ts/foo/foo.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/// <reference path="../../../bar/bar.ts" /> | ||
var foo = (function () { | ||
function foo() { | ||
} | ||
return foo; | ||
})(); |
3 changes: 3 additions & 0 deletions
3
...nes/reference/project/referenceResolutionRelativePathsFromRootDirectory/node/bar/bar.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// <reference path="../src/ts/foo/foo.d.ts" /> | ||
declare class bar { | ||
} |
7 changes: 7 additions & 0 deletions
7
...lines/reference/project/referenceResolutionRelativePathsFromRootDirectory/node/bar/bar.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/// <reference path="../src/ts/foo/foo.ts" /> | ||
// This is bar.ts | ||
var bar = (function () { | ||
function bar() { | ||
} | ||
return bar; | ||
})(); |
20 changes: 20 additions & 0 deletions
20
...elativePathsFromRootDirectory/node/referenceResolutionRelativePathsFromRootDirectory.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"scenario": "referenceResolution1_FromRootDirectory", | ||
"projectRoot": "tests/cases/projects/ReferenceResolution", | ||
"inputFiles": [ | ||
"src/ts/foo/foo.ts" | ||
], | ||
"declaration": true, | ||
"baselineCheck": true, | ||
"resolvedInputFiles": [ | ||
"lib.d.ts", | ||
"bar/bar.ts", | ||
"src/ts/foo/foo.ts" | ||
], | ||
"emittedFiles": [ | ||
"bar/bar.js", | ||
"bar/bar.d.ts", | ||
"src/ts/foo/foo.js", | ||
"src/ts/foo/foo.d.ts" | ||
] | ||
} |
3 changes: 3 additions & 0 deletions
3
...erence/project/referenceResolutionRelativePathsFromRootDirectory/node/src/ts/foo/foo.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/// <reference path="../../../bar/bar.d.ts" /> | ||
declare class foo { | ||
} |
6 changes: 6 additions & 0 deletions
6
...eference/project/referenceResolutionRelativePathsFromRootDirectory/node/src/ts/foo/foo.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/// <reference path="../../../bar/bar.ts" /> | ||
var foo = (function () { | ||
function foo() { | ||
} | ||
return foo; | ||
})(); |
7 changes: 7 additions & 0 deletions
7
tests/baselines/reference/project/referenceResolutionRelativePathsNoResolve/amd/diskFile0.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/// <reference path="../src/ts/foo/foo.ts" /> | ||
// This is bar.ts | ||
var bar = (function () { | ||
function bar() { | ||
} | ||
return bar; | ||
})(); |
2 changes: 2 additions & 0 deletions
2
.../baselines/reference/project/referenceResolutionRelativePathsNoResolve/amd/diskFile1.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare class bar { | ||
} |
2 changes: 2 additions & 0 deletions
2
tests/baselines/reference/project/referenceResolutionRelativePathsNoResolve/amd/foo.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare class foo { | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand why noResolve is of any consequence here. we will come here because we decided to resolve references, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we just need to compute an absolute path for every file for comparison purposes regardless of --noresolve, just do not make it the main name of the file so that error messages still use the name the user inputed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mhegazy don't we say if --noResolve is given do not resolve file names on the disk but use whatever is given in to the compiler, so why should we be resolving to full name in case of --noResolve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--noResolve=true means do not resolve /// references. the path resolution is more of a compiler implementation detail.