Skip to content

ci(schematics): skipLibCheck on compile for schematics #13883

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

Merged
merged 8 commits into from
Feb 13, 2024
Merged

Conversation

Lipata
Copy link
Member

@Lipata Lipata commented Feb 8, 2024

Enable skipLibCheck for schematics compilation, because node_modules/@types/node contains multiple versions and leads to the following problem. The solution was taken from: https://bobbyhadz.com/blog/typescript-duplicate-identifier#pulling-in-typings-from-multiple-versions-of-a-package.

I've tried to update the @types/node package, but even with the latest, it contains multiple versions and the tsconfig setting is needed. Anyway, all the types are updated along with the typescript package. Typescript was initially updated, along with @types, but we prefer to be automatically updated by a major/minor ng-update.

The build:schematics script can be used for verification.

@Lipata Lipata added the ❌ status: awaiting-test PRs awaiting manual verification label Feb 8, 2024
@damyanpetev
Copy link
Member

Correction on the description: @types/node has had this split by typesVersions folders since at least v16 (likely earlier) and moving through supported TypeScript versions. At least in the previous version we had on this duplicate for URL was present https://unpkg.com/browse/@types/node@18.11.19/ts4.8/url.d.ts but not double-included in the build process as intended.

What has changed though:
v16 of the DevKit schematics did not have explicit references https://unpkg.com/browse/@angular-devkit/schematics@16.2.12/src/engine/engine.d.ts
vs v17 https://unpkg.com/browse/@angular-devkit/schematics@17.1.3/src/engine/engine.d.ts:

/// <reference types="@types/node/url" />
/// <reference types="@types/node/ts4.8/url" />

Which causes this:

node_modules/@types/node/url.d.ts
  Type library referenced via '@types/node/url' from file 'node_modules/@angular-devkit/schematics/src/engine/engine.d.ts' with packageId '@types/node/url.d.ts@20.8.10'
  Referenced via 'url.d.ts' from file 'node_modules/@types/node/index.d.ts'
node_modules/@types/node/ts4.8/url.d.ts
  Type library referenced via '@types/node/ts4.8/url' from file 'node_modules/@angular-devkit/schematics/src/engine/engine.d.ts' with packageId '@types/node/ts4.8/url.d.ts@20.8.10'

and then the build error:

node_modules/@types/node/ts4.8/url.d.ts:365:11 - error TS2300: Duplicate identifier 'URL'.
365     class URL {
              ~~~
  node_modules/@types/node/url.d.ts:365:11
    365     class URL {
                  ~~~
    'URL' was also declared here.

Not exactly sure what the compile reason is for those references (I believe those are auto-emitted) and it might be a third-party issue to begin with.

However, the default empty schematic project as provided by the Schematics CLI via schematics blank also sets skipLibCheck by default (https://github.com/angular/angular-cli/blob/860b93a25bd7a013e1542e09f96766bb7f384e39/packages/angular_devkit/schematics_cli/blank/project-files/tsconfig.json#L16) and also fails similarly if disabled for the same reason, so I guess running without the check is not uncommon and we could do that.

@Lipata Lipata removed the ❌ status: awaiting-test PRs awaiting manual verification label Feb 13, 2024
@Lipata Lipata merged commit 1ece5cd into master Feb 13, 2024
@Lipata Lipata deleted the schematics-types branch February 13, 2024 20:51
damyanpetev pushed a commit that referenced this pull request Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants