Skip to content

Commit becb7a8

Browse files
devversiontinayuangao
authored andcommitted
build: tsconfig for editor warnings (#3791)
* build: tsconfig for editor warnings Currently when using a code editor that uses the TypeScript language service (Webstorm / VS Code / Atom / Sublime) there will be TypeScript errors in the `.spec` files. This is because the editor finds the `tsconfig.json` file that doesn't match the spec files. Therefore it complains about the `experimentalDecorators`. In `angular/angular` there is a global `tsconfig` file that matches everything and is therefore fixing the editor warnings. This file is also used to compile all `.spec` files for the whole project. We can add such a `tsconfig.json` file as well, and in the future we can use it for compiling the specs as well. * Add docs for tsconfig files
1 parent 51cfb5f commit becb7a8

11 files changed

+36
-6
lines changed

e2e/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// TypeScript config that is used to build the e2e spec files. Protractor will use TS-Node to
2+
// compile the e2e/ folder at runtime.
13
{
24
"compilerOptions": {
35
"declaration": true,

src/demo-app/tsconfig-aot.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
/* Config file for the Angular Compiler. Paths need to be relative to the dist folder. */
1+
// TypeScript config that extends the demo-app tsconfig file. This config compiles the
2+
// "main-aot.ts" file and also enables templage code generation / AOT. All paths need
3+
// to be relative to the output directory.
24
{
3-
"extends": "./tsconfig",
5+
"extends": "./tsconfig-build",
46
"compilerOptions": {
57
"experimentalDecorators": true,
68
"paths": {

src/demo-app/tsconfig.json renamed to src/demo-app/tsconfig-build.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// TypeScript config file that is used to compile the demo-app. Target environment will be ES5,
2+
// since the demo-app will be served in the browser.
13
{
24
"compilerOptions": {
35
"declaration": false,

src/e2e-app/tsconfig.json renamed to src/e2e-app/tsconfig-build.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// TypeScript config file that is used to compile the e2e-app. Protractor will run all specs
2+
// against the e2e-app in the browser and therefore the code needs to be ES5 compatible.
13
{
24
"compilerOptions": {
35
"declaration": true,

src/lib/tsconfig.json renamed to src/lib/tsconfig-build.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// TypeScript config file that is used to compile the library. Target environment needs to be
2+
// ES2015 since the build process will create FESM bundles using rollup.
13
{
24
"compilerOptions": {
35
"baseUrl": ".",

src/lib/tsconfig-specs.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
// TypeScript config file that extends the default tsconfig file for the library. This config is
2+
// used to compile the specs for Karma. Since the code will run inside of the browser, the target
3+
// needs to be ES5. The format needs to be CommonJS since Karma only supports that module format.
14
{
2-
"extends": "./tsconfig",
5+
"extends": "./tsconfig-build",
36
"compilerOptions": {
47
"module": "commonjs",
58
"target": "es5",

src/tsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// TypeScript config file that matches all source files in the project. This file is read by
2+
// IDEs and ensures that `experimentalDecorator` warnings are not showing up.
3+
{
4+
"compilerOptions": {
5+
"experimentalDecorators": true,
6+
"module": "es2015",
7+
"moduleResolution": "node",
8+
"outDir": "../../dist/packages/all",
9+
"sourceMap": true,
10+
"inlineSources": true,
11+
"target": "es2015",
12+
"lib": ["es2015", "dom"],
13+
"types": ["jasmine"]
14+
}
15+
}

tools/gulp/tasks/development.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ task(':watch:devapp', () => {
1616
});
1717

1818
/** Path to the demo-app tsconfig file. */
19-
const tsconfigPath = join(appDir, 'tsconfig.json');
19+
const tsconfigPath = join(appDir, 'tsconfig-build.json');
2020

2121
task(':build:devapp:ts', tsBuildTask(tsconfigPath));
2222
task(':build:devapp:scss', sassBuildTask(outDir, appDir));

tools/gulp/tasks/e2e.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const appDir = path.join(SOURCE_ROOT, 'e2e-app');
1313
const outDir = DIST_E2EAPP;
1414

1515
const PROTRACTOR_CONFIG_PATH = path.join(PROJECT_ROOT, 'test/protractor.conf.js');
16-
const tsconfigPath = path.join(appDir, 'tsconfig.json');
16+
const tsconfigPath = path.join(appDir, 'tsconfig-build.json');
1717

1818
task(':watch:e2eapp', () => {
1919
watch(path.join(appDir, '**/*.ts'), [':build:e2eapp:ts']);

tools/gulp/tasks/library.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const inlineResources = require('../../../scripts/release/inline-resources');
1313
const uglify = require('uglify-js');
1414

1515
const libraryRoot = join(SOURCE_ROOT, 'lib');
16-
const tsconfigPath = join(libraryRoot, 'tsconfig.json');
16+
const tsconfigPath = join(libraryRoot, 'tsconfig-build.json');
1717

1818
// Paths to the different output directories.
1919
const materialDir = DIST_MATERIAL;

tools/gulp/tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// TypeScript config file that will be used to compile the gulp tasks. The normal gulpfile will
2+
// use TS-Node to compile the gulp tasks at runtime.
13
{
24
"compilerOptions": {
35
"experimentalDecorators": true,

0 commit comments

Comments
 (0)