Skip to content

Commit f50f476

Browse files
committed
build: enable esmoduleinterop option in scripts
Similar to the `/tsconfig.json` and the `tools/tsconfig.json`, we should enable the `esModuleInterop` from TypeScript in the `scripts/` directory. This is necessary to ensure that scripts part of both compilations. e.g. when a file in `scripts/` imports from `tools/` are compatible without needing two coordinated compilations (using e.g TS project references..). In general enabling the interop means more consistency in the repo. Then only remaining exception are the schematics which we can clean-up in the future when we ship them as ES modules.
1 parent 185f875 commit f50f476

21 files changed

+35
-27
lines changed

scripts/breaking-changes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {join, relative} from 'path';
22
import {readFileSync} from 'fs';
3-
import * as chalk from 'chalk';
4-
import * as ts from 'typescript';
3+
import chalk from 'chalk';
4+
import ts from 'typescript';
55
import * as tsutils from 'tsutils';
66

77
const projectRoot = process.cwd();

scripts/check-mdc-exports.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {join} from 'path';
22
import {readdirSync, existsSync} from 'fs';
3-
import * as ts from 'typescript';
4-
import * as chalk from 'chalk';
3+
import ts from 'typescript';
4+
import chalk from 'chalk';
55
import {config} from './check-mdc-exports-config';
66

77
// Script which ensures that a particular MDC package exports all of the same symbols as its

scripts/check-mdc-tests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import {readdirSync, readFileSync} from 'fs';
22
import {join, basename} from 'path';
33
import {sync as glob} from 'glob';
4-
import * as chalk from 'chalk';
5-
import * as ts from 'typescript';
4+
import chalk from 'chalk';
5+
import ts from 'typescript';
66
import {config} from './check-mdc-tests-config';
77

88
const srcDirectory = join(__dirname, '../src');

scripts/check-package-externals.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
* be passed to this script to ensure that the list is up-to-date.
99
*/
1010

11-
import * as chalk from 'chalk';
11+
import chalk from 'chalk';
1212
import {readFileSync} from 'fs';
13-
import * as minimatch from 'minimatch';
13+
import minimatch from 'minimatch';
1414
import {join, relative} from 'path';
15-
import * as ts from 'typescript';
15+
import ts from 'typescript';
1616

1717
const projectRoot = join(__dirname, '../');
1818
const args = process.argv.slice(2);

scripts/ownerslint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as chalk from 'chalk';
1+
import chalk from 'chalk';
22
import {readdirSync, readFileSync, statSync} from 'fs';
33
import {IMinimatch, Minimatch} from 'minimatch';
44
import {join} from 'path';

scripts/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"strict": true,
99
"noEmit": true,
1010
"skipLibCheck": true,
11-
"downlevelIteration": true
11+
"downlevelIteration": true,
12+
"esModuleInterop": true
1213
},
1314
// The `firebase-functions` folder has its own `package.json` and does
1415
// not pass type-checking. This excludes it from being checked.

tools/dgeni/common/class-inheritance.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import {ApiDoc} from 'dgeni-packages/typescript/api-doc-types/ApiDoc';
44
import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc';
55
import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc';
66
import {InterfaceExportDoc} from 'dgeni-packages/typescript/api-doc-types/InterfaceExportDoc';
7-
import * as ts from 'typescript';
87
import {MemberDoc} from 'dgeni-packages/typescript/api-doc-types/MemberDoc';
98

9+
import ts from 'typescript';
10+
1011
/** Type describing class like documents which have been created through inheritance. */
1112
export type InheritanceCreatedClassLikeDoc = ClassLikeExportDoc & {
1213
_inheritanceCreated?: true;

tools/dgeni/processors/async-functions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {DocCollection, Processor} from 'dgeni';
22
import {ApiDoc} from 'dgeni-packages/typescript/api-doc-types/ApiDoc';
33
import {FunctionExportDoc} from 'dgeni-packages/typescript/api-doc-types/FunctionExportDoc';
44
import {MethodMemberDoc} from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc';
5-
import * as ts from 'typescript';
5+
6+
import ts from 'typescript';
67

78
/** Type describing a function-like API doc (i.e. a function, or a class method member). */
89
type FunctionLikeDoc = (FunctionExportDoc | MethodMemberDoc) & {

tools/dgeni/processors/categorizer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import ts from 'typescript';
2+
13
import {DocCollection, Processor} from 'dgeni';
24
import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc';
35
import {MemberDoc} from 'dgeni-packages/typescript/api-doc-types/MemberDoc';
4-
import * as ts from 'typescript';
56
import {getInheritedDocsOfClass} from '../common/class-inheritance';
67
import {
78
decorateDeprecatedDoc,

tools/dgeni/processors/merge-inherited-properties.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {DocCollection, Processor} from 'dgeni';
22
import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc';
33
import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc';
44
import {MemberDoc} from 'dgeni-packages/typescript/api-doc-types/MemberDoc';
5-
import * as ts from 'typescript';
5+
import ts from 'typescript';
66
import {getInheritedDocsOfClass} from '../common/class-inheritance';
77

88
/**

tools/dgeni/processors/resolve-inherited-docs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {DocCollection, Document, Processor} from 'dgeni';
22
import {ClassLikeExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc';
3-
import * as ts from 'typescript';
3+
import ts from 'typescript';
44
import {getInheritedDocsOfClass, isInheritanceCreatedDoc} from '../common/class-inheritance';
55
import {ClassExportDoc} from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc';
66
import {ApiDoc} from 'dgeni-packages/typescript/api-doc-types/ApiDoc';

tools/example-module/parse-example-file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as ts from 'typescript';
1+
import ts from 'typescript';
22

33
interface ParsedMetadata {
44
isPrimary: boolean;

tools/example-module/parse-example-module-file.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import * as ts from 'typescript';
21
import * as fs from 'fs';
32

3+
import ts from 'typescript';
4+
45
/** Parses an example module file by returning all module names within the given file. */
56
export function parseExampleModuleFile(filePath: string) {
67
const fileContent = fs.readFileSync(filePath, 'utf8');

tools/release-checks/npm-package-output/output-validations.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {existsSync, readFileSync} from 'fs';
22
import {sync as glob} from 'glob';
33
import {basename, dirname, isAbsolute, join} from 'path';
44
import * as semver from 'semver';
5-
import * as ts from 'typescript';
5+
6+
import ts from 'typescript';
67

78
/** RegExp that matches Angular component inline styles that contain a sourcemap reference. */
89
const inlineStylesSourcemapRegex = /styles: ?\[["'].*sourceMappingURL=.*["']/;

tools/tslint-rules/lightweightTokensRule.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import ts from 'typescript';
12
import minimatch from 'minimatch';
3+
24
import * as path from 'path';
35
import * as Lint from 'tslint';
4-
import * as ts from 'typescript';
56

67
/** Arguments this rule supports. */
78
type RuleArguments = [

tools/tslint-rules/memberNamingRule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as ts from 'typescript';
1+
import ts from 'typescript';
22
import * as tsutils from 'tsutils';
33
import * as Lint from 'tslint';
44

tools/tslint-rules/ngOnChangesPropertyAccessRule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as ts from 'typescript';
1+
import ts from 'typescript';
22
import * as Lint from 'tslint';
33

44
/**

tools/tslint-rules/noCoercionMembersRule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as ts from 'typescript';
1+
import ts from 'typescript';
22
import * as Lint from 'tslint';
33

44
/** Lint rule that disallows coercion class members. */

tools/tslint-rules/noCrossEntryPointRelativeImportsRule.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import {existsSync} from 'fs';
1+
import ts from 'typescript';
22
import minimatch from 'minimatch';
3+
4+
import {existsSync} from 'fs';
35
import {dirname, join, normalize, relative, resolve} from 'path';
46
import * as Lint from 'tslint';
5-
import * as ts from 'typescript';
67

78
const BUILD_BAZEL_FILE = 'BUILD.bazel';
89

tools/tslint-rules/requireLicenseBannerRule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as path from 'path';
2-
import * as ts from 'typescript';
32
import * as Lint from 'tslint';
43
import minimatch from 'minimatch';
4+
import ts from 'typescript';
55

66
/** License banner that is placed at the top of every public TypeScript file. */
77
const licenseBanner = `/**

tools/tslint-rules/validateDecoratorsRule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as path from 'path';
2-
import * as ts from 'typescript';
32
import * as Lint from 'tslint';
3+
import ts from 'typescript';
44
import minimatch from 'minimatch';
55

66
/**

0 commit comments

Comments
 (0)