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

Output compilerOption Diagnostics #191

Closed
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
4 changes: 3 additions & 1 deletion packages/typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ export default function typescript(options: RollupTypescriptOptions = {}): Plugi
// Emit failed, print all diagnostics for this file
const allDiagnostics = ([] as import('typescript').Diagnostic[])
.concat(services.getSyntacticDiagnostics(id))
.concat(services.getSemanticDiagnostics(id));
.concat(services.getSemanticDiagnostics(id))
.concat(services.getCompilerOptionsDiagnostics());

emitDiagnostics(ts, this, host, allDiagnostics);

throw new Error(`Couldn't compile ${id}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default () => 10;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"composite": true,
"declaration": false,
},
"include": ["./"]
}
19 changes: 19 additions & 0 deletions packages/typescript/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,25 @@ test('complies code that uses browser functions', async (t) => {
t.true(code.includes('navigator.clipboard.readText()'), code);
});

test('reports compiler options errors', async (t) => {
process.chdir('fixtures/invalid-compiler-options');
const err = await t.throwsAsync(() =>
rollup({
input: 'main.ts',
plugins: [
typescript({
tsconfig: 'tsconfig.json'
})
]
})
);

t.true(
err.message.includes('Composite projects may not disable declaration emit'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we override this flag too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add composite to our list of overridden compiler options if it causes an error.

Copy link
Author

@samcooke98 samcooke98 Feb 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree - I think this is best done in a separate PR however(although if you want it done in this one too, I'm happy to do it)

It seems ideal to output compilerOptions errors, regardless of the overridden compiler options - Future typescript versions may introduce new compilerOption errors.

(And thinking about it, when I do this in a separate PR, it'll break this test)

`Unexpected error message: ${err.message}`
);
});

test('allows specifying a path for tsconfig.json', async (t) => {
const bundle = await rollup({
input: 'fixtures/tsconfig-jsx/main.tsx',
Expand Down