Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache is not cleared after tsconfig.json changes when using tsimp #6

Open
andriyor opened this issue Dec 24, 2023 · 2 comments
Open

Comments

@andriyor
Copy link

andriyor commented Dec 24, 2023

i had such error

❯ tsimp src/esm/usage.ts
(node:98619) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
src/esm/usage.ts:3:1 - error TS2584: Cannot find name 'console'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.

3 console.log(sum(2, 8));

after lib propperty change in tsconfig.json i had the same error

"lib": ["dom"],

and only after deleting of .tsimp it fixed

@andriyor andriyor changed the title cache is not cleared after tsconfig.json changes cache is not cleared after tsconfig.json changes when using tsimp Dec 24, 2023
@andrew0
Copy link
Contributor

andrew0 commented Dec 30, 2023

It seems like in general tsimp doesn't clear the cache for any changes to a file's dependency tree (including the tsconfig). For example:

  1. Create two files, "foo.ts" and "bar.ts":

    foo.ts

    export {};

    bar.ts

    import {foo} from './foo.js';
    
    foo();
  2. Run node --import=tsimp/import bar.ts:

    bar.ts:1:10 - error TS2305: Module '"./foo.js"' has no exported member 'foo'.
    
    1 import { foo } from './foo.js';
            ~~~
    
    bar.ts:1
    import { foo } from './foo.js';
            ^
    
    SyntaxError: The requested module './foo.js' does not provide an export named 'foo'
        at ModuleJob._instantiate (node:internal/modules/esm/module_job:131:21)
        at async ModuleJob.run (node:internal/modules/esm/module_job:213:5)
        at async ModuleLoader.import (node:internal/modules/esm/loader:308:24)
        at async loadESM (node:internal/process/esm_loader:42:7)
        at async handleMainPromise (node:internal/modules/run_main:66:12)
    
  3. Update foo.ts implementation to fix TypeScript error:

    foo.ts

    export function foo() {
      console.log('hello world');
    }
  4. Run node --import=tsimp/import bar.ts again, and it still shows the old error:

    bar.ts:1:10 - error TS2305: Module '"./foo.js"' has no exported member 'foo'.
    
    1 import { foo } from './foo.js';
            ~~~
    
    hello world
    

After clearing the .tsimp cache, the type error goes away.

@NoahAndrews
Copy link

NoahAndrews commented Jun 7, 2024

@andrew0 I filed #20 for that issue. That being said, it doesn't seem to actually be an issue with the on-disk cache (all you need to do is restart the daemon, not delete the cache).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants