Skip to content

Commit 79c9371

Browse files
committed
fix: Fix targetLang param in rephraseText()
1 parent 48440e6 commit 79c9371

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
<!-- * add to here... -->
1010
### Changed
1111
* Update form-data lib due to https://github.com/advisories/GHSA-fjxv-7rqg-78g4
12+
* Fixed `targetLang` parameter in `DeepLClient::rephraseText` to be an optional `string` parameter.
1213

1314
## [1.19.0] - 2025-06-26
1415
### Added

src/deeplClient.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import { Translator, checkStatusCode } from './translator';
66
import {
7-
SourceLanguageCode,
87
DeepLClientOptions,
98
WriteResult,
109
MultilingualGlossaryDictionaryEntries,
@@ -61,7 +60,7 @@ export class DeepLClient extends Translator {
6160

6261
async rephraseText<T extends string | string[]>(
6362
texts: T,
64-
targetLang: SourceLanguageCode | null,
63+
targetLang?: string | null,
6564
writingStyle?: string | null,
6665
tone?: string | null,
6766
): Promise<T extends string ? WriteResult : WriteResult[]> {

tests/rephraseText.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ describe('rephrase text', () => {
1515
expect(result.targetLang).toBe('de');
1616
});
1717

18+
withRealServer('should rephrase a single text without a target language', async () => {
19+
const deeplClient = makeDeeplClient();
20+
const result = await deeplClient.rephraseText(exampleText.de);
21+
expect(result.text).toBe(exampleText.de);
22+
expect(result.detectedSourceLang).toBe('de');
23+
expect(result.targetLang).toBe('de');
24+
});
25+
1826
it('should throw an error for unsupported languages', async () => {
1927
const deeplClient = makeDeeplClient();
2028
const deeplClientPromise = deeplClient.rephraseText(exampleText.de, 'ja');

0 commit comments

Comments
 (0)