1 | /**
|
2 | * @license
|
3 | * Copyright Google LLC All Rights Reserved.
|
4 | *
|
5 | * Use of this source code is governed by an MIT-style license that can be
|
6 | * found in the LICENSE file at https://angular.io/license
|
7 | */
|
8 | import { BabelFile, types as t } from '@babel/core';
|
9 |
|
10 | /**
|
11 | * Augment some Babel types to add symbols that we rely on, but are not included in the Babel typings.
|
12 | */
|
13 |
|
14 | declare module '@babel/traverse' {
|
15 | interface Hub {
|
16 | file: BabelFile;
|
17 | }
|
18 | }
|
19 |
|
20 | declare module '@babel/core' {
|
21 | interface BabelFile {
|
22 | buildCodeFrameError(node: t.Node, message: string): Error;
|
23 | }
|
24 | }
|
25 |
|
26 | // The following modules are declared to work around a limitation in tsc_wrapped's `strict_deps`
|
27 | // check. Since Babel uses scoped packages, the corresponding lookup for declaration files in the
|
28 | // `node_modules/@types/` directory follows a special strategy: the `@types` package has to be
|
29 | // named `{scope}__{package}`, e.g. `@types/babel__generator`. When `tsc` performs module
|
30 | // resolution for the `@babel/generator` module specifier, it will first try the `paths` mappings
|
31 | // but resolution through path mappings does _not_ apply this special naming convention rule for
|
32 | // `@types` packages, `tsc` only applies that rule in its `@types` resolution step. Consequently,
|
33 | // the path mapping into Bazel's private `node_modules` directory fails to resolve, causing `tsc`
|
34 | // to find the nearest `node_modules` directory in an ancestor directory of the origin source
|
35 | // file. This finds the `node_modules` directory in the workspace, _not_ Bazel's private copy of
|
36 | // `node_modules` and therefore the `@types` end up being resolved from a `node_modules` tree
|
37 | // that is not governed by Bazel, and therefore not expected by the `strict_deps` rule.
|
38 | // Declaring the modules here allows `strict_deps` to always find a declaration of the modules
|
39 | // in an input file to the compilation, therefore accepting the module import.
|
40 | declare module '@babel/generator' {}
|
41 | declare module '@babel/template' {}
|
42 | declare module '@babel/parser' {}
|