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.

Bug: tsr-declarations requires do not work with rootDir

See original GitHub issue

If I give a rootDir, and ask tsr to transpile a file that is not from the root directory, it assumes the tsr-declaration.js path incorrectly: e.g.

tsr --tsConfig tsconfig.json src/types/assert.ts

will give the error

$ node lib/types/assert.js
Error: Cannot find module './tsr-declarations'

I think the core of this error is ts-runtime assumes I will always be generating runtime check files at the root of my repo. However, I just want runtime checks on a few functions in my repo that deal with user input.

tsconfig.json:

{
  "compilerOptions": {
    "rootDir": "./src",
    "outDir": "./lib/"
  },
  "include": ["src/**/*.ts"]
}

let me know if you want a reproducible repo, I can push one!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
andykaiscommented, Feb 1, 2019

great! Here is a sample repo

0reactions
fabiandevcommented, Sep 6, 2019

Closing due to inactivity. Feel free to pick this up again if there are any more questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

tsc should not care and fail with ts files outside of rootDir #9858
I have a fixtures folder which contains .ts files. In my tsconfig.json I set rootDir to src which does contain all my source...
Read more >
File is not under 'rootDir' error in TypeScript | bobbyhadz
The "File is not under 'rootDir'" error occurs when we try to import something from a file that is not located under the...
Read more >
unreferenced .ts file in project's root "is not under root dir"
I invoke it with ts-node when needed. This script is not referenced anywhere in the actual source. The actual source of my program...
Read more >
TSConfig Option: rootDir - TypeScript
It would be an error to specify rootDir as core and include as * because it creates a file ( helpers.ts ) that...
Read more >
TypeScript errors and how to fix them
You need to assign your type declaration using the = character: ... If you don't want client to be a function, you have...
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