diff --git a/packages/typescript/src/options/validate.ts b/packages/typescript/src/options/validate.ts index dce893d47..663e50ce3 100644 --- a/packages/typescript/src/options/validate.ts +++ b/packages/typescript/src/options/validate.ts @@ -44,11 +44,11 @@ export function validatePaths( ) { if (compilerOptions.out) { context.error( - `@rollup/plugin-typescript: Deprecated 'out' option is not supported. Use 'outDir' instead.` + `@rollup/plugin-typescript: Deprecated Typescript compiler option 'out' is not supported. Use 'outDir' instead.` ); } else if (compilerOptions.outFile) { context.error( - `@rollup/plugin-typescript: 'outFile' option is not supported. Use 'outDir' instead.` + `@rollup/plugin-typescript: Typescript compiler option 'outFile' is not supported. Use 'outDir' instead.` ); } @@ -56,14 +56,16 @@ export function validatePaths( if (compilerOptions[dirProperty]) { if (!outputOptions.dir) { context.error( - `@rollup/plugin-typescript: 'dir' must be used when '${dirProperty}' is specified.` + `@rollup/plugin-typescript: Rollup 'dir' option must be used when Typescript compiler option '${dirProperty}' is specified.` ); } // Checks if the given path lies within Rollup output dir const fromRollupDirToTs = relative(outputOptions.dir, compilerOptions[dirProperty]!); if (fromRollupDirToTs.startsWith('..')) { - context.error(`@rollup/plugin-typescript: '${dirProperty}' must be located inside 'dir'.`); + context.error( + `@rollup/plugin-typescript: Path of Typescript compiler option '${dirProperty}' must be located inside Rollup 'dir' option.` + ); } } } @@ -72,21 +74,24 @@ export function validatePaths( if (tsBuildInfoPath && compilerOptions.incremental) { if (!outputOptions.dir) { context.error( - `@rollup/plugin-typescript: 'dir' must be used when 'tsBuildInfoFile' or 'incremental' are specified.` + `@rollup/plugin-typescript: Rollup 'dir' option must be used when Typescript compiler options 'tsBuildInfoFile' or 'incremental' are specified.` ); } // Checks if the given path lies within Rollup output dir const fromRollupDirToTs = relative(outputOptions.dir, tsBuildInfoPath); if (fromRollupDirToTs.startsWith('..')) { - context.error(`@rollup/plugin-typescript: 'tsBuildInfoFile' must be located inside 'dir'.`); + context.error( + `@rollup/plugin-typescript: Path of Typescript compiler option 'tsBuildInfoFile' must be located inside Rollup 'dir' option.` + ); } } if (compilerOptions.declaration || compilerOptions.declarationMap || compilerOptions.composite) { if (DIRECTORY_PROPS.every((dirProperty) => !compilerOptions[dirProperty])) { context.error( - `@rollup/plugin-typescript: 'outDir' or 'declarationDir' must be specified to generate declaration files.` + `@rollup/plugin-typescript: You are using one of Typescript's compiler options 'declaration', 'declarationMap' or 'composite'. ` + + `In this case 'outDir' or 'declarationDir' must be specified to generate declaration files.` ); } } diff --git a/packages/typescript/test/test.js b/packages/typescript/test/test.js index 067bca11b..928d454e7 100644 --- a/packages/typescript/test/test.js +++ b/packages/typescript/test/test.js @@ -209,7 +209,9 @@ test.serial('ensures outDir is located in Rollup output dir', async (t) => { getCode(bundle, { format: 'esm', file: 'fixtures/basic/other/out.js' }, true) ); t.true( - noDirError.message.includes(`'dir' must be used when 'outDir' is specified`), + noDirError.message.includes( + `Rollup 'dir' option must be used when Typescript compiler option 'outDir' is specified` + ), `Unexpected error message: ${noDirError.message}` ); @@ -217,7 +219,9 @@ test.serial('ensures outDir is located in Rollup output dir', async (t) => { getCode(bundle, { format: 'esm', dir: 'fixtures/basic/dist' }, true) ); t.true( - wrongDirError.message.includes(`'outDir' must be located inside 'dir'`), + wrongDirError.message.includes( + `Path of Typescript compiler option 'outDir' must be located inside Rollup 'dir' option` + ), `Unexpected error message: ${wrongDirError.message}` ); }); @@ -239,7 +243,9 @@ test.serial('ensures declarationDir is located in Rollup output dir', async (t) getCode(bundle, { format: 'esm', file: 'fixtures/basic/other/out.js' }, true) ); t.true( - noDirError.message.includes(`'dir' must be used when 'declarationDir' is specified`), + noDirError.message.includes( + `Rollup 'dir' option must be used when Typescript compiler option 'declarationDir' is specified` + ), `Unexpected error message: ${noDirError.message}` ); @@ -247,7 +253,9 @@ test.serial('ensures declarationDir is located in Rollup output dir', async (t) getCode(bundle, { format: 'esm', dir: 'fixtures/basic/dist' }, true) ); t.true( - wrongDirError.message.includes(`'declarationDir' must be located inside 'dir'`), + wrongDirError.message.includes( + `Path of Typescript compiler option 'declarationDir' must be located inside Rollup 'dir' option` + ), `Unexpected error message: ${wrongDirError.message}` ); });