mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-26 21:23:53 -06:00
Auto-include types for the jsx import source in the new jsx transforms
This commit is contained in:
parent
6bde4b5c02
commit
6714998e01
@ -25132,6 +25132,31 @@ namespace ts {
|
||||
return links.resolvedSymbol;
|
||||
}
|
||||
|
||||
function getJsxNamespaceContainerForImplicitImport(location: Node | undefined): Symbol | undefined {
|
||||
const file = location && getSourceFileOfNode(location);
|
||||
const links = file && getNodeLinks(file);
|
||||
if (links && links.jsxImplicitImportContainer === false) {
|
||||
return undefined;
|
||||
}
|
||||
if (links && links.jsxImplicitImportContainer) {
|
||||
return links.jsxImplicitImportContainer;
|
||||
}
|
||||
const runtimeImportSpecifier = getJSXRuntimeImport(getJSXImplicitImportBase(compilerOptions, file), compilerOptions);
|
||||
if (!runtimeImportSpecifier) {
|
||||
return undefined;
|
||||
}
|
||||
const isClassic = getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Classic;
|
||||
const errorMessage = isClassic
|
||||
? Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_the_paths_option
|
||||
: Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
|
||||
const mod = resolveExternalModule(location!, runtimeImportSpecifier, errorMessage, location!);
|
||||
const result = mod && mod !== unknownSymbol ? getMergedSymbol(resolveSymbol(mod)) : undefined;
|
||||
if (links) {
|
||||
links.jsxImplicitImportContainer = result || false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function getJsxNamespaceAt(location: Node | undefined): Symbol {
|
||||
const links = location && getNodeLinks(location);
|
||||
if (links && links.jsxNamespace) {
|
||||
@ -25139,7 +25164,10 @@ namespace ts {
|
||||
}
|
||||
if (!links || links.jsxNamespace !== false) {
|
||||
const namespaceName = getJsxNamespace(location);
|
||||
const resolvedNamespace = resolveName(location, namespaceName, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false);
|
||||
let resolvedNamespace = resolveName(location, namespaceName, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false);
|
||||
if (!resolvedNamespace || resolvedNamespace === unknownSymbol) {
|
||||
resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location);
|
||||
}
|
||||
if (resolvedNamespace) {
|
||||
const candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, SymbolFlags.Namespace));
|
||||
if (candidate && candidate !== unknownSymbol) {
|
||||
@ -25148,9 +25176,9 @@ namespace ts {
|
||||
}
|
||||
return candidate;
|
||||
}
|
||||
if (links) {
|
||||
links.jsxNamespace = false;
|
||||
}
|
||||
}
|
||||
if (links) {
|
||||
links.jsxNamespace = false;
|
||||
}
|
||||
}
|
||||
// JSX global fallback
|
||||
|
||||
@ -402,8 +402,10 @@ namespace ts {
|
||||
*/
|
||||
export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[] {
|
||||
// Use explicit type list from tsconfig.json
|
||||
// jsxImportSource, if present and in use, creates implicit imports
|
||||
const implicitImport = getJSXRuntimeImport(getJSXImplicitImportBase(options), options);
|
||||
if (options.types) {
|
||||
return options.types;
|
||||
return [...options.types, ...(implicitImport ? [implicitImport] : [])];
|
||||
}
|
||||
|
||||
// Walk the primary type lookup locations
|
||||
@ -434,6 +436,9 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (implicitImport) {
|
||||
result.push(implicitImport);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -1494,7 +1494,7 @@ namespace ts {
|
||||
}
|
||||
// try to verify results of module resolution
|
||||
for (const { oldFile: oldSourceFile, newFile: newSourceFile } of modifiedSourceFiles) {
|
||||
const moduleNames = getModuleNames(newSourceFile);
|
||||
const moduleNames = getModuleNames(newSourceFile, options);
|
||||
const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
|
||||
// ensure that module resolution results are still correct
|
||||
const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo);
|
||||
@ -2840,11 +2840,16 @@ namespace ts {
|
||||
if (resolvedTypeReferenceDirective.isExternalLibraryImport) currentNodeModulesDepth--;
|
||||
}
|
||||
else {
|
||||
fileProcessingDiagnostics.add(createRefFileDiagnostic(
|
||||
refFile,
|
||||
Diagnostics.Cannot_find_type_definition_file_for_0,
|
||||
typeReferenceDirective
|
||||
));
|
||||
// Don't issue an error when auto-inclusion lookup fails for the jsxImportSource (at this point)
|
||||
// It may be provided by an ambient module in the compilation, instead.
|
||||
// A usage of a JSX tag later should report that the module couldn't be resolved if it is not supplied.
|
||||
if (refFile || typeReferenceDirective !== getJSXRuntimeImport(getJSXImplicitImportBase(options), options)) {
|
||||
fileProcessingDiagnostics.add(createRefFileDiagnostic(
|
||||
refFile,
|
||||
Diagnostics.Cannot_find_type_definition_file_for_0,
|
||||
typeReferenceDirective
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if (saveResolution) {
|
||||
@ -2891,9 +2896,9 @@ namespace ts {
|
||||
|
||||
function processImportedModules(file: SourceFile) {
|
||||
collectExternalModuleReferences(file);
|
||||
if (file.imports.length || file.moduleAugmentations.length) {
|
||||
if (file.imports.length || file.moduleAugmentations.length || getJSXImplicitImportBase(options, file)) {
|
||||
// Because global augmentation doesn't have string literal name, we can check for global augmentation as such.
|
||||
const moduleNames = getModuleNames(file);
|
||||
const moduleNames = getModuleNames(file, options);
|
||||
const resolutions = resolveModuleNamesReusingOldState(moduleNames, file);
|
||||
Debug.assert(resolutions.length === moduleNames.length);
|
||||
for (let i = 0; i < moduleNames.length; i++) {
|
||||
@ -3882,7 +3887,8 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function getModuleNames({ imports, moduleAugmentations }: SourceFile): string[] {
|
||||
function getModuleNames(file: SourceFile, options: CompilerOptions): string[] {
|
||||
const { imports, moduleAugmentations } = file;
|
||||
const res = imports.map(i => i.text);
|
||||
for (const aug of moduleAugmentations) {
|
||||
if (aug.kind === SyntaxKind.StringLiteral) {
|
||||
@ -3890,6 +3896,10 @@ namespace ts {
|
||||
}
|
||||
// Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`.
|
||||
}
|
||||
const jsxRuntimeImport = getJSXRuntimeImport(getJSXImplicitImportBase(options, file), options);
|
||||
if (jsxRuntimeImport) {
|
||||
res.push(jsxRuntimeImport);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ namespace ts {
|
||||
function getImplicitImportForName(name: string) {
|
||||
const importSource = name === "createElement"
|
||||
? currentFileState.importSpecifier!
|
||||
: `${currentFileState.importSpecifier}/${compilerOptions.jsx === JsxEmit.ReactJSXDev ? "jsx-dev-runtime" : "jsx-runtime"}`;
|
||||
: getJSXRuntimeImport(currentFileState.importSpecifier, compilerOptions)!;
|
||||
const existing = currentFileState.utilizedImplicitRuntimeImports?.get(importSource)?.get(name);
|
||||
if (existing) {
|
||||
return existing.name;
|
||||
|
||||
@ -4843,6 +4843,7 @@ namespace ts {
|
||||
resolvedJSDocType?: Type; // Resolved type of a JSDoc type reference
|
||||
switchTypes?: Type[]; // Cached array of switch case expression types
|
||||
jsxNamespace?: Symbol | false; // Resolved jsx namespace symbol for this node
|
||||
jsxImplicitImportContainer?: Symbol | false; // Resolved module symbol the implicit jsx import of this file should refer to
|
||||
contextFreeType?: Type; // Cached context-free type used by the first pass of inference; used when a function's return is partially contextually sensitive
|
||||
deferredNodes?: ESMap<NodeId, Node>; // Set of nodes whose checking has been deferred
|
||||
capturedBlockScopeBindings?: Symbol[]; // Block-scoped bindings captured beneath this part of an IterationStatement
|
||||
|
||||
@ -6009,8 +6009,8 @@ namespace ts {
|
||||
return jsx === JsxEmit.React || jsx === JsxEmit.ReactJSX || jsx === JsxEmit.ReactJSXDev;
|
||||
}
|
||||
|
||||
export function getJSXImplicitImportBase(compilerOptions: CompilerOptions, file: SourceFile): string | undefined {
|
||||
const jsxImportSourcePragmas = file.pragmas.get("jsximportsource");
|
||||
export function getJSXImplicitImportBase(compilerOptions: CompilerOptions, file?: SourceFile): string | undefined {
|
||||
const jsxImportSourcePragmas = file?.pragmas.get("jsximportsource");
|
||||
const jsxImportSourcePragma = isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[0] : jsxImportSourcePragmas;
|
||||
return compilerOptions.jsx === JsxEmit.ReactJSX ||
|
||||
compilerOptions.jsx === JsxEmit.ReactJSXDev ||
|
||||
@ -6020,6 +6020,10 @@ namespace ts {
|
||||
undefined;
|
||||
}
|
||||
|
||||
export function getJSXRuntimeImport(base: string | undefined, options: CompilerOptions) {
|
||||
return base ? `${base}/${options.jsx === JsxEmit.ReactJSXDev ? "jsx-dev-runtime" : "jsx-runtime"}` : undefined;
|
||||
}
|
||||
|
||||
export function hasZeroOrOneAsteriskCharacter(str: string): boolean {
|
||||
let seenAsterisk = false;
|
||||
for (let i = 0; i < str.length; i++) {
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImport.tsx (1 errors) ====
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
const a = <>
|
||||
~~
|
||||
!!! error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations.
|
||||
<p></p>
|
||||
text
|
||||
<div className="foo"></div>
|
||||
</>
|
||||
|
||||
export {};
|
||||
@ -0,0 +1,14 @@
|
||||
tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImport.tsx(2,11): error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformCustomImport.tsx (1 errors) ====
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
const a = <>
|
||||
~~
|
||||
!!! error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations.
|
||||
<p></p>
|
||||
text
|
||||
<div className="foo"></div>
|
||||
</>
|
||||
|
||||
export {};
|
||||
@ -0,0 +1,26 @@
|
||||
tests/cases/conformance/jsx/jsxs/preact.tsx(3,11): error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/jsxs/react.tsx (0 errors) ====
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
/* @jsxImportSource react */
|
||||
import "./preact";
|
||||
const a = <>
|
||||
<p></p>
|
||||
text
|
||||
<div className="foo"></div>
|
||||
</>
|
||||
|
||||
export {};
|
||||
==== tests/cases/conformance/jsx/jsxs/preact.tsx (1 errors) ====
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
/* @jsxImportSource preact */
|
||||
const a = <>
|
||||
~~
|
||||
!!! error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations.
|
||||
<p></p>
|
||||
text
|
||||
<div className="foo"></div>
|
||||
</>
|
||||
|
||||
export {};
|
||||
@ -0,0 +1,26 @@
|
||||
tests/cases/conformance/jsx/jsxs/preact.tsx(3,11): error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/jsxs/react.tsx (0 errors) ====
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
/* @jsxImportSource react */
|
||||
import "./preact";
|
||||
const a = <>
|
||||
<p></p>
|
||||
text
|
||||
<div className="foo"></div>
|
||||
</>
|
||||
|
||||
export {};
|
||||
==== tests/cases/conformance/jsx/jsxs/preact.tsx (1 errors) ====
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
/* @jsxImportSource preact */
|
||||
const a = <>
|
||||
~~
|
||||
!!! error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations.
|
||||
<p></p>
|
||||
text
|
||||
<div className="foo"></div>
|
||||
</>
|
||||
|
||||
export {};
|
||||
@ -0,0 +1,13 @@
|
||||
tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImport.tsx(3,11): error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImport.tsx (1 errors) ====
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
const props = { answer: 42 }
|
||||
const a = <div key="foo" {...props}>text</div>;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations.
|
||||
const b = <div {...props} key="bar">text</div>;
|
||||
|
||||
export {};
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImport.tsx(3,11): error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformKeyPropCustomImport.tsx (1 errors) ====
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
const props = { answer: 42 }
|
||||
const a = <div key="foo" {...props}>text</div>;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations.
|
||||
const b = <div {...props} key="bar">text</div>;
|
||||
|
||||
export {};
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
tests/cases/conformance/jsx/jsxs/preact.tsx(4,11): error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/jsxs/react.tsx (0 errors) ====
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
/* @jsxImportSource react */
|
||||
import "./preact";
|
||||
const props2 = { answer: 42 }
|
||||
const a2 = <div key="foo" {...props2}>text</div>;
|
||||
const b2 = <div {...props2} key="bar">text</div>;
|
||||
|
||||
export {};
|
||||
|
||||
==== tests/cases/conformance/jsx/jsxs/preact.tsx (1 errors) ====
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
/* @jsxImportSource preact */
|
||||
const props = { answer: 42 }
|
||||
const a = <div key="foo" {...props}>text</div>;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'preact/jsx-runtime' or its corresponding type declarations.
|
||||
const b = <div {...props} key="bar">text</div>;
|
||||
|
||||
export {};
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
tests/cases/conformance/jsx/jsxs/preact.tsx(4,11): error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations.
|
||||
|
||||
|
||||
==== tests/cases/conformance/jsx/jsxs/react.tsx (0 errors) ====
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
/* @jsxImportSource react */
|
||||
import "./preact";
|
||||
const props2 = { answer: 42 }
|
||||
const a2 = <div key="foo" {...props2}>text</div>;
|
||||
const b2 = <div {...props2} key="bar">text</div>;
|
||||
|
||||
export {};
|
||||
|
||||
==== tests/cases/conformance/jsx/jsxs/preact.tsx (1 errors) ====
|
||||
/// <reference path="/.lib/react16.d.ts" />
|
||||
/* @jsxImportSource preact */
|
||||
const props = { answer: 42 }
|
||||
const a = <div key="foo" {...props}>text</div>;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2307: Cannot find module 'preact/jsx-dev-runtime' or its corresponding type declarations.
|
||||
const b = <div {...props} key="bar">text</div>;
|
||||
|
||||
export {};
|
||||
|
||||
@ -0,0 +1,110 @@
|
||||
//// [tests/cases/compiler/jsxNamespaceImplicitImportJSXNamespace.tsx] ////
|
||||
|
||||
//// [index.d.ts]
|
||||
type Defaultize<Props, Defaults> =
|
||||
// Distribute over unions
|
||||
Props extends any // Make any properties included in Default optional
|
||||
? Partial<Pick<Props, Extract<keyof Props, keyof Defaults>>> &
|
||||
// Include the remaining properties from Props
|
||||
Pick<Props, Exclude<keyof Props, keyof Defaults>>
|
||||
: never;
|
||||
export namespace JSXInternal {
|
||||
interface HTMLAttributes<T = {}> { }
|
||||
interface SVGAttributes<T = {}> { }
|
||||
type LibraryManagedAttributes<Component, Props> = Component extends {
|
||||
defaultProps: infer Defaults;
|
||||
}
|
||||
? Defaultize<Props, Defaults>
|
||||
: Props;
|
||||
|
||||
interface IntrinsicAttributes {
|
||||
key?: any;
|
||||
}
|
||||
|
||||
interface Element extends VNode<any> { }
|
||||
|
||||
interface ElementClass extends Component<any, any> { }
|
||||
|
||||
interface ElementAttributesProperty {
|
||||
props: any;
|
||||
}
|
||||
|
||||
interface ElementChildrenAttribute {
|
||||
children: any;
|
||||
}
|
||||
|
||||
interface IntrinsicElements {
|
||||
div: HTMLAttributes;
|
||||
}
|
||||
}
|
||||
export const Fragment: unique symbol;
|
||||
export type ComponentType<T = {}> = {};
|
||||
export type ComponentChild = {};
|
||||
export type ComponentChildren = {};
|
||||
export type VNode<T = {}> = {};
|
||||
export type Attributes = {};
|
||||
export type Component<T = {}, U = {}> = {};
|
||||
//// [index.d.ts]
|
||||
export { Fragment } from '..';
|
||||
import {
|
||||
ComponentType,
|
||||
ComponentChild,
|
||||
ComponentChildren,
|
||||
VNode,
|
||||
Attributes
|
||||
} from '..';
|
||||
import { JSXInternal } from '..';
|
||||
|
||||
export function jsx(
|
||||
type: string,
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
JSXInternal.SVGAttributes &
|
||||
Record<string, any> & { children?: ComponentChild },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
export function jsx<P>(
|
||||
type: ComponentType<P>,
|
||||
props: Attributes & P & { children?: ComponentChild },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
|
||||
|
||||
export function jsxs(
|
||||
type: string,
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
JSXInternal.SVGAttributes &
|
||||
Record<string, any> & { children?: ComponentChild[] },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
export function jsxs<P>(
|
||||
type: ComponentType<P>,
|
||||
props: Attributes & P & { children?: ComponentChild[] },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
|
||||
|
||||
export function jsxDEV(
|
||||
type: string,
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
JSXInternal.SVGAttributes &
|
||||
Record<string, any> & { children?: ComponentChildren },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
export function jsxDEV<P>(
|
||||
type: ComponentType<P>,
|
||||
props: Attributes & P & { children?: ComponentChildren },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
|
||||
export import JSX = JSXInternal;
|
||||
|
||||
//// [index.tsx]
|
||||
export const Comp = () => <div></div>;
|
||||
|
||||
//// [index.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports.Comp = void 0;
|
||||
var jsx_runtime_1 = require("preact/jsx-runtime");
|
||||
var Comp = function () { return jsx_runtime_1.jsx("div", {}, void 0); };
|
||||
exports.Comp = Comp;
|
||||
@ -0,0 +1,298 @@
|
||||
=== /node_modules/preact/index.d.ts ===
|
||||
type Defaultize<Props, Defaults> =
|
||||
>Defaultize : Symbol(Defaultize, Decl(index.d.ts, 0, 0))
|
||||
>Props : Symbol(Props, Decl(index.d.ts, 0, 16))
|
||||
>Defaults : Symbol(Defaults, Decl(index.d.ts, 0, 22))
|
||||
|
||||
// Distribute over unions
|
||||
Props extends any // Make any properties included in Default optional
|
||||
>Props : Symbol(Props, Decl(index.d.ts, 0, 16))
|
||||
|
||||
? Partial<Pick<Props, Extract<keyof Props, keyof Defaults>>> &
|
||||
>Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --))
|
||||
>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --))
|
||||
>Props : Symbol(Props, Decl(index.d.ts, 0, 16))
|
||||
>Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --))
|
||||
>Props : Symbol(Props, Decl(index.d.ts, 0, 16))
|
||||
>Defaults : Symbol(Defaults, Decl(index.d.ts, 0, 22))
|
||||
|
||||
// Include the remaining properties from Props
|
||||
Pick<Props, Exclude<keyof Props, keyof Defaults>>
|
||||
>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --))
|
||||
>Props : Symbol(Props, Decl(index.d.ts, 0, 16))
|
||||
>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --))
|
||||
>Props : Symbol(Props, Decl(index.d.ts, 0, 16))
|
||||
>Defaults : Symbol(Defaults, Decl(index.d.ts, 0, 22))
|
||||
|
||||
: never;
|
||||
export namespace JSXInternal {
|
||||
>JSXInternal : Symbol(JSXInternal, Decl(index.d.ts, 6, 10))
|
||||
|
||||
interface HTMLAttributes<T = {}> { }
|
||||
>HTMLAttributes : Symbol(HTMLAttributes, Decl(index.d.ts, 7, 30))
|
||||
>T : Symbol(T, Decl(index.d.ts, 8, 29))
|
||||
|
||||
interface SVGAttributes<T = {}> { }
|
||||
>SVGAttributes : Symbol(SVGAttributes, Decl(index.d.ts, 8, 40))
|
||||
>T : Symbol(T, Decl(index.d.ts, 9, 28))
|
||||
|
||||
type LibraryManagedAttributes<Component, Props> = Component extends {
|
||||
>LibraryManagedAttributes : Symbol(LibraryManagedAttributes, Decl(index.d.ts, 9, 39))
|
||||
>Component : Symbol(Component, Decl(index.d.ts, 10, 34))
|
||||
>Props : Symbol(Props, Decl(index.d.ts, 10, 44))
|
||||
>Component : Symbol(Component, Decl(index.d.ts, 10, 34))
|
||||
|
||||
defaultProps: infer Defaults;
|
||||
>defaultProps : Symbol(defaultProps, Decl(index.d.ts, 10, 73))
|
||||
>Defaults : Symbol(Defaults, Decl(index.d.ts, 11, 27))
|
||||
}
|
||||
? Defaultize<Props, Defaults>
|
||||
>Defaultize : Symbol(Defaultize, Decl(index.d.ts, 0, 0))
|
||||
>Props : Symbol(Props, Decl(index.d.ts, 10, 44))
|
||||
>Defaults : Symbol(Defaults, Decl(index.d.ts, 11, 27))
|
||||
|
||||
: Props;
|
||||
>Props : Symbol(Props, Decl(index.d.ts, 10, 44))
|
||||
|
||||
interface IntrinsicAttributes {
|
||||
>IntrinsicAttributes : Symbol(IntrinsicAttributes, Decl(index.d.ts, 14, 16))
|
||||
|
||||
key?: any;
|
||||
>key : Symbol(IntrinsicAttributes.key, Decl(index.d.ts, 16, 35))
|
||||
}
|
||||
|
||||
interface Element extends VNode<any> { }
|
||||
>Element : Symbol(Element, Decl(index.d.ts, 18, 5))
|
||||
>VNode : Symbol(VNode, Decl(index.d.ts, 39, 35))
|
||||
|
||||
interface ElementClass extends Component<any, any> { }
|
||||
>ElementClass : Symbol(ElementClass, Decl(index.d.ts, 20, 44))
|
||||
>Component : Symbol(Component, Decl(index.d.ts, 41, 28))
|
||||
|
||||
interface ElementAttributesProperty {
|
||||
>ElementAttributesProperty : Symbol(ElementAttributesProperty, Decl(index.d.ts, 22, 58))
|
||||
|
||||
props: any;
|
||||
>props : Symbol(ElementAttributesProperty.props, Decl(index.d.ts, 24, 41))
|
||||
}
|
||||
|
||||
interface ElementChildrenAttribute {
|
||||
>ElementChildrenAttribute : Symbol(ElementChildrenAttribute, Decl(index.d.ts, 26, 5))
|
||||
|
||||
children: any;
|
||||
>children : Symbol(ElementChildrenAttribute.children, Decl(index.d.ts, 28, 40))
|
||||
}
|
||||
|
||||
interface IntrinsicElements {
|
||||
>IntrinsicElements : Symbol(IntrinsicElements, Decl(index.d.ts, 30, 5))
|
||||
|
||||
div: HTMLAttributes;
|
||||
>div : Symbol(IntrinsicElements.div, Decl(index.d.ts, 32, 33))
|
||||
>HTMLAttributes : Symbol(HTMLAttributes, Decl(index.d.ts, 7, 30))
|
||||
}
|
||||
}
|
||||
export const Fragment: unique symbol;
|
||||
>Fragment : Symbol(Fragment, Decl(index.d.ts, 36, 12))
|
||||
|
||||
export type ComponentType<T = {}> = {};
|
||||
>ComponentType : Symbol(ComponentType, Decl(index.d.ts, 36, 37))
|
||||
>T : Symbol(T, Decl(index.d.ts, 37, 26))
|
||||
|
||||
export type ComponentChild = {};
|
||||
>ComponentChild : Symbol(ComponentChild, Decl(index.d.ts, 37, 39))
|
||||
|
||||
export type ComponentChildren = {};
|
||||
>ComponentChildren : Symbol(ComponentChildren, Decl(index.d.ts, 38, 32))
|
||||
|
||||
export type VNode<T = {}> = {};
|
||||
>VNode : Symbol(VNode, Decl(index.d.ts, 39, 35))
|
||||
>T : Symbol(T, Decl(index.d.ts, 40, 18))
|
||||
|
||||
export type Attributes = {};
|
||||
>Attributes : Symbol(Attributes, Decl(index.d.ts, 40, 31))
|
||||
|
||||
export type Component<T = {}, U = {}> = {};
|
||||
>Component : Symbol(Component, Decl(index.d.ts, 41, 28))
|
||||
>T : Symbol(T, Decl(index.d.ts, 42, 22))
|
||||
>U : Symbol(U, Decl(index.d.ts, 42, 29))
|
||||
|
||||
=== /node_modules/preact/jsx-runtime/index.d.ts ===
|
||||
export { Fragment } from '..';
|
||||
>Fragment : Symbol(Fragment, Decl(index.d.ts, 0, 8))
|
||||
|
||||
import {
|
||||
ComponentType,
|
||||
>ComponentType : Symbol(ComponentType, Decl(index.d.ts, 1, 8))
|
||||
|
||||
ComponentChild,
|
||||
>ComponentChild : Symbol(ComponentChild, Decl(index.d.ts, 2, 18))
|
||||
|
||||
ComponentChildren,
|
||||
>ComponentChildren : Symbol(ComponentChildren, Decl(index.d.ts, 3, 19))
|
||||
|
||||
VNode,
|
||||
>VNode : Symbol(VNode, Decl(index.d.ts, 4, 22))
|
||||
|
||||
Attributes
|
||||
>Attributes : Symbol(Attributes, Decl(index.d.ts, 5, 10))
|
||||
|
||||
} from '..';
|
||||
import { JSXInternal } from '..';
|
||||
>JSXInternal : Symbol(JSXInternal, Decl(index.d.ts, 8, 8))
|
||||
|
||||
export function jsx(
|
||||
>jsx : Symbol(jsx, Decl(index.d.ts, 8, 33), Decl(index.d.ts, 16, 14))
|
||||
|
||||
type: string,
|
||||
>type : Symbol(type, Decl(index.d.ts, 10, 20))
|
||||
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
>props : Symbol(props, Decl(index.d.ts, 11, 17))
|
||||
>JSXInternal : Symbol(JSXInternal, Decl(index.d.ts, 8, 8))
|
||||
>HTMLAttributes : Symbol(JSXInternal.HTMLAttributes, Decl(index.d.ts, 7, 30))
|
||||
|
||||
JSXInternal.SVGAttributes &
|
||||
>JSXInternal : Symbol(JSXInternal, Decl(index.d.ts, 8, 8))
|
||||
>SVGAttributes : Symbol(JSXInternal.SVGAttributes, Decl(index.d.ts, 8, 40))
|
||||
|
||||
Record<string, any> & { children?: ComponentChild },
|
||||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
|
||||
>children : Symbol(children, Decl(index.d.ts, 14, 31))
|
||||
>ComponentChild : Symbol(ComponentChild, Decl(index.d.ts, 2, 18))
|
||||
|
||||
key?: string
|
||||
>key : Symbol(key, Decl(index.d.ts, 14, 60))
|
||||
|
||||
): VNode<any>;
|
||||
>VNode : Symbol(VNode, Decl(index.d.ts, 4, 22))
|
||||
|
||||
export function jsx<P>(
|
||||
>jsx : Symbol(jsx, Decl(index.d.ts, 8, 33), Decl(index.d.ts, 16, 14))
|
||||
>P : Symbol(P, Decl(index.d.ts, 17, 20))
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : Symbol(type, Decl(index.d.ts, 17, 23))
|
||||
>ComponentType : Symbol(ComponentType, Decl(index.d.ts, 1, 8))
|
||||
>P : Symbol(P, Decl(index.d.ts, 17, 20))
|
||||
|
||||
props: Attributes & P & { children?: ComponentChild },
|
||||
>props : Symbol(props, Decl(index.d.ts, 18, 27))
|
||||
>Attributes : Symbol(Attributes, Decl(index.d.ts, 5, 10))
|
||||
>P : Symbol(P, Decl(index.d.ts, 17, 20))
|
||||
>children : Symbol(children, Decl(index.d.ts, 19, 29))
|
||||
>ComponentChild : Symbol(ComponentChild, Decl(index.d.ts, 2, 18))
|
||||
|
||||
key?: string
|
||||
>key : Symbol(key, Decl(index.d.ts, 19, 58))
|
||||
|
||||
): VNode<any>;
|
||||
>VNode : Symbol(VNode, Decl(index.d.ts, 4, 22))
|
||||
|
||||
|
||||
export function jsxs(
|
||||
>jsxs : Symbol(jsxs, Decl(index.d.ts, 21, 14), Decl(index.d.ts, 30, 14))
|
||||
|
||||
type: string,
|
||||
>type : Symbol(type, Decl(index.d.ts, 24, 21))
|
||||
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
>props : Symbol(props, Decl(index.d.ts, 25, 17))
|
||||
>JSXInternal : Symbol(JSXInternal, Decl(index.d.ts, 8, 8))
|
||||
>HTMLAttributes : Symbol(JSXInternal.HTMLAttributes, Decl(index.d.ts, 7, 30))
|
||||
|
||||
JSXInternal.SVGAttributes &
|
||||
>JSXInternal : Symbol(JSXInternal, Decl(index.d.ts, 8, 8))
|
||||
>SVGAttributes : Symbol(JSXInternal.SVGAttributes, Decl(index.d.ts, 8, 40))
|
||||
|
||||
Record<string, any> & { children?: ComponentChild[] },
|
||||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
|
||||
>children : Symbol(children, Decl(index.d.ts, 28, 31))
|
||||
>ComponentChild : Symbol(ComponentChild, Decl(index.d.ts, 2, 18))
|
||||
|
||||
key?: string
|
||||
>key : Symbol(key, Decl(index.d.ts, 28, 62))
|
||||
|
||||
): VNode<any>;
|
||||
>VNode : Symbol(VNode, Decl(index.d.ts, 4, 22))
|
||||
|
||||
export function jsxs<P>(
|
||||
>jsxs : Symbol(jsxs, Decl(index.d.ts, 21, 14), Decl(index.d.ts, 30, 14))
|
||||
>P : Symbol(P, Decl(index.d.ts, 31, 21))
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : Symbol(type, Decl(index.d.ts, 31, 24))
|
||||
>ComponentType : Symbol(ComponentType, Decl(index.d.ts, 1, 8))
|
||||
>P : Symbol(P, Decl(index.d.ts, 31, 21))
|
||||
|
||||
props: Attributes & P & { children?: ComponentChild[] },
|
||||
>props : Symbol(props, Decl(index.d.ts, 32, 27))
|
||||
>Attributes : Symbol(Attributes, Decl(index.d.ts, 5, 10))
|
||||
>P : Symbol(P, Decl(index.d.ts, 31, 21))
|
||||
>children : Symbol(children, Decl(index.d.ts, 33, 29))
|
||||
>ComponentChild : Symbol(ComponentChild, Decl(index.d.ts, 2, 18))
|
||||
|
||||
key?: string
|
||||
>key : Symbol(key, Decl(index.d.ts, 33, 60))
|
||||
|
||||
): VNode<any>;
|
||||
>VNode : Symbol(VNode, Decl(index.d.ts, 4, 22))
|
||||
|
||||
|
||||
export function jsxDEV(
|
||||
>jsxDEV : Symbol(jsxDEV, Decl(index.d.ts, 35, 14), Decl(index.d.ts, 44, 14))
|
||||
|
||||
type: string,
|
||||
>type : Symbol(type, Decl(index.d.ts, 38, 23))
|
||||
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
>props : Symbol(props, Decl(index.d.ts, 39, 17))
|
||||
>JSXInternal : Symbol(JSXInternal, Decl(index.d.ts, 8, 8))
|
||||
>HTMLAttributes : Symbol(JSXInternal.HTMLAttributes, Decl(index.d.ts, 7, 30))
|
||||
|
||||
JSXInternal.SVGAttributes &
|
||||
>JSXInternal : Symbol(JSXInternal, Decl(index.d.ts, 8, 8))
|
||||
>SVGAttributes : Symbol(JSXInternal.SVGAttributes, Decl(index.d.ts, 8, 40))
|
||||
|
||||
Record<string, any> & { children?: ComponentChildren },
|
||||
>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --))
|
||||
>children : Symbol(children, Decl(index.d.ts, 42, 31))
|
||||
>ComponentChildren : Symbol(ComponentChildren, Decl(index.d.ts, 3, 19))
|
||||
|
||||
key?: string
|
||||
>key : Symbol(key, Decl(index.d.ts, 42, 63))
|
||||
|
||||
): VNode<any>;
|
||||
>VNode : Symbol(VNode, Decl(index.d.ts, 4, 22))
|
||||
|
||||
export function jsxDEV<P>(
|
||||
>jsxDEV : Symbol(jsxDEV, Decl(index.d.ts, 35, 14), Decl(index.d.ts, 44, 14))
|
||||
>P : Symbol(P, Decl(index.d.ts, 45, 23))
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : Symbol(type, Decl(index.d.ts, 45, 26))
|
||||
>ComponentType : Symbol(ComponentType, Decl(index.d.ts, 1, 8))
|
||||
>P : Symbol(P, Decl(index.d.ts, 45, 23))
|
||||
|
||||
props: Attributes & P & { children?: ComponentChildren },
|
||||
>props : Symbol(props, Decl(index.d.ts, 46, 27))
|
||||
>Attributes : Symbol(Attributes, Decl(index.d.ts, 5, 10))
|
||||
>P : Symbol(P, Decl(index.d.ts, 45, 23))
|
||||
>children : Symbol(children, Decl(index.d.ts, 47, 29))
|
||||
>ComponentChildren : Symbol(ComponentChildren, Decl(index.d.ts, 3, 19))
|
||||
|
||||
key?: string
|
||||
>key : Symbol(key, Decl(index.d.ts, 47, 61))
|
||||
|
||||
): VNode<any>;
|
||||
>VNode : Symbol(VNode, Decl(index.d.ts, 4, 22))
|
||||
|
||||
export import JSX = JSXInternal;
|
||||
>JSX : Symbol(JSX, Decl(index.d.ts, 49, 14))
|
||||
>JSXInternal : Symbol(JSXInternal, Decl(index.d.ts, 8, 8))
|
||||
|
||||
=== /index.tsx ===
|
||||
export const Comp = () => <div></div>;
|
||||
>Comp : Symbol(Comp, Decl(index.tsx, 0, 12))
|
||||
>div : Symbol(JSXInternal.IntrinsicElements.div, Decl(index.d.ts, 32, 33))
|
||||
>div : Symbol(JSXInternal.IntrinsicElements.div, Decl(index.d.ts, 32, 33))
|
||||
|
||||
@ -0,0 +1,210 @@
|
||||
=== /node_modules/preact/index.d.ts ===
|
||||
type Defaultize<Props, Defaults> =
|
||||
>Defaultize : Defaultize<Props, Defaults>
|
||||
|
||||
// Distribute over unions
|
||||
Props extends any // Make any properties included in Default optional
|
||||
? Partial<Pick<Props, Extract<keyof Props, keyof Defaults>>> &
|
||||
// Include the remaining properties from Props
|
||||
Pick<Props, Exclude<keyof Props, keyof Defaults>>
|
||||
: never;
|
||||
export namespace JSXInternal {
|
||||
interface HTMLAttributes<T = {}> { }
|
||||
interface SVGAttributes<T = {}> { }
|
||||
type LibraryManagedAttributes<Component, Props> = Component extends {
|
||||
>LibraryManagedAttributes : LibraryManagedAttributes<Component, Props>
|
||||
|
||||
defaultProps: infer Defaults;
|
||||
>defaultProps : Defaults
|
||||
}
|
||||
? Defaultize<Props, Defaults>
|
||||
: Props;
|
||||
|
||||
interface IntrinsicAttributes {
|
||||
key?: any;
|
||||
>key : any
|
||||
}
|
||||
|
||||
interface Element extends VNode<any> { }
|
||||
|
||||
interface ElementClass extends Component<any, any> { }
|
||||
|
||||
interface ElementAttributesProperty {
|
||||
props: any;
|
||||
>props : any
|
||||
}
|
||||
|
||||
interface ElementChildrenAttribute {
|
||||
children: any;
|
||||
>children : any
|
||||
}
|
||||
|
||||
interface IntrinsicElements {
|
||||
div: HTMLAttributes;
|
||||
>div : HTMLAttributes<{}>
|
||||
}
|
||||
}
|
||||
export const Fragment: unique symbol;
|
||||
>Fragment : unique symbol
|
||||
|
||||
export type ComponentType<T = {}> = {};
|
||||
>ComponentType : ComponentType<T>
|
||||
|
||||
export type ComponentChild = {};
|
||||
>ComponentChild : ComponentChild
|
||||
|
||||
export type ComponentChildren = {};
|
||||
>ComponentChildren : ComponentChildren
|
||||
|
||||
export type VNode<T = {}> = {};
|
||||
>VNode : VNode<T>
|
||||
|
||||
export type Attributes = {};
|
||||
>Attributes : Attributes
|
||||
|
||||
export type Component<T = {}, U = {}> = {};
|
||||
>Component : Component<T, U>
|
||||
|
||||
=== /node_modules/preact/jsx-runtime/index.d.ts ===
|
||||
export { Fragment } from '..';
|
||||
>Fragment : unique symbol
|
||||
|
||||
import {
|
||||
ComponentType,
|
||||
>ComponentType : any
|
||||
|
||||
ComponentChild,
|
||||
>ComponentChild : any
|
||||
|
||||
ComponentChildren,
|
||||
>ComponentChildren : any
|
||||
|
||||
VNode,
|
||||
>VNode : any
|
||||
|
||||
Attributes
|
||||
>Attributes : any
|
||||
|
||||
} from '..';
|
||||
import { JSXInternal } from '..';
|
||||
>JSXInternal : any
|
||||
|
||||
export function jsx(
|
||||
>jsx : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChild;}, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: string,
|
||||
>type : string
|
||||
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
>props : JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild | undefined; }
|
||||
>JSXInternal : any
|
||||
|
||||
JSXInternal.SVGAttributes &
|
||||
>JSXInternal : any
|
||||
|
||||
Record<string, any> & { children?: ComponentChild },
|
||||
>children : ComponentChild | undefined
|
||||
|
||||
key?: string
|
||||
>key : string | undefined
|
||||
|
||||
): VNode<any>;
|
||||
export function jsx<P>(
|
||||
>jsx : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChild;}, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : ComponentType<P>
|
||||
|
||||
props: Attributes & P & { children?: ComponentChild },
|
||||
>props : P & { children?: ComponentChild | undefined; }
|
||||
>children : ComponentChild | undefined
|
||||
|
||||
key?: string
|
||||
>key : string | undefined
|
||||
|
||||
): VNode<any>;
|
||||
|
||||
|
||||
export function jsxs(
|
||||
>jsxs : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChild[];}, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: string,
|
||||
>type : string
|
||||
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
>props : JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild[] | undefined; }
|
||||
>JSXInternal : any
|
||||
|
||||
JSXInternal.SVGAttributes &
|
||||
>JSXInternal : any
|
||||
|
||||
Record<string, any> & { children?: ComponentChild[] },
|
||||
>children : ComponentChild[] | undefined
|
||||
|
||||
key?: string
|
||||
>key : string | undefined
|
||||
|
||||
): VNode<any>;
|
||||
export function jsxs<P>(
|
||||
>jsxs : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChild[] | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChild[];}, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : ComponentType<P>
|
||||
|
||||
props: Attributes & P & { children?: ComponentChild[] },
|
||||
>props : P & { children?: ComponentChild[] | undefined; }
|
||||
>children : ComponentChild[] | undefined
|
||||
|
||||
key?: string
|
||||
>key : string | undefined
|
||||
|
||||
): VNode<any>;
|
||||
|
||||
|
||||
export function jsxDEV(
|
||||
>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> & { children?: ComponentChildren;}, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: P & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: string,
|
||||
>type : string
|
||||
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
>props : JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChildren | undefined; }
|
||||
>JSXInternal : any
|
||||
|
||||
JSXInternal.SVGAttributes &
|
||||
>JSXInternal : any
|
||||
|
||||
Record<string, any> & { children?: ComponentChildren },
|
||||
>children : ComponentChildren | undefined
|
||||
|
||||
key?: string
|
||||
>key : string | undefined
|
||||
|
||||
): VNode<any>;
|
||||
export function jsxDEV<P>(
|
||||
>jsxDEV : { (type: string, props: JSXInternal.HTMLAttributes<{}> & JSXInternal.SVGAttributes<{}> & Record<string, any> & { children?: ComponentChildren | undefined; }, key?: string | undefined): VNode<any>; <P>(type: ComponentType<P>, props: Attributes & P & { children?: ComponentChildren;}, key?: string | undefined): VNode<any>; }
|
||||
|
||||
type: ComponentType<P>,
|
||||
>type : ComponentType<P>
|
||||
|
||||
props: Attributes & P & { children?: ComponentChildren },
|
||||
>props : P & { children?: ComponentChildren | undefined; }
|
||||
>children : ComponentChildren | undefined
|
||||
|
||||
key?: string
|
||||
>key : string | undefined
|
||||
|
||||
): VNode<any>;
|
||||
|
||||
export import JSX = JSXInternal;
|
||||
>JSX : any
|
||||
>JSXInternal : error
|
||||
|
||||
=== /index.tsx ===
|
||||
export const Comp = () => <div></div>;
|
||||
>Comp : () => import("/node_modules/preact/index").JSXInternal.Element
|
||||
>() => <div></div> : () => import("/node_modules/preact/index").JSXInternal.Element
|
||||
><div></div> : import("/node_modules/preact/index").JSXInternal.Element
|
||||
>div : any
|
||||
>div : any
|
||||
|
||||
103
tests/cases/compiler/jsxNamespaceImplicitImportJSXNamespace.tsx
Normal file
103
tests/cases/compiler/jsxNamespaceImplicitImportJSXNamespace.tsx
Normal file
@ -0,0 +1,103 @@
|
||||
// @strict: true
|
||||
// @jsx: react-jsx
|
||||
// @jsxImportSource: preact
|
||||
// @filename: /node_modules/preact/index.d.ts
|
||||
type Defaultize<Props, Defaults> =
|
||||
// Distribute over unions
|
||||
Props extends any // Make any properties included in Default optional
|
||||
? Partial<Pick<Props, Extract<keyof Props, keyof Defaults>>> &
|
||||
// Include the remaining properties from Props
|
||||
Pick<Props, Exclude<keyof Props, keyof Defaults>>
|
||||
: never;
|
||||
export namespace JSXInternal {
|
||||
interface HTMLAttributes<T = {}> { }
|
||||
interface SVGAttributes<T = {}> { }
|
||||
type LibraryManagedAttributes<Component, Props> = Component extends {
|
||||
defaultProps: infer Defaults;
|
||||
}
|
||||
? Defaultize<Props, Defaults>
|
||||
: Props;
|
||||
|
||||
interface IntrinsicAttributes {
|
||||
key?: any;
|
||||
}
|
||||
|
||||
interface Element extends VNode<any> { }
|
||||
|
||||
interface ElementClass extends Component<any, any> { }
|
||||
|
||||
interface ElementAttributesProperty {
|
||||
props: any;
|
||||
}
|
||||
|
||||
interface ElementChildrenAttribute {
|
||||
children: any;
|
||||
}
|
||||
|
||||
interface IntrinsicElements {
|
||||
div: HTMLAttributes;
|
||||
}
|
||||
}
|
||||
export const Fragment: unique symbol;
|
||||
export type ComponentType<T = {}> = {};
|
||||
export type ComponentChild = {};
|
||||
export type ComponentChildren = {};
|
||||
export type VNode<T = {}> = {};
|
||||
export type Attributes = {};
|
||||
export type Component<T = {}, U = {}> = {};
|
||||
// @filename: /node_modules/preact/jsx-runtime/index.d.ts
|
||||
export { Fragment } from '..';
|
||||
import {
|
||||
ComponentType,
|
||||
ComponentChild,
|
||||
ComponentChildren,
|
||||
VNode,
|
||||
Attributes
|
||||
} from '..';
|
||||
import { JSXInternal } from '..';
|
||||
|
||||
export function jsx(
|
||||
type: string,
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
JSXInternal.SVGAttributes &
|
||||
Record<string, any> & { children?: ComponentChild },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
export function jsx<P>(
|
||||
type: ComponentType<P>,
|
||||
props: Attributes & P & { children?: ComponentChild },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
|
||||
|
||||
export function jsxs(
|
||||
type: string,
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
JSXInternal.SVGAttributes &
|
||||
Record<string, any> & { children?: ComponentChild[] },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
export function jsxs<P>(
|
||||
type: ComponentType<P>,
|
||||
props: Attributes & P & { children?: ComponentChild[] },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
|
||||
|
||||
export function jsxDEV(
|
||||
type: string,
|
||||
props: JSXInternal.HTMLAttributes &
|
||||
JSXInternal.SVGAttributes &
|
||||
Record<string, any> & { children?: ComponentChildren },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
export function jsxDEV<P>(
|
||||
type: ComponentType<P>,
|
||||
props: Attributes & P & { children?: ComponentChildren },
|
||||
key?: string
|
||||
): VNode<any>;
|
||||
|
||||
export import JSX = JSXInternal;
|
||||
|
||||
// @filename: /index.tsx
|
||||
export const Comp = () => <div></div>;
|
||||
16
tests/lib/react16.d.ts
vendored
16
tests/lib/react16.d.ts
vendored
@ -2566,4 +2566,18 @@ declare module "react" {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module "react/jsx-runtime" {
|
||||
import * as React from "react";
|
||||
export function jsx(...args: any): React.ReactElement<any>;
|
||||
export function jsxs(...args: any): React.ReactElement<any>;
|
||||
export import Fragment = React.Fragment;
|
||||
}
|
||||
|
||||
|
||||
declare module "react/jsx-dev-runtime" {
|
||||
import * as React from "react";
|
||||
export function jsxDEV(...args: any): React.ReactElement<any>;
|
||||
export import Fragment = React.Fragment;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user