Skip to content

Commit 9cbb951

Browse files
committed
Fix: Change base styled import to baseStyled to use styled as default export
1 parent 228ef95 commit 9cbb951

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

.changeset/plenty-rules-heal.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@emotion/styled': major
3+
---
4+
5+
What: Add autocomplete suggestion for styled. Fixes #3312
6+
7+
Why: When typing "styled" while coding, there are no autocompletion suggestions for `styled`. It's expected behavior is to have a suggestion option and when selected, imports `styled` like this: `import styled from @emotion/styled`
8+
9+
How: The previous code imports the base styled as `styled`. This changes it to `baseStyled` so the module can use `styled` as the default export.

packages/styled/src/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Theme } from '@emotion/react'
2-
import styled from './base'
2+
import baseStyled from './base'
33
import { ReactJSXIntrinsicElements } from './jsx-namespace'
44
import { tags } from './tags'
55
import {
@@ -33,11 +33,10 @@ export type StyledTags = {
3333
export interface CreateStyled extends BaseCreateStyled, StyledTags {}
3434

3535
// bind it to avoid mutating the original function
36-
const newStyled = styled.bind(null) as CreateStyled
36+
const styled = baseStyled.bind(null) as CreateStyled
3737

3838
tags.forEach(tagName => {
39-
;(newStyled as any)[tagName] = newStyled(tagName as keyof typeof newStyled)
39+
;(styled as any)[tagName] = styled(tagName as keyof typeof styled)
4040
})
4141

42-
export { newStyled as styled }
43-
export default newStyled
42+
export default styled

0 commit comments

Comments
 (0)