Skip to content

Fix incorrect relative module name detection#18576

Closed
sameoldmadness wants to merge 1 commit into
microsoft:masterfrom
sameoldmadness:fix-incorrect-relative-module-name-detection
Closed

Fix incorrect relative module name detection#18576
sameoldmadness wants to merge 1 commit into
microsoft:masterfrom
sameoldmadness:fix-incorrect-relative-module-name-detection

Conversation

@sameoldmadness
Copy link
Copy Markdown

Fixes #18536

Comment thread lib/tsc.js
if (path.charCodeAt(1) === 58) {
if (path.charCodeAt(2) === 47)
return 3;
return 2;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please undo changes to files under lib

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

"compilerOptions": {
/* Basic Options */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not sure why yo had to change these.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

These fixes are made by gulp baseline-accept.

Completely unrelated to the issue, but I suppose it would not hurt to fix a typo in the comments.

Should I revert it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks like we did not catch these failures. that should be fixed by #18583

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Great! I've removed these changes from the PR.

Comment thread src/compiler/core.ts
}
if (path.charCodeAt(1) === CharacterCodes.colon) {
if (path.charCodeAt(2) === CharacterCodes.slash) return 3;
return 2;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should it still return 2 if path.length === 2 to handle input like C:?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems like a good suggestion.
we should add some unit tests for this function, but that can be a different change.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

C: does not look like a valid path to me, so I'd rather say no.

Maybe I'm just missing some use cases.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

c: is a valid folder name on windows. so we should allow it.

Copy link
Copy Markdown
Author

@sameoldmadness sameoldmadness Sep 23, 2017

Choose a reason for hiding this comment

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

Well, I've made a bit of a research.

  1. c: is NOT a valid folder name on Windows. : is not a valid character for a folder name.
  2. In command line cd c: does nothing, dir c: displays the content of a current directory. So it seems like c: is not a path, but rather a volume label, which is not handled by Windows the same way as a regular path.
  3. Node's path.isAbsolutePath returns true for both c:/ and c:\\, but false for c:.
  4. Node's path.resolve returns current directory for c:.

Based on this behaviour a cannot see how c: is a valid path.

Can you provide some code to illustrate your point?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@mhegazy Take a look, please. ☝️

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fair enough. can you update the test baselines

Copy link
Copy Markdown
Author

@sameoldmadness sameoldmadness Oct 17, 2017

Choose a reason for hiding this comment

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

I did, and something went wrong : [

I've run exactly

jake
jake runtests-parallel
jake baseline-accept

Now there are tons of changed and new files in the PR.

What should I've done differently?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@mhegazy Can you take a look please?

@sameoldmadness sameoldmadness force-pushed the fix-incorrect-relative-module-name-detection branch 2 times, most recently from 1036ec8 to 9b188bd Compare September 23, 2017 13:02
@microsoft microsoft deleted a comment from msftclas Sep 26, 2017
@microsoft microsoft deleted a comment from msftclas Sep 26, 2017
@sameoldmadness sameoldmadness force-pushed the fix-incorrect-relative-module-name-detection branch from 9b188bd to 924945f Compare October 17, 2017 08:36
@orloffv
Copy link
Copy Markdown

orloffv commented Oct 20, 2017

Any news on this PR?

@mhegazy mhegazy mentioned this pull request Nov 3, 2017
@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Nov 3, 2017

Superseded by #19702

@mhegazy mhegazy closed this Nov 3, 2017
@sameoldmadness sameoldmadness deleted the fix-incorrect-relative-module-name-detection branch November 3, 2017 19:32
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants