-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
feat(jsx-types): namespace JSX types #7083
Changes from all commits
0ce86c2
f1f9527
6df268d
f8762a6
b93f2b0
3662049
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../../api-extractor.json", | ||
"mainEntryPointFilePath": "./dist/packages/<unscopedPackageName>/src/index.d.ts", | ||
"dtsRollup": { | ||
"publicTrimmedFilePath": "./dist/<unscopedPackageName>.d.ts" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "@vue/jsx", | ||
"version": "3.2.44", | ||
"description": "@vue/jsx", | ||
"main": "dist/jsx.cjs.js", | ||
"types": "dist/jsx.d.ts", | ||
"files": [ | ||
"register.d.ts", | ||
"dist" | ||
], | ||
"buildOptions": { | ||
"formats": [ | ||
"cjs" | ||
] | ||
}, | ||
"sideEffects": false, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/vuejs/core.git", | ||
"directory": "packages/jsx" | ||
}, | ||
"keywords": [ | ||
"vue" | ||
], | ||
"author": "Rahul Kadyan", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/vuejs/core/issues" | ||
}, | ||
"homepage": "https://github.com/vuejs/core/tree/main/packages/jsx#readme", | ||
"dependencies": { | ||
"csstype": "^3.1.1", | ||
"@vue/runtime-core": "3.2.44" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { h } from './dist/jsx' | ||
|
||
declare global { | ||
namespace JSX { | ||
interface Element extends h.JSX.Element {} | ||
interface ElementClass extends h.JSX.ElementClass {} | ||
interface ElementAttributesProperty | ||
extends h.JSX.ElementAttributesProperty {} | ||
interface IntrinsicElements extends h.JSX.IntrinsicElements {} | ||
interface IntrinsicAttributes extends h.JSX.IntrinsicAttributes {} | ||
interface ElementChildrenAttribute extends h.JSX.ElementChildrenAttribute {} | ||
} | ||
} | ||
|
||
export {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as CSS from 'csstype' | ||
|
||
export interface CSSProperties | ||
extends CSS.Properties<string | number>, | ||
CSS.PropertiesHyphen<string | number> { | ||
/** | ||
* 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 | ||
*/ | ||
[v: `--${string}`]: string | number | undefined | ||
} | ||
|
||
// Vue's style normalization supports nested arrays | ||
export type StyleValue = string | CSSProperties | Array<StyleValue> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { type VNode, h as _h } from '@vue/runtime-core' | ||
import { type HTMLElementAttributesMap } from './html' | ||
import { type SVGElementAttributesMap } from './svg' | ||
import { type ReservedProps } from './vue' | ||
|
||
type ElementAttrs<T> = T & ReservedProps | ||
type NativeElements = { | ||
[K in keyof HTMLElementAttributesMap]: ElementAttrs< | ||
HTMLElementAttributesMap[K] | ||
> | ||
} & { | ||
[K in keyof SVGElementAttributesMap]: ElementAttrs<SVGElementAttributesMap[K]> | ||
} | ||
|
||
/** | ||
* This is only for type support. | ||
* @public | ||
*/ | ||
export const h = _h | ||
export namespace h { | ||
export namespace JSX { | ||
export interface Element extends VNode {} | ||
export interface ElementClass { | ||
$props: {} | ||
} | ||
export interface ElementAttributesProperty { | ||
$props: {} | ||
} | ||
export interface IntrinsicElements extends NativeElements { | ||
// allow arbitrary elements | ||
// @ts-ignore suppress ts:2374 = Duplicate string index signature. | ||
[name: string]: any | ||
} | ||
export interface IntrinsicAttributes extends ReservedProps {} | ||
export interface ElementChildrenAttribute { | ||
$slots: {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this count as breaking change?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vuetify uses $children. Volar uses $slots but it isn't inside $props so doesn't count. |
||
} | ||
} | ||
} |
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.
I hope it's okay to use
@vue/jsx
as package name.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.
It's more like
@vue/tsx
though 😂Unless we are planning to add more functionalities to this package later.