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.

Question: Setting up a project with in-memory FS + typeRoots from disk?

See original GitHub issue

I’m trying to setup a project using in memory FS but need the usual consumption of node_modules/@types. Is this possible? am I doing something wrong? Is the proper way to do that is manually using the .createSourceFile method of the project?

CleanShot 2022-03-02 at 19 00 00@2x

What currently happens is that stuff like Promise.resolve(1) infers to any type.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dsherretcommented, Mar 3, 2022

Works for me when targeting ESNext (I think the default is ES5 and that doesn’t have Promise):

> import { Project, ts } from "https://deno.land/x/ts_morph@13.0.3/mod.ts";
undefined
> const project = new Project({ useInMemoryFileSystem: true, compilerOptions: { target: ts.ScriptTarget.ESNext } });
undefined
> const sourceFile = project.createSourceFile("test.ts", "function test() { return Promise.resolve(1); }");
undefined
> sourceFile.getFunctions()[0].getReturnType().getText()
"Promise<number>"
0reactions
jasonkuhrtcommented, Mar 3, 2022

Nothing to do with ts-morph. There’s nothing much to share for posterity really, since the issue was so specific and random to my codebase.

As always thanks @dsherret amazing project!

Read more comments on GitHub >

github_iconTop Results From Across the Web

DESIGN IN-MEMORY FILE SYSTEM - PYTHON SOLUTION
In this video we are solving a Hard level Leetcode Question : Design In-Memory File System (#588). This question seems straightforward but is ......
Read more >
Speed up your tests with an in-memory filesystem | 8th Light
Introducing: tmpfs. The above two commands will create the temporary folder, and reserve 200 megabytes of memory in RAM for anything that gets ......
Read more >
Design data structures and algorithms for in-memory file system
Explain the data structures and algorithms that you would use to design an in-memory file system. Illustrate with an example in the code...
Read more >
where are the transpiled js files when using Angular CLI
When using ng serve, the transpiled files are held in memory, not on disk. To generate the transpiled files for deployment etc, use...
Read more >
NGC stopped creating *.ngfactory.ts files for AOT - Angular 5.0
This works fine when reverting to 4.4.6 but 5.0 does not create any *.ngfactory.ts files in the aot directory that was previously working....
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