镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

getSourceFilePathInNewDir broken by recent commits #9768

Description

TypeScript Version: 2.0.0-beta

Zhengbo Li (@zhengbli) The following commit appears to have broken the getSourceFilePathInNewDir implementation in certain circumstances:

Use getCanonicalFileName

The use of getCanonicalFileName breaks the implementation if the common directory is a parent of the current directory.

For example, with these files:

C:/Users/Nicholas/example/a/a.ts
C:/Users/Nicholas/example/b/b.ts

The common directory is C:/Users/Nicholas/example.

If the current directory is C:/Users/Nicholas/example/b, for the a.ts source file:

cannonical source = ../a/a.ts
cannonical common = ..

So isSourceFileInCommonSourceDirectory will be true.

However, for the b.ts source file:

cannonical source = b.ts
cannonical common = ..

So isSourceFileInCommonSourceDirectory will be false - which will result in the absolute path to the source file - C:/Users/Nicholas/example/b/b.ts - being returned.

Specifically, this change to the implementation breaks my tsify-based builds.

Activity

  1. added this to the milestone on Jul 17, 2016
  2. zhengbli commented on Aug 3, 2016

    @zhengbli

    I don't quite understand. The sourceFilePath is always an absolute path returned by getNormalizedAbsolutePath, and getCanonicalFileName only changes casing, so why does the cannonical source file path of C:/Users/Nicholas/example/b/b.ts become b.ts?

  3. cartant commented on Aug 3, 2016

    @cartant
    Author

    getCanonicalFileName does more than change the case; it returns a relative path. And if C:/Users/Nicholas/example/b is the current directory, b.ts is the cannonical path. The examples I gave were from console outputs I placed in the source - with some upper directory levels removed.

  4. cartant commented on Aug 3, 2016

    @cartant
    Author

    I think I see the problem.

    getCanonicalFileName is implemented in the host, so it's tsify's implementation that's being called. It's not calling the TypeScript implementation of getCanonicalFileName - which, as you've said, just changes the case.

    Thanks. I guess I have something to fix in tsify.

  5. added
    ExternalRelates to another program, environment, or user action which we cannot control.
    and removed
    BugA bug in TypeScript
    FixedA PR has been merged for this issue
    on Aug 3, 2016
  6. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions