Alex Rickabaugh 8f425701e4 test(ivy): enable //packages/bazel/test/ngc-wrapped/... tests for Ivy (#27470)
This commit allows //packages/bazel/test/ngc-wrapped/... tests to run
under Ivy mode. To get them to pass, it addresses a problem with the
way the tests are configured: both test targets have sloppy .d.ts
dependencies configured, leading to many type errors being generated
in TypeScript for the .d.ts files.

Due to the way ngc directs TypeScript emit, it avoids type-checking
.d.ts files and thus this issue does not surface. ngtsc does a whole-
program emit which results in full .d.ts type-checking by default,
catching this configuration issue.

To fix this, skipLibCheck is added to the tsconfig.jsons for these
tests, which tells TypeScript to skip type-checking of the .d.ts files,
avoiding this problem in a similar way to ngc.

PR Close #27470
2018-12-05 10:46:51 -08:00

51 lines
1.4 KiB
TypeScript

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {fixmeIvy} from '@angular/private/testing';
import * as fs from 'fs';
import * as path from 'path';
import {setup} from './test_support';
describe('ngc_wrapped', () => {
// fixmeIvy placeholder to prevent jasmine from erroring out because there are no specs
it('should be removed once the fixmeIvy below is resolved', () => {});
it('should work', () => {
const {read, write, runOneBuild, writeConfig, shouldExist, basePath} = setup();
write('some_project/index.ts', `
import {Component} from '@angular/core';
import {a} from 'ambient_module';
console.log('works: ', Component);
`);
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);
shouldExist('bazel-bin/some_project/index.js');
expect(read('bazel-bin/some_project/index.js'))
.toContain(`console.log('works: ', core_1.Component);`);
});
});