Skip to content

Commit ee92c95

Browse files
alicewriteswrongsrwaskiewicz
authored andcommitted
chore(types): fix some strictNullChecks errors (#3932)
This just fixes a few strictNullChecks errors, selected just by running the TypeScript compiler with the option turned on and fixing a few errors that popped up.
1 parent 0e7a64d commit ee92c95

16 files changed

Lines changed: 68 additions & 58 deletions

File tree

src/cli/run.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,17 @@ export const runTask = async (
129129
sys?: d.CompilerSystem
130130
): Promise<void> => {
131131
const logger = config.logger ?? createLogger();
132+
const rootDir = config.rootDir ?? '/';
133+
const configSys = sys ?? config.sys ?? coreCompiler.createSystem({ logger });
132134
const strictConfig: ValidatedConfig = {
133135
...config,
134136
flags: createConfigFlags(config.flags ?? { task }),
135137
hydratedFlag: config.hydratedFlag ?? null,
136138
logger,
137139
outputTargets: config.outputTargets ?? [],
138-
rootDir: config.rootDir ?? '/',
139-
sys: sys ?? config.sys ?? coreCompiler.createSystem({ logger }),
140+
packageJsonFilePath: configSys.platformPath.join(rootDir, 'package.json'),
141+
rootDir,
142+
sys: configSys,
140143
testing: config.testing ?? {},
141144
};
142145

src/compiler/build/build-stats.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ export function generateBuildStats(
6464
}
6565
} catch (e: unknown) {
6666
const diagnostic: d.Diagnostic = {
67-
messageText: `Generate Build Stats Error: ` + e,
6867
level: `error`,
68+
lines: [],
69+
messageText: `Generate Build Stats Error: ` + e,
6970
type: `build`,
7071
};
7172
jsonData = {

src/compiler/build/test/build-stats.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ describe('generateBuildStats', () => {
5555
level: 'error',
5656
type: 'horrible',
5757
messageText: 'the worst error _possible_ has just occurred',
58+
lines: [],
5859
};
5960
buildCtx.buildResults.diagnostics = [diagnostic];
6061
const result = generateBuildStats(config, buildCtx);

src/compiler/config/test/load-config.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,15 @@ describe('load config', () => {
8282
expect<d.Diagnostic>(loadedConfig.diagnostics[0]).toEqual({
8383
absFilePath: '/tsconfig.json',
8484
code: '18003',
85+
columnNumber: undefined,
8586
header: 'TypeScript',
8687
language: 'typescript',
8788
level: 'warn',
89+
lineNumber: undefined,
8890
lines: [],
8991
messageText:
9092
"No inputs were found in config file '/tsconfig.json'. Specified 'include' paths were '[\"src\"]' and 'exclude' paths were '[]'.",
91-
relFilePath: null,
93+
relFilePath: undefined,
9294
type: 'typescript',
9395
});
9496
});

src/compiler/config/test/validate-service-worker.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ describe('validateServiceWorker', () => {
1212

1313
beforeEach(() => {
1414
config = {
15-
fsNamespace: 'app',
16-
rootDir: '/',
17-
hydratedFlag: null,
18-
sys: mockCompilerSystem(),
1915
devMode: false,
2016
flags: createConfigFlags(),
17+
fsNamespace: 'app',
18+
hydratedFlag: null,
2119
logger: mockLogger(),
2220
outputTargets: [],
21+
packageJsonFilePath: '/package.json',
22+
rootDir: '/',
23+
sys: mockCompilerSystem(),
2324
testing: {},
2425
};
2526
});

src/compiler/config/validate-config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { buildError, isBoolean, isNumber, isString, sortBy } from '@utils';
2+
import { join } from 'path';
23

34
import { ConfigBundle, Diagnostic, LoadConfigInit, UnvalidatedConfig, ValidatedConfig } from '../../declarations';
45
import { createLogger } from '../sys/logger/console-logger';
@@ -47,6 +48,7 @@ export const validateConfig = (
4748
const diagnostics: Diagnostic[] = [];
4849

4950
const logger = bootstrapConfig.logger || config.logger || createLogger();
51+
const rootDir = typeof config.rootDir === 'string' ? config.rootDir : '/';
5052

5153
const validatedConfig: ValidatedConfig = {
5254
...config,
@@ -55,7 +57,8 @@ export const validateConfig = (
5557
hydratedFlag: validateHydrated(config),
5658
logger,
5759
outputTargets: config.outputTargets ?? [],
58-
rootDir: typeof config.rootDir === 'string' ? config.rootDir : '/',
60+
packageJsonFilePath: join(rootDir, 'package.json'),
61+
rootDir,
5962
sys: config.sys ?? bootstrapConfig.sys ?? createSystem({ logger }),
6063
testing: config.testing ?? {},
6164
};

src/compiler/html/remove-unused-styles.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const removeUnusedStyleText = (
5050
type: 'css',
5151
header: 'CSS Stringify',
5252
messageText: e,
53+
lines: [],
5354
});
5455
}
5556
} catch (e: any) {
@@ -58,6 +59,7 @@ const removeUnusedStyleText = (
5859
type: 'css',
5960
header: 'CSS Parse',
6061
messageText: e,
62+
lines: [],
6163
});
6264
}
6365
};

src/compiler/optimize/autoprefixer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const autoprefixCss = async (cssText: string, opts: boolean | null | d.Au
3838
messageText: warning.text,
3939
level: 'warn',
4040
type: 'css',
41+
lines: [],
4142
});
4243
});
4344

@@ -48,6 +49,7 @@ export const autoprefixCss = async (cssText: string, opts: boolean | null | d.Au
4849
messageText: `CSS Error` + e,
4950
level: `error`,
5051
type: `css`,
52+
lines: [],
5153
};
5254

5355
if (typeof e.name === 'string') {

src/compiler/output-targets/dist-custom-elements/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export const bundleCustomElements = async (
135135
level: 'error',
136136
type: 'build',
137137
messageText: 'dist-custom-elements output target provided with no output target directory!',
138+
lines: [],
138139
});
139140
return;
140141
}

src/compiler/output-targets/test/output-targets-dist-custom-elements.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export * from '${USER_INDEX_ENTRY_ID}';
130130
expect(buildCtx.diagnostics).toEqual([
131131
{
132132
level: 'error',
133+
lines: [],
133134
type: 'build',
134135
messageText: 'dist-custom-elements output target provided with no output target directory!',
135136
},

0 commit comments

Comments
 (0)