@tsrx/core 0.1.38 → 0.1.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Core compiler infrastructure for TSRX syntax",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.1.38",
6
+ "version": "0.1.40",
7
7
  "type": "module",
8
8
  "repository": {
9
9
  "type": "git",
package/src/plugin.js CHANGED
@@ -1000,13 +1000,15 @@ export function TSRXPlugin(config) {
1000
1000
  // following raw text belongs to an enclosing template, not to it. With no
1001
1001
  // enclosing template (e.g. a top-level `return <div />`), the trailing
1002
1002
  // text is plain JS and must not be read as template raw text.
1003
+ // Inter-token whitespace has already advanced `pos`; `lastTokEnd` still
1004
+ // identifies the consumed `/>` boundary.
1003
1005
  const opening = this.#openingNativeTemplateNode;
1004
1006
  if (
1005
1007
  opening &&
1006
1008
  current_template_node === opening &&
1007
1009
  /** @type {any} */ (opening).openingElement?.selfClosing &&
1008
- this.input.charCodeAt(this.pos - 1) === CharCode.greaterThan &&
1009
- this.input.charCodeAt(this.pos - 2) === CharCode.slash
1010
+ this.input.charCodeAt(this.lastTokEnd - 1) === CharCode.greaterThan &&
1011
+ this.input.charCodeAt(this.lastTokEnd - 2) === CharCode.slash
1010
1012
  ) {
1011
1013
  const enclosing = this.#path.findLast(
1012
1014
  (node) => node !== opening && this.#isNativeTemplateNode(node),
@@ -185,6 +185,16 @@ export function tsx_with_ts_locations() {
185
185
  }
186
186
  context.write('>');
187
187
  },
188
+ // esrap's TSExpressionWithTypeArguments printer only emits `expression`,
189
+ // dropping interface heritage arguments such as the `<T>` in
190
+ // `interface Foo<T> extends Bar<T> {}`. Besides changing the declaration's
191
+ // semantics, that leaves segments.js unable to map the omitted node.
192
+ TSExpressionWithTypeArguments: (node, context) => {
193
+ context.visit(node.expression);
194
+ if (node.typeParameters) {
195
+ context.visit(node.typeParameters);
196
+ }
197
+ },
188
198
  TSModuleDeclaration: (node, context) => {
189
199
  context.write(node.metadata?.module_keyword ?? 'module');
190
200
  context.write(' ');