-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Convert @emotion/cache
's source code to TypeScript
#3277
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1dea229
Convert `@emotion/cache`'s source code to TypeScript
Andarist 819070f
remove extra comment types
Andarist 810f9b7
tweak pkg json
Andarist e253393
fixed pkg.json#imports
Andarist a6a1d3b
try with this
Andarist e438604
use .ts
Andarist c09c9b4
try this
Andarist babe748
try this
Andarist 34eb972
one more
Andarist bab0a81
try this
Andarist 85aa6c2
Merge remote-tracking branch 'origin/main' into migrate-cache-to-ts
Andarist 3e72e8c
update `@types/stylis`
Andarist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@emotion/cache': minor | ||
--- | ||
|
||
Source code has been migrated to TypeScript. From now on type declarations will be emitted based on that, instead of being hand-written. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
import { | ||
charat, | ||
combine, | ||
copy, | ||
copy as _copy, | ||
DECLARATION, | ||
hash, | ||
indexof, | ||
|
@@ -15,12 +15,17 @@ import { | |
RULESET, | ||
serialize, | ||
strlen, | ||
WEBKIT | ||
WEBKIT, | ||
type Element, | ||
Middleware | ||
} from 'stylis' | ||
|
||
// `@types/stylis` are inaccurate, so we temporarily cast to our own definitions until fix lands: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/71310 | ||
const copy: (root: Element, props: Partial<Element>) => Element = _copy as any | ||
|
||
// this is a copy of [email protected] prefixer, the latter version introduced grid prefixing which we don't want | ||
|
||
function prefix(value, length) { | ||
function prefix(value: string, length: number): string { | ||
switch (hash(value, length)) { | ||
// color-adjust | ||
case 5103: | ||
|
@@ -279,7 +284,12 @@ function prefix(value, length) { | |
return value | ||
} | ||
|
||
export let prefixer = (element, index, children, callback) => { | ||
export let prefixer = ( | ||
element: Element, | ||
index: number, | ||
children: Element[], | ||
callback: Middleware | ||
) => { | ||
if (element.length > -1) | ||
if (!element.return) | ||
switch (element.type) { | ||
|
@@ -297,7 +307,7 @@ export let prefixer = (element, index, children, callback) => { | |
) | ||
case RULESET: | ||
if (element.length) | ||
return combine(element.props, function (value) { | ||
return combine(element.props as string[], function (value) { | ||
switch (match(value, /(::plac\w+|:read-\w+)/)) { | ||
// :read-(only|write) | ||
case ':read-only': | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
funny thing, I think this was incorrect since #1817 . It was working because we were able to store properties on this function that was returned from here. We should be returning an object though. The caller is responsible both for reading and writing to this "cache"