Skip to content

Commit

Permalink
Merge pull request #2869 from preactjs/ts-use-dom-cssom
Browse files Browse the repository at this point in the history
[ts] Use CSSStyleDeclaration for CSS property list
  • Loading branch information
developit authored Dec 21, 2020
2 parents 0de465a + 0244869 commit e8a4c46
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 20 deletions.
6 changes: 0 additions & 6 deletions config/copy-csstype.js

This file was deleted.

18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"build:test-utils": "microbundle build --raw --cwd test-utils",
"build:compat": "microbundle build --raw --cwd compat --globals 'preact/hooks=preactHooks'",
"build:jsx": "microbundle build --raw --cwd jsx-runtime",
"postbuild": "node ./config/node-13-exports.js && node ./config/copy-csstype.js",
"postbuild": "node ./config/node-13-exports.js",
"dev": "microbundle watch --raw --format cjs",
"dev:hooks": "microbundle watch --raw --format cjs --cwd hooks",
"dev:compat": "microbundle watch --raw --format cjs --cwd compat --globals 'preact/hooks=preactHooks'",
Expand Down
28 changes: 15 additions & 13 deletions src/jsx.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Users who only use Preact for SSR might not specify "dom" in their lib in tsconfig.json
/// <reference lib="dom" />
import * as CSS from './jsx-csstype';

type Defaultize<Props, Defaults> =
// Distribute over unions
Expand Down Expand Up @@ -33,18 +32,21 @@ export namespace JSXInternal {
children: any;
}

interface CSSProperties<
TLength = (string & {}) | number,
TTime = string & {}
> extends CSS.Properties<TLength, TTime> {
/**
* The index signature was removed to enable closed typing for style
* using CSSType. You're able to use type assertion or module augmentation
* to add properties or an index signature of your own.
*
* For examples and more information, visit:
* https://github.com/frenic/csstype#what-should-i-do-when-i-get-type-errors
*/
type DOMCSSProperties = {
[key in keyof Omit<
CSSStyleDeclaration,
| 'item'
| 'setProperty'
| 'removeProperty'
| 'getPropertyValue'
| 'getPropertyPriority'
>]?: string | number | null | undefined;
};
type AllCSSProperties = {
[key: string]: string | number | null | undefined;
};
interface CSSProperties extends AllCSSProperties, DOMCSSProperties {
cssText?: string | null;
}

interface SVGAttributes<Target extends EventTarget = SVGElement>
Expand Down

0 comments on commit e8a4c46

Please sign in to comment.