Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Changed
- Re-enable strict type errors for `strictNullChecks`,
`useUnknownInCatchVariables`, and `strictFunctionTypes` (#357).
- Bump devDependencies (eslint 10, typescript 6, eslint-plugin-jsdoc 62, etc.).

## [2.0.2] - 2026-03-10
Expand Down
7 changes: 2 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
"declarationMap": true,
"noEmitOnError": true,
"module": "NodeNext", // Approximates browser target.
// TODO: #357: Fix strict type errors.
"noImplicitAny": false,
"strictNullChecks": false,
"useUnknownInCatchVariables": false,
"strictFunctionTypes": false
// TODO: #357: Fix implicit any types.
"noImplicitAny": false
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more left. This one is the biggie though.

}
}
16 changes: 8 additions & 8 deletions types/x-element.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ export default class XElement extends HTMLElement {
static get properties(): {
[key: string]: {
type?: (new (...args: unknown[]) => unknown) | undefined;
attribute?: string;
input?: string[];
compute?: (...args: unknown[]) => unknown;
observe?: (host: HTMLElement, value: unknown, oldValue: unknown) => any;
reflect?: boolean;
internal?: boolean;
readOnly?: boolean;
attribute?: string | undefined;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just TS being additionally verbose know that we removed one of our checks. It would only impact consumers that explicitly set exactOptionalPropertyTypes from my understanding.

input?: string[] | undefined;
compute?: ((...args: unknown[]) => unknown) | undefined;
observe?: ((host: HTMLElement, value: unknown, oldValue: unknown) => any) | undefined;
reflect?: boolean | undefined;
internal?: boolean | undefined;
readOnly?: boolean | undefined;
initial?: unknown | (() => unknown);
default?: unknown | (() => unknown);
};
Expand Down Expand Up @@ -131,7 +131,7 @@ export default class XElement extends HTMLElement {
static #validateProperties(constructor: any, properties: any, entries: any): void;
static #validateProperty(constructor: any, key: any, property: any): void;
static #validatePropertyAttribute(constructor: any, key: any, property: any, attribute: any): void;
static #propertyIsCyclic(property: any, inputMap: any, seen?: Set<any>): boolean;
static #propertyIsCyclic(property: any, inputMap: any, seen?: Set<any>): true | undefined;
static #validateListeners(constructor: any, listeners: any, entries: any): void;
static #mutateProperty(constructor: any, propertyMap: any, key: any, property: any): void;
static #addPropertyInitial(constructor: any, property: any): void;
Expand Down
2 changes: 1 addition & 1 deletion types/x-element.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions types/x-parser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export class XParser {
static #boundAttributeMalformed: RegExp;
static #boundPropertyMalformed: RegExp;
static #danglingQuoteMalformed: RegExp;
static #getErrorMessage(key: any): "Could not parse template markup (at template start)." | "Could not parse template markup (after text content)." | "Could not parse template markup (after a comment)." | "Could not parse template markup (after interpolated content)." | "Could not parse template markup (after a spacing within start tag)." | "Could not parse template markup (after a start tag)." | "Could not parse template markup (after a boolean attribute interpolation in a start tag)." | "Could not parse template markup (after a defined attribute interpolation in a start tag)." | "Could not parse template markup (after an attribute interpolation in a start tag)." | "Could not parse template markup (after a property interpolation in a start tag)." | "Could not parse template markup (after an end tag)." | "Invalid tag name - refer to https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/define#valid_custom_element_names)." | "Invalid tag whitespace (extraneous whitespace in start tag)." | "Invalid start tag (extraneous whitespace at close of start tag)." | "Invalid end tag." | "Invalid tag attribute (must use kebab-case names and double-quoted values)." | "Invalid tag attribute interpolation (must use kebab-case names and double-quoted values)." | "Invalid tag property interpolation (must use kebab-case names and double-quoted values)." | "Invalid closing quote on tag attribute or property." | "CDATA sections are not supported. Use character references instead: https://developer.mozilla.org/en-US/docs/Glossary/Character_reference." | "Bad escape in tagged template string. Use “&bsol;” for “\\”, “&dollar;” for “\\$”, and “&grave;” for “\\`”. All character references are supported: https://developer.mozilla.org/en-US/docs/Glossary/Character_reference." | "Ambiguous ampersand character or invalid hexadecimal character reference." | "Invalid comment. Comments cannot start with “>” or “->” characters, they cannot include a set of “--” characters, and they cannot end with a “-” character." | "Unsupported native tag - supported native tags are listed here: https://github.com/Netflix/x-element/blob/main/doc/TEMPLATES.md#supported-native-tags." | "Invalid end tag (all non-void start tags much have matching end tags)." | "Unsupported <textarea> interpolation. Interpolation must be exact (<textarea>${…}</textarea>)." | "Unsupported declarative shadow root on <template>. The “shadowrootmode” attribute is not supported." | "Missing closing quote on bound attribute or property.";
static #getErrorMessageKeyFromValue(value: any): "#100" | "#101" | "#102" | "#103" | "#104" | "#105" | "#106" | "#107" | "#108" | "#109" | "#110";
static #getErrorMessageKeyFromValueMalformed(valueMalformed: any): "#120" | "#121" | "#122" | "#123" | "#124" | "#125" | "#126" | "#127";
static #getErrorMessageKeyFromValueForbidden(valueForbidden: any): string;
static #getErrorMessageKeyFromErrorName(errorName: any): "#150" | "#151" | "#152" | "#153" | "#154" | "#155" | "#156" | "#157";
static #getErrorMessage(key: any): "Could not parse template markup (at template start)." | "Could not parse template markup (after text content)." | "Could not parse template markup (after a comment)." | "Could not parse template markup (after interpolated content)." | "Could not parse template markup (after a spacing within start tag)." | "Could not parse template markup (after a start tag)." | "Could not parse template markup (after a boolean attribute interpolation in a start tag)." | "Could not parse template markup (after a defined attribute interpolation in a start tag)." | "Could not parse template markup (after an attribute interpolation in a start tag)." | "Could not parse template markup (after a property interpolation in a start tag)." | "Could not parse template markup (after an end tag)." | "Invalid tag name - refer to https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/define#valid_custom_element_names)." | "Invalid tag whitespace (extraneous whitespace in start tag)." | "Invalid start tag (extraneous whitespace at close of start tag)." | "Invalid end tag." | "Invalid tag attribute (must use kebab-case names and double-quoted values)." | "Invalid tag attribute interpolation (must use kebab-case names and double-quoted values)." | "Invalid tag property interpolation (must use kebab-case names and double-quoted values)." | "Invalid closing quote on tag attribute or property." | "CDATA sections are not supported. Use character references instead: https://developer.mozilla.org/en-US/docs/Glossary/Character_reference." | "Bad escape in tagged template string. Use “&bsol;” for “\\”, “&dollar;” for “\\$”, and “&grave;” for “\\`”. All character references are supported: https://developer.mozilla.org/en-US/docs/Glossary/Character_reference." | "Ambiguous ampersand character or invalid hexadecimal character reference." | "Invalid comment. Comments cannot start with “>” or “->” characters, they cannot include a set of “--” characters, and they cannot end with a “-” character." | "Unsupported native tag - supported native tags are listed here: https://github.com/Netflix/x-element/blob/main/doc/TEMPLATES.md#supported-native-tags." | "Invalid end tag (all non-void start tags much have matching end tags)." | "Unsupported <textarea> interpolation. Interpolation must be exact (<textarea>${…}</textarea>)." | "Unsupported declarative shadow root on <template>. The “shadowrootmode” attribute is not supported." | "Missing closing quote on bound attribute or property." | undefined;
static #getErrorMessageKeyFromValue(value: any): "#100" | "#101" | "#102" | "#103" | "#104" | "#105" | "#106" | "#107" | "#108" | "#109" | "#110" | undefined;
static #getErrorMessageKeyFromValueMalformed(valueMalformed: any): "#120" | "#121" | "#122" | "#123" | "#124" | "#125" | "#126" | "#127" | undefined;
static #getErrorMessageKeyFromValueForbidden(valueForbidden: any): "#140" | undefined;
static #getErrorMessageKeyFromErrorName(errorName: any): "#150" | "#151" | "#152" | "#153" | "#154" | "#155" | "#156" | "#157" | undefined;
static #try(string: any, stringIndex: any, ...values: any[]): any;
static #forbiddenTransition(string: any, stringIndex: any, value: any): any;
static #invalidTransition(string: any, stringIndex: any, value: any): any;
Expand Down
2 changes: 1 addition & 1 deletion types/x-parser.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions types/x-template.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const render: (...args: unknown[]) => unknown;
export const html: (...args: unknown[]) => unknown;
export const render: (container: HTMLElement, rawResult: unknown) => void;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually correct now.

export const html: (strings: string[], ...values: unknown[]) => unknown;
//# sourceMappingURL=x-template.d.ts.map
2 changes: 1 addition & 1 deletion types/x-template.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 14 additions & 5 deletions x-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,13 @@ export class XParser {
break;
}
}
stringIndex = nextStringIndex; // Update out pointer from our pattern match.
// Cast: nextStringIndex is guaranteed non-null here — it’s always
// set from a regex match (value.lastIndex) before reaching this
// point. TypeScript cannot prove this because the assignment happens
// inside a switch-case that doesn’t cover every value of
// nextStringIndex’s type. A zero-cost cast is preferred over a
// runtime guard in this hot loop.
stringIndex = /** @type {number} */ (nextStringIndex); // Update out pointer from our pattern match.
nextStringIndex = null;
}
stringsIndex++;
Expand All @@ -1078,10 +1084,13 @@ export class XParser {
XParser.#validateExit(value, tagName);
} catch (error) {
// Roughly match the conventions for “onToken”.
const index = stringsIndex;
const start = stringIndex;
const end = nextStringIndex;
error[XParser.#errorContextKey] = { index, start, end };
if (typeof error === 'object' && error !== null) {
// Narrow from "unknown" to attach debug context via Object.assign.
const index = stringsIndex;
const start = stringIndex;
const end = nextStringIndex;
Object.assign(error, { [XParser.#errorContextKey]: { index, start, end } });
}
throw error;
}
}
Expand Down
2 changes: 1 addition & 1 deletion x-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TemplateEngine {

/**
* Default template engine interface — what you get inside “template”.
* @type {{[key: string]: (...args: unknown[]) => unknown}}
* @type {{ render: (container: HTMLElement, rawResult: unknown) => void, html: (strings: string[], ...values: unknown[]) => unknown }}
*/
static interface = Object.freeze({
render: TemplateEngine.render,
Expand Down