feat(react): update complier options for strict mode (#8127)
This commit is contained in:
parent
acffd2e689
commit
e4f7e2e40b
@ -19,7 +19,7 @@ describe('app', () => {
|
|||||||
name: 'myApp',
|
name: 'myApp',
|
||||||
linter: Linter.EsLint,
|
linter: Linter.EsLint,
|
||||||
style: 'css',
|
style: 'css',
|
||||||
strict: false,
|
strict: true,
|
||||||
standaloneConfig: false,
|
standaloneConfig: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -76,14 +76,16 @@ describe('app', () => {
|
|||||||
path: './tsconfig.spec.json',
|
path: './tsconfig.spec.json',
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
expect(tsconfig.compilerOptions.strict).not.toBeDefined();
|
expect(tsconfig.compilerOptions.forceConsistentCasingInFileNames).toEqual(
|
||||||
|
true
|
||||||
|
);
|
||||||
|
expect(tsconfig.compilerOptions.strict).toEqual(true);
|
||||||
|
expect(tsconfig.compilerOptions.noImplicitOverride).toEqual(true);
|
||||||
expect(
|
expect(
|
||||||
tsconfig.compilerOptions.forceConsistentCasingInFileNames
|
tsconfig.compilerOptions.noPropertyAccessFromIndexSignature
|
||||||
).not.toBeDefined();
|
).toEqual(true);
|
||||||
expect(tsconfig.compilerOptions.noImplicitReturns).not.toBeDefined();
|
expect(tsconfig.compilerOptions.noImplicitReturns).toEqual(true);
|
||||||
expect(
|
expect(tsconfig.compilerOptions.noFallthroughCasesInSwitch).toEqual(true);
|
||||||
tsconfig.compilerOptions.noFallthroughCasesInSwitch
|
|
||||||
).not.toBeDefined();
|
|
||||||
|
|
||||||
const tsconfigApp = readJson(appTree, 'apps/my-app/tsconfig.app.json');
|
const tsconfigApp = readJson(appTree, 'apps/my-app/tsconfig.app.json');
|
||||||
expect(tsconfigApp.compilerOptions.outDir).toEqual('../../dist/out-tsc');
|
expect(tsconfigApp.compilerOptions.outDir).toEqual('../../dist/out-tsc');
|
||||||
@ -718,22 +720,26 @@ Object {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('--strict', () => {
|
describe('--no-strict', () => {
|
||||||
it('should update tsconfig.json', async () => {
|
it('should not add options for strict mode', async () => {
|
||||||
await applicationGenerator(appTree, {
|
await applicationGenerator(appTree, {
|
||||||
...schema,
|
...schema,
|
||||||
strict: true,
|
strict: false,
|
||||||
});
|
});
|
||||||
const tsconfigJson = readJson(appTree, '/apps/my-app/tsconfig.json');
|
const tsconfigJson = readJson(appTree, '/apps/my-app/tsconfig.json');
|
||||||
|
|
||||||
expect(tsconfigJson.compilerOptions.strict).toBeTruthy();
|
|
||||||
expect(
|
expect(
|
||||||
tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
|
tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
|
||||||
).toBeTruthy();
|
).not.toBeDefined();
|
||||||
expect(tsconfigJson.compilerOptions.noImplicitReturns).toBeTruthy();
|
expect(tsconfigJson.compilerOptions.strict).not.toBeDefined();
|
||||||
|
expect(tsconfigJson.compilerOptions.noImplicitOverride).not.toBeDefined();
|
||||||
|
expect(
|
||||||
|
tsconfigJson.compilerOptions.noPropertyAccessFromIndexSignature
|
||||||
|
).not.toBeDefined();
|
||||||
|
expect(tsconfigJson.compilerOptions.noImplicitReturns).not.toBeDefined();
|
||||||
expect(
|
expect(
|
||||||
tsconfigJson.compilerOptions.noFallthroughCasesInSwitch
|
tsconfigJson.compilerOptions.noFallthroughCasesInSwitch
|
||||||
).toBeTruthy();
|
).not.toBeDefined();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -20,6 +20,8 @@ function updateTsConfig(host: Tree, options: NormalizedSchema) {
|
|||||||
...json.compilerOptions,
|
...json.compilerOptions,
|
||||||
forceConsistentCasingInFileNames: true,
|
forceConsistentCasingInFileNames: true,
|
||||||
strict: true,
|
strict: true,
|
||||||
|
noImplicitOverride: true,
|
||||||
|
noPropertyAccessFromIndexSignature: true,
|
||||||
noImplicitReturns: true,
|
noImplicitReturns: true,
|
||||||
noFallthroughCasesInSwitch: true,
|
noFallthroughCasesInSwitch: true,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -104,6 +104,10 @@ describe('lib', () => {
|
|||||||
tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
|
tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
|
||||||
).toEqual(true);
|
).toEqual(true);
|
||||||
expect(tsconfigJson.compilerOptions.strict).toEqual(true);
|
expect(tsconfigJson.compilerOptions.strict).toEqual(true);
|
||||||
|
expect(tsconfigJson.compilerOptions.noImplicitOverride).toEqual(true);
|
||||||
|
expect(
|
||||||
|
tsconfigJson.compilerOptions.noPropertyAccessFromIndexSignature
|
||||||
|
).toEqual(true);
|
||||||
expect(tsconfigJson.compilerOptions.noImplicitReturns).toEqual(true);
|
expect(tsconfigJson.compilerOptions.noImplicitReturns).toEqual(true);
|
||||||
expect(tsconfigJson.compilerOptions.noFallthroughCasesInSwitch).toEqual(
|
expect(tsconfigJson.compilerOptions.noFallthroughCasesInSwitch).toEqual(
|
||||||
true
|
true
|
||||||
@ -630,6 +634,10 @@ describe('lib', () => {
|
|||||||
tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
|
tsconfigJson.compilerOptions.forceConsistentCasingInFileNames
|
||||||
).not.toBeDefined();
|
).not.toBeDefined();
|
||||||
expect(tsconfigJson.compilerOptions.strict).not.toBeDefined();
|
expect(tsconfigJson.compilerOptions.strict).not.toBeDefined();
|
||||||
|
expect(tsconfigJson.compilerOptions.noImplicitOverride).not.toBeDefined();
|
||||||
|
expect(
|
||||||
|
tsconfigJson.compilerOptions.noPropertyAccessFromIndexSignature
|
||||||
|
).not.toBeDefined();
|
||||||
expect(tsconfigJson.compilerOptions.noImplicitReturns).not.toBeDefined();
|
expect(tsconfigJson.compilerOptions.noImplicitReturns).not.toBeDefined();
|
||||||
expect(
|
expect(
|
||||||
tsconfigJson.compilerOptions.noFallthroughCasesInSwitch
|
tsconfigJson.compilerOptions.noFallthroughCasesInSwitch
|
||||||
|
|||||||
@ -226,6 +226,8 @@ function updateTsConfig(tree: Tree, options: NormalizedSchema) {
|
|||||||
...json.compilerOptions,
|
...json.compilerOptions,
|
||||||
forceConsistentCasingInFileNames: true,
|
forceConsistentCasingInFileNames: true,
|
||||||
strict: true,
|
strict: true,
|
||||||
|
noImplicitOverride: true,
|
||||||
|
noPropertyAccessFromIndexSignature: true,
|
||||||
noImplicitReturns: true,
|
noImplicitReturns: true,
|
||||||
noFallthroughCasesInSwitch: true,
|
noFallthroughCasesInSwitch: true,
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user