Closed
Description
I want to turn off required properties check in TSX context with using skate.js http://skate.js.org/
And, I don't want to turn of type checking about properties.
cc/ @bradleyayers do you interested in this issue?
TypeScript Version: 2.0.6
Code
Reproduce code is here.
https://gist.github.com/vvakame/e7a230fa558763e225b58d57b459f64d
summary
declare global {
namespace JSX {
interface ElementAttributesProperty {
'': any;
}
}
}
declare module "skatejs" {
export class Component extends HTMLElement {
}
}
const ComponentA = skate.define("x-component-a", class ComponentA extends skate.Component {
myCounter = 0;
...
}
skate.define("x-main", class Main extends skate.Component {
render(elem: this): JSX.Element {
return (
// tsc raise a lot of errors!
// error TS2324: Property 'ATTRIBUTE_NODE' is missing in type 'ComponentA'.
// error TS2324: Property 'outerHTML' is missing in type 'ComponentA'.
// ...
// but I want a type checking...
<ComponentA myCounter={-3}></ComponentA>
);
}
...
});
other information.
/// e.g. "props" for React.d.ts,
/// or 'undefined' if ElementAttributesProperty doesn't exist (which means all
/// non-intrinsic elements' attributes type is 'any'),
/// or '' if it has 0 properties (which means every
/// non-intrinsic elements' attributes type is the element instance type)
function getJsxElementPropertiesName() {
I want to change targetAttributesType && !sawSpreadedAny
to something like... targetAttributesType && !sawSpreadedAny && !suppressRequiredPropertyCheck
.
function checkJsxOpeningLikeElement(node: JsxOpeningLikeElement) {
...
// Check that all required properties have been provided. If an 'any'
// was spreaded in, though, assume that it provided all required properties
if (targetAttributesType && !sawSpreadedAny) {
const targetProperties = getPropertiesOfType(targetAttributesType);
for (let i = 0; i < targetProperties.length; i++) {
if (!(targetProperties[i].flags & SymbolFlags.Optional) &&
!nameTable[targetProperties[i].name]) {
error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType));
}
}
}
Expected behavior:
We can compile my code.
Actual behavior:
tsc raise a lot of errors.
Metadata
Metadata
Assignees
Labels
No labels