build: refactor ambient node & jasmine types so they are only included where needed (#25491)
PR Close #25491
This commit is contained in:
@ -2,6 +2,7 @@ package(default_visibility = ["//visibility:public"])
|
||||
|
||||
exports_files([
|
||||
"tsconfig-build.json",
|
||||
"tsconfig-test.json",
|
||||
"tsconfig.json",
|
||||
])
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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';
|
||||
|
@ -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$/;
|
||||
|
@ -13,6 +13,7 @@ UTILS = [
|
||||
|
||||
ts_library(
|
||||
name = "test_utils",
|
||||
testonly = True,
|
||||
srcs = UTILS,
|
||||
visibility = [
|
||||
"//packages/compiler-cli/test:__subpackages__",
|
||||
|
@ -6,6 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
/**
|
||||
* @module
|
||||
* @description
|
||||
|
@ -6,6 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
/// <reference types="jasmine" />
|
||||
|
||||
/**
|
||||
* @module
|
||||
* @description
|
||||
|
@ -6,6 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
/**
|
||||
* @module
|
||||
* @description
|
||||
|
@ -6,6 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
/// <reference types="jasmine" />
|
||||
|
||||
/**
|
||||
* @module
|
||||
* @description
|
||||
|
@ -6,6 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
/**
|
||||
* @module
|
||||
* @description
|
||||
|
@ -6,6 +6,7 @@ load("//tools:defaults.bzl", "ng_module")
|
||||
|
||||
ng_module(
|
||||
name = "testing",
|
||||
testonly = True,
|
||||
srcs = glob(
|
||||
["**/*.ts"],
|
||||
),
|
||||
|
9
packages/tsconfig-test.json
Normal file
9
packages/tsconfig-test.json
Normal 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
9
packages/types.d.ts
vendored
@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user