build: remove unneeded babel types postinstall patching (#53441)

These patches are no longer necessary with the current state of the
type packages and the code within the repository. The types are now
included in the already required babel.d.ts file for the relevant
babel packages (currently: `@babel/core` and `@babel/generator`).

PR Close #53441
This commit is contained in:
Charles Lyding 2023-12-05 17:50:38 -05:00 committed by Alex Rickabaugh
parent ad52eeb164
commit 119a94ef4b
4 changed files with 7 additions and 19 deletions

View file

@ -5,7 +5,6 @@
```ts
/// <reference types="@angular/compiler-cli/private/babel" />
/// <reference types="@types/babel__core" />
import { AbsoluteFsPath } from '@angular/compiler-cli/private/localize';
import { Element as Element_2 } from '@angular/compiler';

View file

@ -20,5 +20,9 @@
// that is not governed by Bazel, and therefore not expected by the `strict_deps` rule.
// Declaring the modules here allows `strict_deps` to always find a declaration of the modules
// in an input file to the compilation, therefore accepting the module import.
declare module '@babel/core' {}
declare module '@babel/generator' {}
declare module '@babel/core' {
export * from '@types/babel__core';
}
declare module '@babel/generator' {
export { default } from '@types/babel__generator';
}

View file

@ -7,6 +7,7 @@ ts_library(
deps = [
"//packages/compiler-cli/linker",
"//packages/compiler-cli/linker/babel",
"//packages/compiler-cli/private",
"//packages/compiler-cli/src/ngtsc/file_system",
"//packages/compiler-cli/src/ngtsc/logging",
"//packages/compiler-cli/src/ngtsc/sourcemaps",

View file

@ -45,22 +45,6 @@ sed('-i', '(\'response\' in xhr)', '(\'response\' in (xhr as any))',
'node_modules/rxjs/src/observable/dom/AjaxObservable.ts');
*/
// Workaround https://github.com/bazelbuild/rules_nodejs/issues/1033
// TypeScript doesn't understand typings without "declare module" unless
// they are actually resolved by the @types default mechanism
log('\n# patch: @types/babel__* adding declare module wrappers');
ls('node_modules/@types').filter(f => f.startsWith('babel__')).forEach(pkg => {
const modName = '@' + pkg.replace('__', '/');
const typingsFile = `node_modules/@types/${pkg}/index.d.ts`;
// Only add the patch if it is not already there.
if (readFileSync(typingsFile, 'utf8').indexOf('/*added by tools/postinstall_patches.js*/') ===
-1) {
const insertPrefix = `/*added by tools/postinstall_patches.js*/ declare module "${modName}" { `;
sed('-i', `(// Type definitions for ${modName})`, insertPrefix + '$1', typingsFile);
echo('}').toEnd(typingsFile);
}
});
log('\n# patch: delete d.ts files referring to rxjs-compat');
// more info in https://github.com/angular/angular/pull/33786
rm('-rf', [