lathonez / clicker

Ionic 2 + @angular/cli Seed Project : Angular2 + Typescript + Karma + Protractor + Travis
http://lathonez.com/2018/ionic-2-unit-testing/
MIT License
430 stars 137 forks source link

Different tsconfig.json for ionic? #273

Closed studds closed 6 years ago

studds commented 6 years ago

This is more of a question / clarification... the instructions here http://lathonez.com/2017/ionic-2-e2e-testing/ recommend adding "exclude": ["node_modules", "src/test.ts", "e2e"], to tsconfig.json. This makes sense, but it means that vscode, which using tsconfig.json, won't report errors in test files. (Or at least, it won't report errors that require type checking. I'm also using https://github.com/angelozerr/tslint-language-service and so linting isn't available in excluded files.

Is there a recommended approach here? Is there a way to direct ionic to use a different tsconfig.json, similar to how ng cli has a tsconfig per-task? Alternatively, does it actually matter if these files aren't excluded?

lathonez commented 6 years ago

it means that vscode, which using tsconfig.json, won't report errors in test files

I have the same issue in webstorm, when I last looked there wasn't a way to direct the editor to use a specific config file. Unfortunately the best way I've found to work around this is to comment out the exclude when I'm not running the app.

I'm also using https://github.com/angelozerr/tslint-language-service and so linting isn't available in excluded files.

Sorry I don't know about tslint-language-service.

Is there a way to direct ionic to use a different tsconfig.json, similar to how ng cli has a tsconfig per-task?

Not to my knowledge, least not the last time I checked. Ionic are constantly improving their scripts, so this may have changed.

Alternatively, does it actually matter if these files aren't excluded?

There's a lot of history here.. #159 #167 #170 #174 #236

Here's the relevant comment where we finally added it back: https://github.com/lathonez/clicker/issues/236#issuecomment-286299057

So, it seems they are only there for ionic build --prod. I have run that locally and it works OK, so am going to remove them and see what breaks in CI / who complains about it.

lathonez commented 6 years ago

So yea, it breaks on windows: https://ci.appveyor.com/project/lathonez/clicker/build/1.0.147

lathonez commented 6 years ago

Added the Jasmine types back in, which fixed it previously on Windows

lathonez commented 6 years ago

looks good.

So basically - you no longer need the excludes. If you are running windows you need to add jasmine types. Have never been able to figure out why these are not needed on linux based distro.

See recent commits, will update the blog.

Thanks