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

languages: drop ts-nocheck #27803

Merged
merged 1 commit into from
Nov 4, 2024
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
2 changes: 1 addition & 1 deletion generators/angular/support/update-languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type BaseGenerator from '../../base/index.js';
import type BaseGenerator from '../../base-core/index.js';
import { type UpdateClientLanguagesTaskParam, updateLanguagesInDayjsConfigurationTask } from '../../client/support/index.js';
import { generateLanguagesWebappOptions } from '../../languages/support/index.js';

Expand Down
1 change: 1 addition & 0 deletions generators/base-application/support/prepare-entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function _derivedProperties(entityWithConfig) {
paginationInfiniteScroll: pagination === INFINITE_SCROLL,
paginationNo: pagination === NO_PAGINATION,
dtoMapstruct: dto === MAPSTRUCT,
dtoAny: dto && dto !== NO_DTO,
serviceImpl: service === SERVICE_IMPL,
serviceNo: service === NO_SERVICE,
});
Expand Down
3 changes: 3 additions & 0 deletions generators/bootstrap-application/generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ describe(`generator - ${generator}`, () => {
"databaseType": "sql",
"differentRelationships": {},
"dto": true,
"dtoAny": true,
"dtoClass": "UserDTO",
"dtoInstance": "userDTO",
"dtoMapstruct": false,
Expand Down Expand Up @@ -1111,6 +1112,7 @@ describe(`generator - ${generator}`, () => {
"databaseType": "sql",
"differentRelationships": {},
"dto": "no",
"dtoAny": false,
"dtoMapstruct": false,
"dtoReferences": Any<Array>,
"dtoSuffix": "DTO",
Expand Down Expand Up @@ -1455,6 +1457,7 @@ describe(`generator - ${generator}`, () => {
"databaseType": "sql",
"differentRelationships": {},
"dto": "no",
"dtoAny": false,
"dtoMapstruct": false,
"dtoReferences": Any<Array>,
"dtoSuffix": "DTO",
Expand Down
9 changes: 7 additions & 2 deletions generators/client/support/update-languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@
* limitations under the License.
*/
import type { CommonClientServerApplication } from '../../base-application/types.js';
import type BaseGenerator from '../../base/index.js';
import type BaseGenerator from '../../base-core/index.js';

type UpdateLanguagesApplication = Pick<
CommonClientServerApplication<any>,
'clientBundlerWebpack' | 'clientSrcDir' | 'clientRootDir' | 'enableTranslation' | 'languagesDefinition' | 'languages'
>;

export type UpdateClientLanguagesTaskParam = {
application: CommonClientServerApplication<any> & { enableTranslation: true };
application: UpdateLanguagesApplication;
control?: any;
};

Expand Down
30 changes: 14 additions & 16 deletions generators/languages/generator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-nocheck
/**
* Copyright 2013-2024 the original author or authors from the JHipster project.
*
Expand Down Expand Up @@ -37,24 +36,22 @@ import { clientI18nFiles } from './files.js';
import { askForLanguages, askI18n } from './prompts.js';

const { NO: NO_CLIENT_FRAMEWORK, ANGULAR } = clientFrameworkTypes;

/**
* This is the base class for a generator that generates entities.
*
* @class
* @extends {BaseApplicationGenerator}
*/
export default class LanguagesGenerator extends BaseApplicationGenerator {
askForMoreLanguages!: boolean;
askForNativeLanguage!: boolean;
translationData: TranslationData;
translationData!: TranslationData;
supportedLanguages;
languages;
/**
* Languages to be generated.
* Can be incremental or every language.
*/
languagesToApply;
composedBlueprints: string[] = [];
composedBlueprints: any[] = [];
languageCommand;
writeJavaLanguageFiles;
regenerateLanguages;
Expand Down Expand Up @@ -165,7 +162,7 @@ export default class LanguagesGenerator extends BaseApplicationGenerator {
const { nativeLanguage, enableTranslation } = this.jhipsterConfigWithDefaults;
const isLanguageConfigured = Boolean(this.jhipsterConfig.nativeLanguage);
// Prompts detects current language. Save default native language for next execution.
this.config.defaults({ nativeLanguage });
this.config.defaults({ nativeLanguage: nativeLanguage! });
if (!enableTranslation) {
return;
}
Expand All @@ -174,13 +171,13 @@ export default class LanguagesGenerator extends BaseApplicationGenerator {
// If languages is not configured, apply defaults.
this.languagesToApply = this.jhipsterConfigWithDefaults.languages;
}
if (this.jhipsterConfig.languages.length === 0 || this.jhipsterConfig.languages[0] !== this.jhipsterConfig.nativeLanguage) {
if (this.jhipsterConfig.languages!.length === 0 || this.jhipsterConfig.languages![0] !== this.jhipsterConfig.nativeLanguage) {
// Set native language as first language.
this.jhipsterConfig.languages = [...new Set([nativeLanguage, ...this.jhipsterConfig.languages])];
this.jhipsterConfig.languages = [...new Set([nativeLanguage, ...this.jhipsterConfig.languages!])];
}
if (this.languagesToApply && this.languagesToApply.length > 0) {
// Save new languages.
this.jhipsterConfig.languages = [...new Set([...this.jhipsterConfig.languages, ...this.languagesToApply])];
this.jhipsterConfig.languages = [...new Set([...this.jhipsterConfig.languages!, ...this.languagesToApply])];
}
},
});
Expand Down Expand Up @@ -324,10 +321,11 @@ export default class LanguagesGenerator extends BaseApplicationGenerator {

get postWriting() {
return this.asPostWritingTaskGroup({
write({ application, control }) {
write({ application, control, source }) {
if (this.options.skipPriorities?.includes?.(PRIORITY_NAMES.POST_WRITING)) return;

if (application.enableTranslation && !application.skipClient) {
const { enableTranslation, skipClient } = application;
if (enableTranslation && !skipClient) {
if (application.clientFrameworkAngular) {
updateLanguagesInAngularTask.call(this, { application, control });
}
Expand All @@ -345,7 +343,7 @@ export default class LanguagesGenerator extends BaseApplicationGenerator {
application.backendTypeJavaAny &&
application.backendTypeSpringBoot
) {
updateLanguagesInJava.call(this, { application, control });
updateLanguagesInJava.call(this, { application, control, source });
}
},
});
Expand Down Expand Up @@ -377,13 +375,13 @@ export default class LanguagesGenerator extends BaseApplicationGenerator {
return this.delegateTasksToBlueprint(() => this.postWritingEntities);
}

migrateLanguages(languagesToMigrate) {
migrateLanguages(languagesToMigrate: Record<string, string>) {
const { languages, nativeLanguage } = this.jhipsterConfig;
if (languagesToMigrate[nativeLanguage!]) {
this.jhipsterConfig.nativeLanguage = languagesToMigrate[nativeLanguage!];
}
if (languages?.some(lang => languagesToMigrate[lang])) {
this.jhipsterConfig.languages = languages.map(lang => languagesToMigrate[lang] ?? lang);
if (languages?.some(lang => languagesToMigrate[lang as string])) {
this.jhipsterConfig.languages = languages.map(lang => languagesToMigrate[lang as string] ?? lang);
}
}

Expand Down
2 changes: 1 addition & 1 deletion generators/react/support/update-languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type BaseGenerator from '../../base/index.js';
import type BaseGenerator from '../../base-core/index.js';
import { type UpdateClientLanguagesTaskParam, updateLanguagesInDayjsConfigurationTask } from '../../client/support/index.js';
import { generateLanguagesWebappOptions } from '../../languages/support/index.js';

Expand Down
14 changes: 10 additions & 4 deletions generators/server/support/update-languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
*/

import { asPostWritingTask } from '../../base-application/support/task-type-inference.js';
import type { Language } from '../../languages/support/languages.js';

/**
* Update Languages In MailServiceIT
*
* @param application
*/
export const updateLanguagesInMailServiceITTask = asPostWritingTask(function updateLanguagesInMailServiceITTask({ application, control }) {
export const updateLanguagesInMailServiceITTask = asPostWritingTask<
any,
{ javaPackageTestDir?: string; languagesDefinition?: readonly Language[] }
>(function updateLanguagesInMailServiceITTask({ application, control }) {
const { javaPackageTestDir, languagesDefinition } = application;
const { ignoreNeedlesError: ignoreNonExisting } = control;
let newContent = 'private static final String[] languages = {\n';
Expand All @@ -38,6 +42,8 @@ export const updateLanguagesInMailServiceITTask = asPostWritingTask(function upd
);
});

export default asPostWritingTask(function updateLanguagesTask(this, taskParam) {
updateLanguagesInMailServiceITTask.call(this, taskParam);
});
export default asPostWritingTask<any, { javaPackageTestDir?: string; languagesDefinition?: readonly Language[] }>(
function updateLanguagesTask(this, taskParam) {
updateLanguagesInMailServiceITTask.call(this, taskParam);
},
);
2 changes: 1 addition & 1 deletion generators/vue/support/update-languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import type BaseGenerator from '../../base/index.js';
import type BaseGenerator from '../../base-core/index.js';
import { type UpdateClientLanguagesTaskParam, updateLanguagesInDayjsConfigurationTask } from '../../client/support/update-languages.js';
import { generateLanguagesWebappOptions } from '../../languages/support/index.js';

Expand Down
Loading