Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,14 @@ export class Environment {
case 'ImportNamespace': {
if (this.#isKnownReactModule(binding.module)) {
// only resolve imports to modules we know about
// For default imports from 'react', always resolve to the React global type
// regardless of the local binding name (e.g., import ReactAlias from 'react')
const globalType =
binding.kind === 'ImportDefault' && binding.module.toLowerCase() === 'react'
? this.#globals.get('React')
: this.#globals.get(binding.name);
return (
this.#globals.get(binding.name) ??
globalType ??
(isHookName(binding.name) ? this.#getCustomHookType() : null)
);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

## Input

```javascript
import ReactAlias from 'react'

function App3() {
const v = ReactAlias.use();
return <div>{v}</div>
}

```

## Code

```javascript
import { c as _c } from "react/compiler-runtime";
import ReactAlias from "react";

function App3() {
const $ = _c(2);
const v = ReactAlias.use();
let t0;
if ($[0] !== v) {
t0 = <div>{v}</div>;
$[0] = v;
$[1] = t0;
} else {
t0 = $[1];
}
return t0;
}

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import ReactAlias from 'react'

function App3() {
const v = ReactAlias.use();
return <div>{v}</div>
}