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

fix(compiler): ignore TS diagnostics on builds where typedef file changes #5013

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/compiler/transpile/run-program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ export const runTsProgram = async (
await Promise.all(srcRootDtsFiles);
}

if (config.validateTypes) {
// TODO(STENCIL-540): remove `hasTypesChanged` check and figure out how to generate types before
// executing the TS build program so we don't get semantic diagnostic errors about referencing the
// auto-generated `components.d.ts` file.
if (config.validateTypes && !hasTypesChanged) {
Comment on lines +135 to +138
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there's an emitOnlyDtsFiles option for the .emit callback that we call here:

https://github.com/ionic-team/stencil/blob/4fd0ecd17e72f6892c96b8256a0206f6e583be13/src/compiler/transpile/run-program.ts#L91-L92

possibly I'm misunderstanding the comment here - but if we ran a dts-only emit first and then the whole program would that prevent the error? Probably that would be slower so not necessarily saying we want to, more just wondering if that's indeed how it works here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there'd still be an issue since we don't generate the components.d.ts file until after the TS program has ran/emitted the files. What we really need to do is generate the components.d.ts file before we run the TS program so that the file exists before the build. We can do this, just need to restructure things a bit more since we don't have the components metadata on the BuildCtx until the build callback, at which point the TS program has already ran and generated the diagnostics. This was just intended as a quick fix to remedy the regression until we can take the step for the desired, long term solution

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh I think I sort of forgot that the components.d.ts is so artisanal, makes sense!

const tsSemantic = loadTypeScriptDiagnostics(tsBuilder.getSemanticDiagnostics());
if (config.devMode) {
tsSemantic.forEach((semanticDiagnostic) => {
Expand Down