diff --git a/WORKSPACE b/WORKSPACE index 2abf5f6cc8..1beda0c030 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -16,7 +16,7 @@ node_repositories(package_json = ["//:package.json"]) git_repository( name = "build_bazel_rules_typescript", remote = "https://github.com/bazelbuild/rules_typescript.git", - commit = "eb3244363e1cb265c84e723b347926f28c29aa35" + commit = "d3ad16d1f105e2490859da9ad528ba4c45991d09" ) load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace") diff --git a/integration/bazel/WORKSPACE b/integration/bazel/WORKSPACE index f063fe7d64..a5983fedb5 100644 --- a/integration/bazel/WORKSPACE +++ b/integration/bazel/WORKSPACE @@ -14,7 +14,7 @@ node_repositories(package_json = ["//:package.json"]) git_repository( name = "build_bazel_rules_typescript", remote = "https://github.com/bazelbuild/rules_typescript.git", - commit = "eb3244363e1cb265c84e723b347926f28c29aa35" + commit = "d3ad16d1f105e2490859da9ad528ba4c45991d09" ) load("@build_bazel_rules_typescript//:defs.bzl", "ts_setup_workspace") diff --git a/packages/bazel/test/ngc-wrapped/index_test.ts b/packages/bazel/test/ngc-wrapped/index_test.ts index b7cce77b1d..49a85d99a6 100644 --- a/packages/bazel/test/ngc-wrapped/index_test.ts +++ b/packages/bazel/test/ngc-wrapped/index_test.ts @@ -18,12 +18,22 @@ describe('ngc_wrapped', () => { write('some_project/index.ts', ` import {Component} from '@angular/core'; + import {a} from 'ambient_module'; console.log('works: ', Component); `); - writeConfig({ + const tsconfig = writeConfig({ srcTargetPath: 'some_project', }); + const typesFile = path.resolve( + tsconfig.compilerOptions.rootDir, tsconfig.compilerOptions.typeRoots[0], 'thing', + 'index.d.ts'); + + write(typesFile, ` + declare module "ambient_module" { + declare const a = 1; + } + `); // expect no error expect(runOneBuild()).toBe(true); diff --git a/packages/bazel/test/ngc-wrapped/test_support.ts b/packages/bazel/test/ngc-wrapped/test_support.ts index 9246d57efb..eec4cb8ee0 100644 --- a/packages/bazel/test/ngc-wrapped/test_support.ts +++ b/packages/bazel/test/ngc-wrapped/test_support.ts @@ -24,7 +24,7 @@ export interface TestSupport { srcTargetPath: string, depPaths?: string[], pathMapping?: Array<{moduleName: string; path: string;}>, - }): void; + }): {compilerOptions: ts.CompilerOptions}; read(fileName: string): string; write(fileName: string, content: string): void; writeFiles(...mockDirs: {[fileName: string]: string}[]): void; @@ -68,11 +68,19 @@ export function setup( // ----------------- // helpers + function mkdirp(dirname: string) { + const parent = path.dirname(dirname); + if (!fs.existsSync(parent)) { + mkdirp(parent); + } + fs.mkdirSync(dirname); + } + function write(fileName: string, content: string) { const dir = path.dirname(fileName); if (dir != '.') { const newDir = path.resolve(basePath, dir); - if (!fs.existsSync(newDir)) fs.mkdirSync(newDir); + if (!fs.existsSync(newDir)) mkdirp(newDir); } fs.writeFileSync(path.resolve(basePath, fileName), content, {encoding: 'utf-8'}); } @@ -126,6 +134,7 @@ export function setup( pathMapping: pathMappingObj, }); write(path.resolve(basePath, tsConfigJsonPath), JSON.stringify(tsconfig, null, 2)); + return tsconfig; } function shouldExist(fileName: string) {