Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"outDir": "./dist/out-tsc",<% if (strict) { %>
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noFallthroughCasesInSwitch": true,
"strictNullChecks": true,<% } %>
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
Expand Down
12 changes: 12 additions & 0 deletions packages/schematics/angular/workspace/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,16 @@ describe('Workspace Schematic', () => {
expect(files).not.toContain('/tslint.json');
expect(files).not.toContain('/.editorconfig');
});

it('should not add strict compiler options when false', async () => {
const tree = await schematicRunner.runSchematicAsync('workspace', { ...defaultOptions, strict: false }).toPromise();
const { compilerOptions } = JSON.parse(tree.readContent('/tsconfig.json'));
expect(compilerOptions.strictNullChecks).not.toBeDefined();
});

it('should not add strict compiler options when true', async () => {
const tree = await schematicRunner.runSchematicAsync('workspace', { ...defaultOptions, strict: true }).toPromise();
const { compilerOptions } = JSON.parse(tree.readContent('/tsconfig.json'));
expect(compilerOptions.strictNullChecks).toBe(true);
});
});
5 changes: 5 additions & 0 deletions packages/schematics/angular/workspace/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
"type": "boolean",
"default": false,
"x-user-analytics": 14
},
"strict": {
"description": "Creates a workspace with stricter TypeScript compiler options.",
"type": "boolean",
"default": false
}
},
"required": [
Expand Down
2 changes: 2 additions & 0 deletions tests/legacy-cli/e2e/tests/build/platform-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export default async function () {
const veEnabled = argv['ve'];

await ng('add', '@nguniversal/express-engine', '--client-project', 'test-project');
// todo remove once https://github.com/angular/universal/pull/1229 is landed
await silentNpm('install', '@types/express', '--save-dev');

await updateJsonFile('package.json', packageJson => {
const dependencies = packageJson['dependencies'];
Expand Down
2 changes: 1 addition & 1 deletion tests/legacy-cli/e2e/tests/misc/browsers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default async function () {
await replaceInFile(
'e2e/src/app.e2e-spec.ts',
'await browser.manage().logs().get(logging.Type.BROWSER)',
'[]',
'[] as any',
);

// Workaround defect in getText WebDriver implementation for Safari/Edge
Expand Down