elsaland / elsa

❄️ Elsa is a minimal runtime for JavaScript and TypeScript written in Go
MIT License
2.8k stars 62 forks source link

typescript: respect tsconfig #32

Closed littledivy closed 4 years ago

littledivy commented 4 years ago

Respect an existing tsconfig.json both at bundling and typechecking at dev mode.

layderv commented 4 years ago

I'm taking a look at this. To understand the idea:

Where should I look at for the dev mode? I guess it's in TypeCheck(), but I'm not sure what you expect it to do

littledivy commented 4 years ago

@layderv Yup you're right about the bundler and we'd want that for now. As far as the typechecker is concerned, i'm planning on a re-write to make things much more streamlined.

EDIT: tracking issue for typechecker #67

layderv commented 4 years ago

@littledivy if I understand, this is it: https://github.com/elsaland/elsa/commit/fd262784ae2e23c674ff66ef42158a1f9ce8c81d

It tries to find tsconfig.json in the same folder as the input file. I could add a command line option instead of inferring the filepath.

My doubt is that it doesn't look to me like that Build function is doing anything with it. Did I understand correctly that is the right place?

I created a simple tsconfig.json:

{
    "compilerOptions": {
      "target": "es1",    
      "strict": true,                       
      "noImplicitAny": true,
      "strictNullChecks": true    
    }
}

It didn't error out, it bundled my typescript source file. It does check that the file exists. In this case the problem seems to be in esbuild. I'll wait for your thoughts.

layderv commented 4 years ago

@littledivy if it's as described above, I think you can close this issue

littledivy commented 4 years ago

Yes, esbuild is a bundler and not a compiler so it won't typecheck the code (reason that we have typescript compilation at dev mode in the first place) so it will only take the target and module fields from the tsconfig json.

I'll close this issue in favour of #67