Prerequisites
Versions
4.2.0, 4.2.1
Description
I am having this same issue for 4.2.0 and 4.2.1 using express and node in any tsx file in my project.
example:
type LinkProps = { class: string } &
(
| {
'hx-get': string;
}
| {
href: string;
}
);
export function Link({
class: className,
children,
...rest
}: Html.PropsWithChildren<LinkProps>) {
const props =
`href` in rest
? { ...rest, target: '_blank', rel: 'noopener noreferrer' }
: rest;
const ourClass = className ? className : 'link';
return (
<a class={ourClass} {...props}>
{children}
</a>
);
}
Error at Html reported by typescript:
Cannot find namespace 'Html'.ts(2503)
⚠ Error(TS2503) |
Cannot find namespace Html .
Error at {children}
Usage of xss-prone content without `safe` attribute. https://kitajs.github.io/ts-html-plugin#k601ts(0 K601)
⚠ Error
Usage of xss-prone content without `safe` attribute. https://kitajs.github.io/ts-html-plugin#k601
(parameter) children: Html.PropsWithChildren<LinkProps>
Steps to Reproduce
Create a project
mkdir nsamespace-bug
cd namespace-bug
touch index.tsx
touch tsconfig.json
npm init -y # ... your choices
npm i -E typescript@5.5.4 @kitajs/html@4.2.1 @kitajs/ts-html-plugin@4.0.2
type LinkProps = { class: string } & (
| {
"hx-get": string;
}
| {
href: string;
}
);
export function Link({
class: className,
children,
...rest
}: Html.PropsWithChildren<LinkProps>) {
const props =
`href` in rest
? { ...rest, target: "_blank", rel: "noopener noreferrer" }
: rest;
const ourClass = className ? className : "link";
return (
<a class={ourClass} {...props}>
{children}
</a>
);
}
{
"compilerOptions": {
"strict": true,
"strictNullChecks": true,
"module": "commonjs",
"declaration": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"target": "ES2021",
"outDir": "./dist",
"baseUrl": "./",
"skipLibCheck": true,
"jsx": "react-jsx",
"jsxImportSource": "@kitajs/html",
"plugins": [{ "name": "@kitajs/ts-html-plugin" }]
}
}
Expected Behavior
Namespace should be recognized in the file as it is if you install @kitajs/html@4.1.0
Prerequisites
Versions
4.2.0, 4.2.1
Description
I am having this same issue for 4.2.0 and 4.2.1 using express and node in any
tsxfile in my project.example:
Error at Html reported by typescript:
Error at
{children}Steps to Reproduce
Create a project
{ "compilerOptions": { "strict": true, "strictNullChecks": true, "module": "commonjs", "declaration": true, "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, "target": "ES2021", "outDir": "./dist", "baseUrl": "./", "skipLibCheck": true, "jsx": "react-jsx", "jsxImportSource": "@kitajs/html", "plugins": [{ "name": "@kitajs/ts-html-plugin" }] } }Expected Behavior
Namespace should be recognized in the file as it is if you install
@kitajs/html@4.1.0