dudykr / stc

Speedy TypeScript type checker
https://stc.dudy.dev
Apache License 2.0
5.76k stars 166 forks source link

Implement more logic for file loader / resolver for multi-file tests #705

Open kdy1 opened 1 year ago

kdy1 commented 1 year ago

https://github.com/dudykr/stc/pull/700 enabled a multi-file testing system, but the loader/resolver is not good enough. But I want to work on other things first, so I'm filing an issue instead.

If you run check.sh, you will see panic messages starting with not yet implemented:.

e.g.

========== Running test moduleResolution/importFromDot.ts
Source:
// @module: commonjs

// @Filename: a.ts
export const rootA = 0;

// @Filename: a/index.ts
export const indexInA = 0;

// @Filename: a/b.ts
import { indexInA, rootA } from ".";

[crates/stc_ts_type_checker/tests/tsc.rs:305] &libs = [
    Es5,
    Dom,
]
load_file: Real("a/b.ts")
resolve: Real("a/b.ts") "."
thread 'conformance::moduleResolution::importFromDot.ts' panicked at 'not yet implemented: resolve: Real("a/b.ts") "."', crates/stc_ts_type_checker/tests/tsc.rs:523:9
stack backtrace:
   0: rust_begin_unwind

Relevant code:

https://github.com/dudykr/stc/blob/86891e586d0162a7b737143910c8e2d30a1aefca/crates/stc_ts_type_checker/tests/tsc.rs#L506-L545

infix commented 1 year ago

I'd love to work on this

kdy1 commented 1 year ago

Thank you!

kdy1 commented 1 year ago

Note: Additionally, we need to handle resolving like node_modules/foo/bar. Maybe we can create a temporary directory and reuse NodeResolver instead of reimplementing a full resolver/loader for testing

infix commented 1 year ago

That makes sense, I was extremely busy last week didn't have time to work on this, will try to find some time this weekend. Sorry for the delay man.

kdy1 commented 1 year ago

No worries, really. It's definitely not something you should be sorry. I found that we need node_modules support while trying to make more good first issues.

kdy1 commented 1 year ago

@infix Are you still willing to work on this?

infix commented 1 year ago

Sorry for the delay, I'm still interested and I'll dedicate some time this weekend!

kdy1 commented 1 year ago

No worries, I'm just checking. And thank you!

DavidHancu commented 1 year ago

Hi @kdy1! If this still needs attention, I'd be willing to work on it. I've already implemented the TypeScript Module Resolution system before (for my Turboprisma project), so it should be pretty easy to do.

kdy1 commented 1 year ago

It will be really nice, thank you!

infix commented 1 year ago

@DavidHancu go for it man. I can't really dedicate time to this.

sunrabbit123 commented 1 year ago

resolve import . at #1064 resolve emit error about not exist file #1076