Skip to content

Side-effect imports are checked if file uses JSX: unintentional breaking change? #28538

Description

Commit 7a71887 (#27340) appears to have introduced an unintentional breaking change: side-effect module imports are now checked, but only if the file uses JSX. This is currently causing the DefinitelyTyped CI (which uses typescript@next) to fail on @types/react-table.

TypeScript Version:7a71887 (problem does not occur in 12e371b)

Search Terms: side effect module import jsx

Code

// code.tsximport*asReactfrom"react";import"nope";<div/>;// tsconfig.json{"compilerOptions": {"jsx": "react","strict": true}}// package.json{"devDependencies": {"@types/react": "^16.7.6"}}

Expected behavior: No compile error.

Actual behavior:error TS2307: Cannot find module 'nope'. But if the JSX element is removed from the file, the error goes away.

Playground Link: N/A, React dependency

Related Issues:#28032, etc. for the previous behavior

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions