forked from vuejs/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(types/jsx): support jsxImportSource, avoid global JSX conflict (v…
…uejs#7958) - No longer implicitly register global JSX types by default - This avoid conflict when using Vue in the same project with React - Global registration must now be done by explicitly importing / referencing `vue/jsx`, or listing it in `compilerOptions.types`. - Add `vue/jsx-runtime` to support `jsxImportSource` usage - Can enable globally by setting `compilerOptions.jsxImportSource` to `'vue'` - Can also opt-in per-file with `/** @jsxImportSource vue */`
- Loading branch information
Showing
9 changed files
with
83 additions
and
43 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { VNode, VNodeRef } from '@vue/runtime-dom' | ||
import { IntrinsicElementAttributes } from './dom' | ||
|
||
export type ReservedProps = { | ||
key?: string | number | symbol | ||
ref?: VNodeRef | ||
ref_for?: boolean | ||
ref_key?: string | ||
} | ||
|
||
export type NativeElements = { | ||
[K in keyof IntrinsicElementAttributes]: IntrinsicElementAttributes[K] & | ||
ReservedProps | ||
} | ||
|
||
/** | ||
* JSX namespace for usage with @jsxImportsSource directive | ||
* when ts compilerOptions.jsx is 'react-jsx' or 'react-jsxdev' | ||
* https://www.typescriptlang.org/tsconfig#jsxImportSource | ||
*/ | ||
export { h as jsx, h as jsxDEV, Fragment } from '@vue/runtime-dom' | ||
|
||
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: {} | ||
} | ||
} |
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,4 @@ | ||
const Vue = require('vue') | ||
exports.jsx = Vue.h | ||
exports.jsxDEV = Vue.h | ||
exports.Fragment = Vue.Fragment |
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 @@ | ||
export { h as jsx, h as jsxDEV, Fragment } from 'vue' |
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 @@ | ||
{ | ||
"main": "index.js", | ||
"module": "index.mjs", | ||
"types": "index.d.ts" | ||
} |
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,17 @@ | ||
// global JSX namespace registration | ||
import { JSX as JSXInternal } from './jsx-runtime' | ||
|
||
declare global { | ||
namespace JSX { | ||
interface Element extends JSXInternal.Element {} | ||
interface ElementClass extends JSXInternal.ElementClass {} | ||
interface ElementAttributesProperty | ||
extends JSXInternal.ElementAttributesProperty {} | ||
interface IntrinsicElements extends JSXInternal.IntrinsicElements {} | ||
interface IntrinsicAttributes extends JSXInternal.IntrinsicAttributes {} | ||
interface ElementChildrenAttribute | ||
extends JSXInternal.ElementChildrenAttribute {} | ||
} | ||
} | ||
|
||
export {} |
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