question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Breaking Change] Typescript 3.7 converts reference paths to tsconfig specified paths breaking multi-project compiles.

See original GitHub issue

Typescript is replacing part of a relative path with one of the paths specified in tsconfig’s path section. This is breaking the projects that rely on this file as they cannot resolve the path.

TypeScript Version: 3.7 Visual Studio Version: Community 2017

Search Terms: Typescirpt paths tsconfig reference paths alias.

Code

In the client project at folder\folder\file.ts

/// <reference path="../../External/Knockout/index.d.ts" />

Becomes (in ClientDeclarations) folder\folder\file.d.ts:

/// <reference types="@Client/external/knockout/index" />

My tsconfig file (folder names with sensitive information are replaced with ***)

{
  "compileOnSave": true,
  "compilerOptions": {
    "module": "amd",
    "target": "es6",
    "lib": [ "es6", "dom" ],
    "sourceMap": true,
    "strict": true,
    "build": true,
    "declaration": true,
    "declarationDir": "../ClientDeclarations",
    "baseUrl": "./",
    "paths": {
      "@Common/*": [ "../Common/*" ],
      "@Server/*": [ "../ServerDeclarations/*" ],
      "@Client/*": [ "./*"]
    }
  },
  "include": [
    "./*",
    "./External/***/koco.ts",
    "./External/***/kocss.ts",
    "./External/***/kopath.ts"
  ],
  "exclude": [
    "node_modules"
  ],
  "references": [
    { "path": "../Common" }
  ]
}

Expected behavior: The path should not be transformed during output.

Actual behavior: The path is transformed to include an @Client reference, which my dependant projects can’t resolve. This did not happen in tsc 3.4.

Additionally all of the casing is altered - meaning that this path would not resolve on linux machines.

Related Issues: I haven’t been able to find any - probably because what I’m trying to look for is called a “path” (in tsconfig) which is a highly overloaded term, making searching for anything related to it almost impossible. It would be nice to call it something like a “path alias” so that searching for related issues was easier.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
huntjoshcommented, Apr 5, 2020

Running into the same issue on another multi-project, only occurs when adding the baseUrl property. Will try the custom branch.

0reactions
Grifforkcommented, Oct 28, 2020

@sheetalkamat Was that branch included in 4.0?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TSConfig Reference - Docs on every TSConfig option
From allowJs to useDefineForClassFields the TSConfig reference includes information about all of the active compiler flags setting up a TypeScript project.
Read more >
Typescript doesn't compiles paths in tsconfig - Stack Overflow
I want to reference my modules in my TS project without using '../../../etc' import syntax. I made the following changes: ... baseUrl ...
Read more >
10 Insights from Adopting TypeScript at Scale | Bloomberg LP
Mandated baseUrl in tsconfig. In TypeScript 4.0. if you want to use Project References or "paths" , you are required to also specify...
Read more >
tsconfig-paths | Yarn - Package Manager
json or jsconfig.json . Both loading at run-time and via API are supported. Typescript by default mimics the Node.js runtime resolution strategy of...
Read more >
Changelog | TypeDoc
Added support for specifying the tsconfig.json file in packages mode with ... option which instructs TypeDoc to not ask TypeScript for compiler errors ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found