Skip to content

Commit 87d824e

Browse files
committed
fix: add typescript test for our typings (angular#9096)
* Revert "fix(d.ts): enable angular2 compilation with TS flag --strictNullChecks (angular#8902)" This reverts commit 7e352a2. * test: add typescript test for our typings
1 parent 50acb96 commit 87d824e

File tree

7 files changed

+83
-2
lines changed

7 files changed

+83
-2
lines changed

modules/@angular/core/src/util/decorators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface ClassDefinition {
2626
* Other methods on the class. Note that values should have type 'Function' but TS requires
2727
* all properties to have a narrower type than the index signature.
2828
*/
29-
[x: string]: Type | Function | any[] | undefined;
29+
[x: string]: Type | Function | any[];
3030
}
3131

3232
/**

scripts/ci-lite/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ cd `dirname $0`
99
source ./env.sh
1010
cd ../..
1111

12+
$(npm bin)/tsc -v
1213
$(npm bin)/tsc -p tools
1314
cp tools/@angular/tsc-wrapped/package.json dist/tools/@angular/tsc-wrapped
1415
node dist/tools/@angular/tsc-wrapped/src/main -p modules

scripts/ci-lite/test_e2e.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ echo 'travis_fold:end:test.buildPackages'
2323

2424

2525
./scripts/ci-lite/offline_compiler_test.sh
26+
./tools/typings-test/test.sh
2627

2728
echo 'travis_fold:start:test.e2e.localChrome'
2829
cd dist/

tools/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"target": "es5"
1818
},
1919
"exclude": [
20-
"node_modules"
20+
"node_modules",
21+
"typings-test"
2122
]
2223
}

tools/typings-test/include-all.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import * as compiler from '@angular/compiler';
2+
import * as compiler_cli from '@angular/compiler-cli';
3+
import * as compilerTesting from '@angular/compiler/testing';
4+
import * as coreTesting from '@angular/core';
5+
import * as core from '@angular/core/testing';
6+
import * as httpTesting from '@angular/http';
7+
import * as http from '@angular/http/testing';
8+
import * as platformBrowserTesting from '@angular/platform-browser';
9+
import * as platformBrowserDynmic from '@angular/platform-browser-dynamic';
10+
import * as platformBrowser from '@angular/platform-browser/testing';
11+
import * as platfomrServerTesting from '@angular/platform-server';
12+
import * as platfomrServer from '@angular/platform-server/testing';
13+
import * as router from '@angular/router';
14+
import * as routerDeprecatedTesting from '@angular/router-deprecated';
15+
import * as routerDeprecated from '@angular/router-deprecated/testing';
16+
import * as routerTesting from '@angular/router/testing';
17+
import * as upgrade from '@angular/upgrade';
18+
19+
export default {
20+
compiler,
21+
compilerTesting,
22+
compiler_cli,
23+
core,
24+
coreTesting,
25+
http,
26+
httpTesting,
27+
platformBrowser,
28+
platformBrowserTesting,
29+
platformBrowserDynmic,
30+
platfomrServer,
31+
platfomrServerTesting,
32+
router,
33+
routerTesting,
34+
routerDeprecated,
35+
routerDeprecatedTesting,
36+
upgrade
37+
}

tools/typings-test/test.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
set -ex -o pipefail
3+
4+
# These ones can be `npm link`ed for fast development
5+
LINKABLE_PKGS=(
6+
$(pwd)/dist/packages-dist/{common,core,compiler,compiler-cli,http,router,router-deprecated,upgrade,platform-{browser,browser-dynamic,server}}
7+
)
8+
9+
TMPDIR=${TMPDIR:-/tmp/angular-build/}
10+
readonly TMP=$TMPDIR/typings-test.$(date +%s)
11+
mkdir -p $TMP
12+
cp -R -v tools/typings-test/* $TMP
13+
14+
# run in subshell to avoid polluting cwd
15+
(
16+
cd $TMP
17+
# create package.json so that npm install doesn't pollute any parent node_modules's directory
18+
npm init --yes
19+
npm install ${LINKABLE_PKGS[*]}
20+
npm install @types/es6-promise @types/es6-collections @types/jasmine [email protected]
21+
npm install [email protected]
22+
$(npm bin)/tsc --version
23+
$(npm bin)/tsc -p tsconfig.json
24+
)

tools/typings-test/tsconfig.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"emitDecoratorMetadata": true,
4+
"experimentalDecorators": true,
5+
"module": "commonjs",
6+
"moduleResolution": "node",
7+
"outDir": "../../dist/typing-test/",
8+
"rootDir": ".",
9+
"target": "es5"
10+
},
11+
"files": [
12+
"include-all.ts",
13+
"node_modules/@types/es6-promise/index.d.ts",
14+
"node_modules/@types/es6-collections/index.d.ts",
15+
"node_modules/@types/jasmine/index.d.ts"
16+
]
17+
}

0 commit comments

Comments
 (0)