diff --git a/modules/playground/e2e_test/example_test.bzl b/modules/playground/e2e_test/example_test.bzl index 41fdc97a357..64da4af375c 100644 --- a/modules/playground/e2e_test/example_test.bzl +++ b/modules/playground/e2e_test/example_test.bzl @@ -1,6 +1,6 @@ load("//tools:defaults.bzl", "protractor_web_test_suite", "ts_library") -def example_test(name, srcs, server, data = [], **kwargs): +def example_test(name, srcs, server, data = [], deps = [], **kwargs): ts_library( name = "%s_lib" % name, testonly = True, @@ -12,7 +12,7 @@ def example_test(name, srcs, server, data = [], **kwargs): "@npm//@types/jasminewd2", "@npm//@types/selenium-webdriver", "@npm//protractor", - ], + ] + deps, ) protractor_web_test_suite( diff --git a/modules/playground/e2e_test/sourcemap/BUILD.bazel b/modules/playground/e2e_test/sourcemap/BUILD.bazel index 943adc8d2ad..94ec1116806 100644 --- a/modules/playground/e2e_test/sourcemap/BUILD.bazel +++ b/modules/playground/e2e_test/sourcemap/BUILD.bazel @@ -8,4 +8,7 @@ example_test( "//modules/playground/src/sourcemap:index.ts", ], server = "//modules/playground/src/sourcemap:devserver", + deps = [ + "@npm//source-map", + ], ) diff --git a/modules/playground/e2e_test/sourcemap/sourcemap_spec.ts b/modules/playground/e2e_test/sourcemap/sourcemap_spec.ts index 2e51457d554..adcd5710124 100644 --- a/modules/playground/e2e_test/sourcemap/sourcemap_spec.ts +++ b/modules/playground/e2e_test/sourcemap/sourcemap_spec.ts @@ -6,11 +6,10 @@ * found in the LICENSE file at https://angular.io/license */ +import {readFileSync} from 'fs'; import {$, browser} from 'protractor'; import {logging} from 'selenium-webdriver'; - -const fs = require('fs'); -const sourceMap = require('source-map'); +import {RawSourceMap, SourceMapConsumer} from 'source-map'; describe('sourcemaps', function() { const URL = '/'; @@ -36,19 +35,18 @@ describe('sourcemaps', function() { const content = - fs.readFileSync(require.resolve('../../src/sourcemap/index.js')).toString('utf8'); + readFileSync(require.resolve('../../src/sourcemap/index.js')).toString('utf8'); const marker = '//# sourceMappingURL=data:application/json;base64,'; const index = content.indexOf(marker); const sourceMapData = Buffer.from(content.substring(index + marker.length), 'base64').toString('utf8'); - const decoder = new sourceMap.SourceMapConsumer(JSON.parse(sourceMapData)); + const decoder = new SourceMapConsumer(JSON.parse(sourceMapData) as RawSourceMap); const originalPosition = decoder.originalPositionFor({line: errorLine, column: errorColumn}); - - const sourceCodeLines = fs.readFileSync(require.resolve('../../src/sourcemap/index.ts'), { - encoding: 'UTF-8' - }).split('\n'); + const sourceCodeLines = readFileSync(require.resolve('../../src/sourcemap/index.ts'), { + encoding: 'UTF-8' + }).split('\n'); expect(sourceCodeLines[originalPosition.line - 1]) .toMatch(/throw new Error\(\'Sourcemap test\'\)/); }); diff --git a/packages/compiler/src/aot/summary_serializer.ts b/packages/compiler/src/aot/summary_serializer.ts index ccf517b65fc..956910f3116 100644 --- a/packages/compiler/src/aot/summary_serializer.ts +++ b/packages/compiler/src/aot/summary_serializer.ts @@ -461,7 +461,7 @@ class FromJsonDeserializer extends ValueTransformer { summaries: Summary[], importAs: {symbol: StaticSymbol, importAs: StaticSymbol}[] } { - const data: {moduleName: string|null, summaries: any[], symbols: any[]} = JSON.parse(json); + const data = JSON.parse(json) as {moduleName: string | null, summaries: any[], symbols: any[]}; const allImportAs: {symbol: StaticSymbol, importAs: StaticSymbol}[] = []; this.symbols = data.symbols.map( (serializedSymbol) => this.symbolCache.get( diff --git a/packages/compiler/test/aot/test_util.ts b/packages/compiler/test/aot/test_util.ts index 41d6a3858f1..bb37cf06fed 100644 --- a/packages/compiler/test/aot/test_util.ts +++ b/packages/compiler/test/aot/test_util.ts @@ -427,7 +427,7 @@ export class MockAotCompilerHost implements AotCompilerHost { if (this.metadataVisible) { const metadataPath = modulePath.replace(DTS, '.metadata.json'); if (this.tsHost.fileExists(metadataPath)) { - let result = JSON.parse(this.tsHost.readFile(metadataPath)); + let result = JSON.parse(this.tsHost.readFile(metadataPath)) as {[key: string]: any}[]; return Array.isArray(result) ? result : [result]; } }