build: refactor ambient node & jasmine types so they are only included where needed (#25491)

PR Close #25491
This commit is contained in:
Greg Magolan
2018-08-14 16:18:26 -07:00
committed by Jason Aden
parent 9ee6702fa9
commit 9605456b66
21 changed files with 69 additions and 12 deletions

View File

@ -2,6 +2,7 @@ package(default_visibility = ["//visibility:public"])
exports_files([
"tsconfig-build.json",
"tsconfig-test.json",
"tsconfig.json",
])

View File

@ -10,6 +10,11 @@ import {AUTO_STYLE, AnimationEvent, AnimationPlayer, NoopAnimationPlayer, ɵAnim
import {AnimationStyleNormalizer} from '../../src/dsl/style_normalization/animation_style_normalizer';
import {AnimationDriver} from '../../src/render/animation_driver';
// We don't include ambient node types here since @angular/animations/browser
// is meant to target the browser so technically it should not depend on node
// types. `process` is just declared locally here as a result.
declare const process: any;
export function isBrowser() {
return (typeof window !== 'undefined' && typeof window.document !== 'undefined');
}

View File

@ -37,6 +37,7 @@ jasmine_node_test(
ts_library(
name = "example_spec_lib",
testonly = True,
srcs = ["example_package.spec.ts"],
deps = ["//packages:types"],
)
@ -55,6 +56,7 @@ jasmine_node_test(
nodejs_binary(
name = "example_package.accept",
testonly = True,
data = [
"example_package.golden",
":example_spec_lib",

View File

@ -6,6 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
/// <reference types="node" />
// Must be imported first, because Angular decorators throw on load.
import 'reflect-metadata';

View File

@ -6,6 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
/// <reference types="node" />
export {ResourceLoader} from './src/api';
export {BaseDefDecoratorHandler} from './src/base_def';
export {ComponentDecoratorHandler} from './src/component';

View File

@ -6,6 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
/// <reference types="node" />
export {FactoryGenerator} from './src/generator';
export {GeneratedFactoryHostWrapper} from './src/host';
export {FactoryInfo, generatedFactoryTransform} from './src/transform';

View File

@ -6,5 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
/// <reference types="node" />
export {TypeScriptReflectionHost, filterToMembersWithDecorator, findMember, reflectObjectLiteral, reflectTypeEntityToDeclaration} from './src/reflector';
export {AbsoluteReference, ImportMode, Reference, ResolvedReference, ResolvedValue, isDynamicValue, staticallyResolve} from './src/resolver';

View File

@ -6,6 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
/// <reference types="node" />
import * as path from 'path';
const TS_DTS_EXTENSION = /(\.d)?\.ts$/;

View File

@ -13,6 +13,7 @@ UTILS = [
ts_library(
name = "test_utils",
testonly = True,
srcs = UTILS,
visibility = [
"//packages/compiler-cli/test:__subpackages__",

View File

@ -6,6 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
/// <reference types="node" />
/**
* @module
* @description

View File

@ -6,6 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
/// <reference types="jasmine" />
/**
* @module
* @description

View File

@ -6,6 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
/// <reference types="node" />
/**
* @module
* @description

View File

@ -6,6 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
/// <reference types="jasmine" />
/**
* @module
* @description

View File

@ -6,6 +6,8 @@
* found in the LICENSE file at https://angular.io/license
*/
/// <reference types="node" />
/**
* @module
* @description

View File

@ -6,6 +6,7 @@ load("//tools:defaults.bzl", "ng_module")
ng_module(
name = "testing",
testonly = True,
srcs = glob(
["**/*.ts"],
),

View File

@ -0,0 +1,9 @@
/**
* Root tsconfig file for use in all tests.
*/
{
"extends": "./tsconfig-build.json",
"compilerOptions": {
"types": ["node", "jasmine"],
},
}

9
packages/types.d.ts vendored
View File

@ -9,13 +9,18 @@
// This file contains all ambient imports needed to compile the packages/ source code
/// <reference types="hammerjs" />
/// <reference types="jasmine" />
/// <reference types="node" />
/// <reference types="zone.js" />
/// <reference path="./es6-subset.d.ts" />
/// <reference path="./goog.d.ts" />
/// <reference path="./system.d.ts" />
// Do not included "node" and "jasmine" types here as we don't
// want these ambient types to be included everywhere.
// Tests will bring in ambient node & jasmine types with
// /packages/tsconfig-test.json when `testonly = True` is set
// and packages such as platform-server that need these types should
// use `/// <reference types="x">` in their main entry points
declare let isNode: boolean;
declare let isBrowser: boolean;