Skip to content

[feat] ability to disable type check for .ts files like forkTypeChecker: false for Ivy #20410

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

Closed
2 of 15 tasks
JounQin opened this issue Mar 31, 2021 · 6 comments
Closed
2 of 15 tasks
Labels
needs: more info Reporter must clarify the issue

Comments

@JounQin
Copy link
Contributor

JounQin commented Mar 31, 2021

🚀 Feature request

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Description

In my company, we have tsc --noEmit to ensure there is no type error for .ts files already, so type checking for .ts on development is redundant and noisy for debugging. So We hope to disable type checking for .ts files.

But for .html files or template option of Component, tsc --noEmit can not help, so I hope type checking will still work with strictTemplates.

Of course, if ngcc --noEmit can achieve similar functionality for both .html and .ts files, that would be greater!

Describe the solution you'd like

As description

Describe alternatives you've considered

N/A

@alan-agius4
Copy link
Collaborator

Hi @JounQin,

Regarding your comment

so type checking for .ts on development is redundant and noisy for debugging

I am not sure how type checking is redundant and noisy during debugging, it gives you information about potential code errors ahead of time during build time, therefore if anything it should make you more confident in the code you are debugging.

Realistically speaking, I don't think we will ever provide an option to turn off type-checking or disable errors. Related issue #19948

@alan-agius4 alan-agius4 added the needs: more info Reporter must clarify the issue label Mar 31, 2021
@JounQin
Copy link
Contributor Author

JounQin commented Mar 31, 2021

NGC already supports the no emit option.

Can it be run on .html files?

forkTypeChecker doesn't disable type-checking, it does type checking in a forked process.

Doesn't forkTypeChecker: false disable type-checking?

I am not sure how type checking is redundant and noisy during debugging, it gives you information about potential code errors ahead of time during build time, therefore if anything it should make you more confident in the code you are debugging.

We've already had tsc --noEmit like eslint . before committing, so type-checking for .ts files (not .html files) becomes redundant and noisy to us, and the IDE already shows the errors for .ts files. Type checking is expensive as you said, so we'd prefer minimal occupancy.

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Mar 31, 2021

Can it be run on .html files?

Yes, it does.

Doesn't forkTypeChecker: false disable type-checking?

No, it just delegates type-checking to a forked process.

We've already had tsc --noEmit like eslint . before committing, so type-checking for .ts files (not .html files) becomes redundant and noisy to us, and the IDE already shows the errors for .ts files. Type checking is expensive as you said, so we'd prefer minimal occupancy.

I see your point here. IMHO, I think type-checking should be used all the time throughout development and not at the very end of the development cycle. Also there is no way to fully disable type-checking fully in TypeScript compiler. You can choose not to show the errors but this is something that is not on the table as ignoring errors is the wrong approach.

@JounQin
Copy link
Contributor Author

JounQin commented Mar 31, 2021

Can it be run on .html files?

Yes, it does.

Thanks for clarify, I tried, and it's working, although it's a bit slow.

No, it just delegates type-checking to a forked process.

I'm not sure to understand,

if (this._forkTypeChecker && !this._typeCheckerProcess) {
this._createForkedTypeChecker();
}
when _forkTypeChecker is false, forkTypeChecker will not be created, will it?

Also there is no way to fully disable type-checking fully in TypeScript compiler.

ts-loader and ts-node both have an option transpileOnly, so I suppose that it should be possible, or at least an option to not emit errors for .ts files.


And TypeScript has an option noEmitOnError which is false by default, I hope errors do not break app compiling and running on development. I understand we should fix type errors before committing, but on development, it breaks the app a lot on debugging a large app.

@alan-agius4
Copy link
Collaborator

when _forkTypeChecker is false, forkTypeChecker will not be created, will it?

When false, the forked type-checker will not be created, but type-checking will be done in the main process.

const diagMode = (this._firstRun || !this._forkTypeChecker) ?
DiagnosticMode.All : DiagnosticMode.Syntactic;

And TypeScript has an option noEmitOnError which is false by default, I hope errors do not break app compiling and running on development. I understand we should fix type errors before committing, but on development, it breaks the app a lot on debugging a large app.

Indeed there is an option to use noEmitOnError, however we don't want to expose this option as previously mentioned in #19948 and #11652 part of the public API. If you wish to change the value of this option you'd need to use a third-party builder that extends the CLI such as https://github.com/manfredsteyer/ngx-build-plus.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: more info Reporter must clarify the issue
Projects
None yet
Development

No branches or pull requests

2 participants