Skip to content

Commit b1f400e

Browse files
committed
chore: typescript 3.6 update
1 parent eee3da2 commit b1f400e

File tree

8 files changed

+34
-34
lines changed

8 files changed

+34
-34
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@
5555
"@types/elementtree": "^0.1.0",
5656
"@types/fs-extra": "^8.0.0",
5757
"@types/jest": "^24.0.12",
58-
"@types/node": "~8.9.5",
58+
"@types/node": "~8.10.56",
5959
"@types/sharp": "^0.23.0",
6060
"husky": "^3.0.0",
6161
"jest": "^23.6.0",
6262
"ts-jest": "^23.10.5",
6363
"tslint": "^5.12.1",
6464
"tslint-ionic-rules": "0.0.21",
65-
"typescript": "~3.5.2"
65+
"typescript": "~3.6.4"
6666
}
6767
}

src/cli.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function getDirectory(): string {
1111
return process.cwd();
1212
}
1313

14-
export async function resolveOptions(args: ReadonlyArray<string>, directory: string, config?: et.ElementTree): Promise<Options> {
14+
export async function resolveOptions(args: readonly string[], directory: string, config?: et.ElementTree): Promise<Options> {
1515
const doc = config ? config.getroot() : undefined;
1616
const platformList = filterSupportedPlatforms(doc ? getPlatforms(doc) : []);
1717
const parsedOptions = parseOptions(args);
@@ -23,7 +23,7 @@ export async function resolveOptions(args: ReadonlyArray<string>, directory: str
2323
};
2424
}
2525

26-
export function parseOptions(args: ReadonlyArray<string>): Options {
26+
export function parseOptions(args: readonly string[]): Options {
2727
const json = args.includes('--json');
2828
const resourcesDirectory = getOptionValue(args, '--resources', DEFAULT_RESOURCES_DIRECTORY);
2929
const platformArg = args[0] ? args[0] : undefined;
@@ -37,14 +37,14 @@ export function parseOptions(args: ReadonlyArray<string>): Options {
3737
};
3838
}
3939

40-
export function generatePlatformOptions(platforms: ReadonlyArray<Platform>, resourcesDirectory: string, args: ReadonlyArray<string>): PlatformOptions {
40+
export function generatePlatformOptions(platforms: readonly Platform[], resourcesDirectory: string, args: readonly string[]): PlatformOptions {
4141
return platforms.reduce((acc, platform) => {
4242
acc[platform] = generateRunOptions(platform, resourcesDirectory, args);
4343
return acc;
4444
}, {} as PlatformOptions);
4545
}
4646

47-
export function generateRunOptions(platform: Platform, resourcesDirectory: string, args: ReadonlyArray<string>): RunPlatformOptions {
47+
export function generateRunOptions(platform: Platform, resourcesDirectory: string, args: readonly string[]): RunPlatformOptions {
4848
const typeOption = getOptionValue(args, '--type');
4949
const types = validateResourceTypes(typeOption ? [typeOption] : RESOURCE_TYPES);
5050

@@ -55,7 +55,7 @@ export function generateRunOptions(platform: Platform, resourcesDirectory: strin
5555
};
5656
}
5757

58-
export function parseAdaptiveIconResourceOptions(platform: Platform, resourcesDirectory: string, args: ReadonlyArray<string>): AdaptiveIconResourceOptions | undefined {
58+
export function parseAdaptiveIconResourceOptions(platform: Platform, resourcesDirectory: string, args: readonly string[]): AdaptiveIconResourceOptions | undefined {
5959
if (platform !== Platform.ANDROID) {
6060
return;
6161
}
@@ -67,7 +67,7 @@ export function parseAdaptiveIconResourceOptions(platform: Platform, resourcesDi
6767
};
6868
}
6969

70-
export function parseAdaptiveIconForegroundOptions(resourcesDirectory: string, args: ReadonlyArray<string>): AdaptiveIconResourceOptions['foreground'] {
70+
export function parseAdaptiveIconForegroundOptions(resourcesDirectory: string, args: readonly string[]): AdaptiveIconResourceOptions['foreground'] {
7171
const source = parseAdaptiveIconSourceFromArgs(ResourceKey.FOREGROUND, args);
7272

7373
if (source && source.type !== SourceType.RASTER) {
@@ -81,7 +81,7 @@ export function parseAdaptiveIconForegroundOptions(resourcesDirectory: string, a
8181
};
8282
}
8383

84-
export function parseAdaptiveIconBackgroundOptions(resourcesDirectory: string, args: ReadonlyArray<string>): AdaptiveIconResourceOptions['background'] {
84+
export function parseAdaptiveIconBackgroundOptions(resourcesDirectory: string, args: readonly string[]): AdaptiveIconResourceOptions['background'] {
8585
const source = parseAdaptiveIconSourceFromArgs(ResourceKey.BACKGROUND, args);
8686

8787
return {
@@ -91,12 +91,12 @@ export function parseAdaptiveIconBackgroundOptions(resourcesDirectory: string, a
9191
};
9292
}
9393

94-
export function parseSimpleResourceOptions(platform: Platform, type: ResourceType.ICON | ResourceType.SPLASH, resourcesDirectory: string, args: ReadonlyArray<string>): SimpleResourceOptions {
94+
export function parseSimpleResourceOptions(platform: Platform, type: ResourceType.ICON | ResourceType.SPLASH, resourcesDirectory: string, args: readonly string[]): SimpleResourceOptions {
9595
const source = parseSourceFromArgs(type, args);
9696
return { sources: source ? [source] : getDefaultSources(platform, type, resourcesDirectory) };
9797
}
9898

99-
export function parseAdaptiveIconSourceFromArgs(type: ResourceKey.FOREGROUND | ResourceKey.BACKGROUND, args: ReadonlyArray<string>): Source | undefined {
99+
export function parseAdaptiveIconSourceFromArgs(type: ResourceKey.FOREGROUND | ResourceKey.BACKGROUND, args: readonly string[]): Source | undefined {
100100
const sourceOption = getOptionValue(args, `--icon-${type}-source`);
101101

102102
if (!sourceOption) {
@@ -106,7 +106,7 @@ export function parseAdaptiveIconSourceFromArgs(type: ResourceKey.FOREGROUND | R
106106
return parseSource(sourceOption);
107107
}
108108

109-
export function parseSourceFromArgs(type: ResourceType.ICON | ResourceType.SPLASH, args: ReadonlyArray<string>): string | undefined {
109+
export function parseSourceFromArgs(type: ResourceType.ICON | ResourceType.SPLASH, args: readonly string[]): string | undefined {
110110
const sourceOption = getOptionValue(args, `--${type}-source`);
111111

112112
if (sourceOption) {

src/config.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function getConfigPath(directory: string): string {
1313
return pathlib.resolve(directory, 'config.xml');
1414
}
1515

16-
export async function run(configPath: string, resourcesDirectory: string, doc: et.ElementTree, sources: ReadonlyArray<ResolvedSource>, resources: ReadonlyArray<GeneratedResource>, errstream?: NodeJS.WritableStream): Promise<void> {
16+
export async function run(configPath: string, resourcesDirectory: string, doc: et.ElementTree, sources: readonly ResolvedSource[], resources: readonly GeneratedResource[], errstream?: NodeJS.WritableStream): Promise<void> {
1717
const colors = sources.filter((source): source is ResolvedColorSource => source.type === SourceType.COLOR);
1818

1919
const androidPlatformElement = resolvePlatformElement(doc.getroot(), Platform.ANDROID);
@@ -50,7 +50,7 @@ export async function resolveColorsDocument(colorsPath: string): Promise<et.Elem
5050
}
5151
}
5252

53-
export async function runColorsConfig(colorsPath: string, colors: ReadonlyArray<ResolvedColorSource>): Promise<void> {
53+
export async function runColorsConfig(colorsPath: string, colors: readonly ResolvedColorSource[]): Promise<void> {
5454
await ensureDir(pathlib.dirname(colorsPath));
5555
const colorsDocument = await resolveColorsDocument(colorsPath);
5656
const root = colorsDocument.getroot();
@@ -70,7 +70,7 @@ export async function runColorsConfig(colorsPath: string, colors: ReadonlyArray<
7070
await write(colorsPath, colorsDocument);
7171
}
7272

73-
export function runConfig(configPath: string, doc: et.ElementTree, resources: ReadonlyArray<GeneratedResource>, errstream?: NodeJS.WritableStream): void {
73+
export function runConfig(configPath: string, doc: et.ElementTree, resources: readonly GeneratedResource[], errstream?: NodeJS.WritableStream): void {
7474
const root = doc.getroot();
7575
const orientationPreference = getPreference(root, 'Orientation');
7676
debug('Orientation preference: %O', orientationPreference);
@@ -151,7 +151,7 @@ export function resolveResourceElement(container: et.Element, nodeName: string,
151151
return et.SubElement(container, nodeName);
152152
}
153153

154-
export function groupImages(images: ReadonlyArray<GeneratedResource>): Map<Platform, GeneratedResource[]> {
154+
export function groupImages(images: readonly GeneratedResource[]): Map<Platform, GeneratedResource[]> {
155155
const platforms = new Map<Platform, GeneratedResource[]>();
156156

157157
for (const image of images) {

src/error.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface BadImageFormatValidationErrorDetails {
1010
type: ResourceType;
1111
code: ValidationErrorCode.BAD_IMAGE_FORMAT;
1212
format: string | undefined;
13-
requiredFormats: ReadonlyArray<string>;
13+
requiredFormats: readonly string[];
1414
}
1515

1616
export interface BadImageSizeValidationErrorDetails {
@@ -72,7 +72,7 @@ export class ResolveSourceImageError extends BaseError {
7272
readonly name = 'ResolveSourceImageError';
7373
readonly code = 'BAD_SOURCES';
7474

75-
constructor(readonly message: string, readonly errors: ReadonlyArray<ValidationError>) {
75+
constructor(readonly message: string, readonly errors: readonly ValidationError[]) {
7676
super(message);
7777
}
7878

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ namespace CordovaRes {
158158
readonly platforms?: Readonly<PlatformOptions>;
159159
}
160160

161-
export async function runCommandLine(args: ReadonlyArray<string>): Promise<void> {
161+
export async function runCommandLine(args: readonly string[]): Promise<void> {
162162
if (args.includes('--version')) {
163163
const pkg = await import(path.resolve(__dirname, '../package.json'));
164164
process.stdout.write(pkg.version + '\n');

src/platform.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ export const enum Platform {
1414
WINDOWS = 'windows',
1515
}
1616

17-
export const PLATFORMS: ReadonlyArray<Platform> = [Platform.ANDROID, Platform.IOS, Platform.WINDOWS];
17+
export const PLATFORMS: readonly Platform[] = [Platform.ANDROID, Platform.IOS, Platform.WINDOWS];
1818

1919
export interface GeneratedResource extends ResourceKeyValues {
2020
type: ResourceType;
2121
platform: Platform;
2222
nodeName: string;
23-
nodeAttributes: ReadonlyArray<ResourceNodeAttribute>;
23+
nodeAttributes: readonly ResourceNodeAttribute[];
2424
indexAttribute: ResourceNodeAttribute;
2525
}
2626

@@ -211,7 +211,7 @@ export async function generateAdaptiveIconResources(resourcesDirectory: string,
211211
};
212212
}
213213

214-
export async function consolidateAdaptiveIconResources(foregrounds: ReadonlyArray<GeneratedResource>, backgrounds: ReadonlyArray<GeneratedResource>): Promise<GeneratedResource[]> {
214+
export async function consolidateAdaptiveIconResources(foregrounds: readonly GeneratedResource[], backgrounds: readonly GeneratedResource[]): Promise<GeneratedResource[]> {
215215
return foregrounds.map(foreground => {
216216
const background = backgrounds.find(r => r[r.indexAttribute.key] === foreground[foreground.indexAttribute.key]);
217217

@@ -292,7 +292,7 @@ export function imageSourceToPath(source: string | ImageSource): string {
292292
return typeof source === 'string' ? source : source.src;
293293
}
294294

295-
export async function resolveSource(platform: Platform, type: ResourceType, name: string, sources: ReadonlyArray<string | ImageSource | ColorSource>, errstream?: NodeJS.WritableStream): Promise<ResolvedSource> {
295+
export async function resolveSource(platform: Platform, type: ResourceType, name: string, sources: readonly (string | ImageSource | ColorSource)[], errstream?: NodeJS.WritableStream): Promise<ResolvedSource> {
296296
for (const source of sources) {
297297
if (typeof source === 'string' || source.type === SourceType.RASTER) {
298298
const src = imageSourceToPath(source);
@@ -316,7 +316,7 @@ export async function resolveSource(platform: Platform, type: ResourceType, name
316316
throw new BadInputError(`Missing source for "${type}" (sources: ${sources.join(', ')})`);
317317
}
318318

319-
export function validatePlatforms(platforms: ReadonlyArray<string>): Platform[] {
319+
export function validatePlatforms(platforms: readonly string[]): Platform[] {
320320
const result: Platform[] = [];
321321

322322
for (const platform of platforms) {
@@ -330,7 +330,7 @@ export function validatePlatforms(platforms: ReadonlyArray<string>): Platform[]
330330
return result;
331331
}
332332

333-
export function filterSupportedPlatforms(platforms: ReadonlyArray<string>): Platform[] {
333+
export function filterSupportedPlatforms(platforms: readonly string[]): Platform[] {
334334
return platforms.filter(isSupportedPlatform);
335335
}
336336

src/resources.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const enum ResourceType {
1111
SPLASH = 'splash',
1212
}
1313

14-
export const RESOURCE_TYPES: ReadonlyArray<ResourceType> = [
14+
export const RESOURCE_TYPES: readonly ResourceType[] = [
1515
ResourceType.ADAPTIVE_ICON,
1616
ResourceType.ICON,
1717
ResourceType.SPLASH,
@@ -81,8 +81,8 @@ export interface ResolvedColorSource extends ColorSource {
8181

8282
export type ResolvedSource = ResolvedImageSource | ResolvedColorSource;
8383

84-
export const RESOURCE_FORMATS: ReadonlyArray<Format> = [Format.JPEG, Format.PNG];
85-
export const RESOURCE_RASTER_FORMATS: ReadonlyArray<Format> = [Format.JPEG, Format.PNG];
84+
export const RESOURCE_FORMATS: readonly Format[] = [Format.JPEG, Format.PNG];
85+
export const RESOURCE_RASTER_FORMATS: readonly Format[] = [Format.JPEG, Format.PNG];
8686

8787
export type ResourceValidator = (source: string, pipeline: Sharp) => Promise<Metadata>;
8888

@@ -218,9 +218,9 @@ export interface ResourceNodeAttribute {
218218
}
219219

220220
export interface ResourcesTypeConfig<C = ResourcesImageConfig> {
221-
readonly resources: ReadonlyArray<C>;
221+
readonly resources: readonly C[];
222222
readonly nodeName: string;
223-
readonly nodeAttributes: ReadonlyArray<ResourceNodeAttribute>;
223+
readonly nodeAttributes: readonly ResourceNodeAttribute[];
224224

225225
/**
226226
* Uniquely identifies a node.
@@ -233,7 +233,7 @@ export interface ResourcesTypeConfig<C = ResourcesImageConfig> {
233233
export type ResourcesPlatform = { readonly [T in ResourceType.ICON | ResourceType.SPLASH]: ResourcesTypeConfig; };
234234
export type ResourcesConfig = { readonly [P in Platform]: ResourcesPlatform; };
235235

236-
export function validateResourceTypes(types: ReadonlyArray<string>): ResourceType[] {
236+
export function validateResourceTypes(types: readonly string[]): ResourceType[] {
237237
const result: ResourceType[] = [];
238238

239239
for (const type of types) {

src/utils/cli.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export function getOptionValue(args: ReadonlyArray<string>, arg: string): string | undefined;
2-
export function getOptionValue(args: ReadonlyArray<string>, arg: string, defaultValue: string): string;
3-
export function getOptionValue(args: ReadonlyArray<string>, arg: string, defaultValue?: string): string | undefined {
1+
export function getOptionValue(args: readonly string[], arg: string): string | undefined;
2+
export function getOptionValue(args: readonly string[], arg: string, defaultValue: string): string;
3+
export function getOptionValue(args: readonly string[], arg: string, defaultValue?: string): string | undefined {
44
const i = args.indexOf(arg);
55

66
if (i >= 0) {

0 commit comments

Comments
 (0)