Skip to content
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
9 changes: 9 additions & 0 deletions .changeset/plenty-rules-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@emotion/styled': major
---

What: Add autocomplete suggestion for styled. Fixes #3312

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`

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.
8 changes: 4 additions & 4 deletions packages/styled/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Theme } from '@emotion/react'
import styled from './base'
import baseStyled from './base'
import { ReactJSXIntrinsicElements } from './jsx-namespace'
import { tags } from './tags'
import {
Expand Down Expand Up @@ -33,10 +33,10 @@ export type StyledTags = {
export interface CreateStyled extends BaseCreateStyled, StyledTags {}

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

tags.forEach(tagName => {
;(newStyled as any)[tagName] = newStyled(tagName as keyof typeof newStyled)
;(styled as any)[tagName] = styled(tagName as keyof typeof styled)
})

export default newStyled
export default styled