Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: re-generate locales using the new script without type casting #729

Closed
wants to merge 2 commits into from
Closed
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
42 changes: 21 additions & 21 deletions scripts/generateLocales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,36 +130,36 @@ function generateLocalesIndexFile(
modules = removeIndexTs(modules);
modules = removeTsSuffix(modules);
const importType = type;

if (!containsAll(modules, expected)) {
type = `Partial<${type}>`;
}
let fieldType = '';
let asType = '';
if (!containsAll(expected, modules)) {
asType = ` as ${type}`;
} else if (type !== 'any') {
fieldType = `: ${type}`;
}
let content = `${autoGeneratedCommentHeader}\n`;

const content = [autoGeneratedCommentHeader];

if (type !== 'any') {
content += ` import type { ${importType.replace(
/\[.*/,
''
)} } from '..${'/..'.repeat(depth)}';\n`;
content.push(
`import type { ${importType.replace(/\[.*/, '')} } from '..${'/..'.repeat(
depth
)}';\n`
);
}
content += ` ${modules
.map((module) => `import ${escapeImport(module)} from './${module}';`)
.join('\n')}

const ${name}${fieldType} = {
content.push(
...modules.map((m) => `import ${escapeImport(m)} from './${m}';`)
);

content.push(`\nconst ${name}${type !== 'any' ? `: ${type}` : ''} = {
${extra}
${modules.map((module) => `${escapeField(module)},`).join('\n')}
}${asType};
};\n`);

export default ${name};
`;
content = format(content, prettierTsOptions);
writeFileSync(resolve(path, 'index.ts'), content);
content.push(`export default ${name};`);

writeFileSync(
resolve(path, 'index.ts'),
format(content.join('\n'), prettierTsOptions)
);
}

function generateRecursiveModuleIndexes(
Expand Down
4 changes: 2 additions & 2 deletions src/locales/af_ZA/address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type { AddressDefinitions } from '../../..';
import default_country from './default_country';
import postcode from './postcode';

const address = {
const address: Partial<AddressDefinitions> = {
default_country,
postcode,
} as Partial<AddressDefinitions>;
};

export default address;
4 changes: 2 additions & 2 deletions src/locales/ar/address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import street_address from './street_address';
import street_name from './street_name';
import street_prefix from './street_prefix';

const address = {
const address: Partial<AddressDefinitions> = {
building_number,
city,
city_name,
Expand All @@ -29,6 +29,6 @@ const address = {
street_address,
street_name,
street_prefix,
} as Partial<AddressDefinitions>;
};

export default address;
4 changes: 2 additions & 2 deletions src/locales/az/address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import street_name from './street_name';
import street_suffix from './street_suffix';
import street_title from './street_title';

const address = {
const address: Partial<AddressDefinitions> = {
building_number,
city,
city_name,
Expand All @@ -29,6 +29,6 @@ const address = {
street_name,
street_suffix,
street_title,
} as Partial<AddressDefinitions>;
};

export default address;
4 changes: 2 additions & 2 deletions src/locales/az/company/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import name_ from './name';
import prefix from './prefix';
import suffix from './suffix';

const company = {
const company: Partial<CompanyDefinitions> = {
name: name_,
prefix,
suffix,
} as Partial<CompanyDefinitions>;
};

export default company;
4 changes: 2 additions & 2 deletions src/locales/cz/address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import street from './street';
import street_address from './street_address';
import street_name from './street_name';

const address = {
const address: Partial<AddressDefinitions> = {
building_number,
city,
city_name,
Expand All @@ -29,6 +29,6 @@ const address = {
street,
street_address,
street_name,
} as Partial<AddressDefinitions>;
};

export default address;
4 changes: 2 additions & 2 deletions src/locales/cz/company/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import name_ from './name';
import noun from './noun';
import suffix from './suffix';

const company = {
const company: Partial<CompanyDefinitions> = {
adjective,
bs_noun,
bs_verb,
descriptor,
name: name_,
noun,
suffix,
} as Partial<CompanyDefinitions>;
};

export default company;
4 changes: 2 additions & 2 deletions src/locales/de/address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import street_address from './street_address';
import street_name from './street_name';
import street_root from './street_root';

const address = {
const address: Partial<AddressDefinitions> = {
building_number,
city,
city_prefix,
Expand All @@ -31,6 +31,6 @@ const address = {
street_address,
street_name,
street_root,
} as Partial<AddressDefinitions>;
};

export default address;
4 changes: 2 additions & 2 deletions src/locales/de/company/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import legal_form from './legal_form';
import name_ from './name';
import suffix from './suffix';

const company = {
const company: Partial<CompanyDefinitions> = {
legal_form,
name: name_,
suffix,
} as Partial<CompanyDefinitions>;
};

export default company;
4 changes: 2 additions & 2 deletions src/locales/de/name/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import name_ from './name';
import nobility_title_prefix from './nobility_title_prefix';
import prefix from './prefix';

const name = {
const name: Partial<NameDefinitions> = {
female_first_name,
first_name,
last_name,
male_first_name,
name: name_,
nobility_title_prefix,
prefix,
} as Partial<NameDefinitions>;
};

export default name;
4 changes: 2 additions & 2 deletions src/locales/de_AT/address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import street_address from './street_address';
import street_name from './street_name';
import street_root from './street_root';

const address = {
const address: Partial<AddressDefinitions> = {
building_number,
city,
city_name,
Expand All @@ -29,6 +29,6 @@ const address = {
street_address,
street_name,
street_root,
} as Partial<AddressDefinitions>;
};

export default address;
4 changes: 2 additions & 2 deletions src/locales/de_AT/company/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import legal_form from './legal_form';
import name_ from './name';
import suffix from './suffix';

const company = {
const company: Partial<CompanyDefinitions> = {
legal_form,
name: name_,
suffix,
} as Partial<CompanyDefinitions>;
};

export default company;
4 changes: 2 additions & 2 deletions src/locales/de_AT/name/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import name_ from './name';
import nobility_title_prefix from './nobility_title_prefix';
import prefix from './prefix';

const name = {
const name: Partial<NameDefinitions> = {
first_name,
last_name,
name: name_,
nobility_title_prefix,
prefix,
} as Partial<NameDefinitions>;
};

export default name;
4 changes: 2 additions & 2 deletions src/locales/de_CH/address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import postcode from './postcode';
import state from './state';
import state_abbr from './state_abbr';

const address = {
const address: Partial<AddressDefinitions> = {
city,
city_name,
country_code,
default_country,
postcode,
state,
state_abbr,
} as Partial<AddressDefinitions>;
};

export default address;
4 changes: 2 additions & 2 deletions src/locales/de_CH/company/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type { CompanyDefinitions } from '../../..';
import name_ from './name';
import suffix from './suffix';

const company = {
const company: Partial<CompanyDefinitions> = {
name: name_,
suffix,
} as Partial<CompanyDefinitions>;
};

export default company;
4 changes: 2 additions & 2 deletions src/locales/el/address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type { AddressDefinitions } from '../../..';
import county from './county';
import default_country from './default_country';

const address = {
const address: Partial<AddressDefinitions> = {
county,
default_country,
} as Partial<AddressDefinitions>;
};

export default address;
4 changes: 2 additions & 2 deletions src/locales/el/company/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import name_ from './name';
import noun from './noun';
import suffix from './suffix';

const company = {
const company: CompanyDefinitions = {
adjective,
bs_adjective,
bs_noun,
Expand All @@ -21,6 +21,6 @@ const company = {
name: name_,
noun,
suffix,
} as CompanyDefinitions;
};

export default company;
4 changes: 2 additions & 2 deletions src/locales/en/address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import street_name from './street_name';
import street_suffix from './street_suffix';
import time_zone from './time_zone';

const address = {
const address: Partial<AddressDefinitions> = {
building_number,
city,
city_name,
Expand All @@ -47,6 +47,6 @@ const address = {
street_name,
street_suffix,
time_zone,
} as Partial<AddressDefinitions>;
};

export default address;
4 changes: 2 additions & 2 deletions src/locales/en/company/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import name_ from './name';
import noun from './noun';
import suffix from './suffix';

const company = {
const company: CompanyDefinitions = {
adjective,
bs_adjective,
bs_noun,
Expand All @@ -21,6 +21,6 @@ const company = {
name: name_,
noun,
suffix,
} as CompanyDefinitions;
};

export default company;
4 changes: 2 additions & 2 deletions src/locales/en/internet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import domain_suffix from './domain_suffix';
import example_email from './example_email';
import free_email from './free_email';

const internet = {
const internet: InternetDefinitions = {
avatar_uri,
domain_suffix,
example_email,
free_email,
} as InternetDefinitions;
};

export default internet;
4 changes: 2 additions & 2 deletions src/locales/en/lorem/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type { LoremDefinitions } from '../../..';
import supplemental from './supplemental';
import words from './words';

const lorem = {
const lorem: LoremDefinitions = {
supplemental,
words,
} as LoremDefinitions;
};

export default lorem;
4 changes: 2 additions & 2 deletions src/locales/en_AU/address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import state from './state';
import state_abbr from './state_abbr';
import street_suffix from './street_suffix';

const address = {
const address: Partial<AddressDefinitions> = {
building_number,
default_country,
postcode,
state,
state_abbr,
street_suffix,
} as Partial<AddressDefinitions>;
};

export default address;
4 changes: 2 additions & 2 deletions src/locales/en_AU_ocker/address/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import street_name from './street_name';
import street_root from './street_root';
import street_suffix from './street_suffix';

const address = {
const address: Partial<AddressDefinitions> = {
building_number,
city,
city_prefix,
Expand All @@ -27,6 +27,6 @@ const address = {
street_name,
street_root,
street_suffix,
} as Partial<AddressDefinitions>;
};

export default address;
Loading