esrap 2.2.5 → 2.2.6

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esrap",
3
- "version": "2.2.5",
3
+ "version": "2.2.6",
4
4
  "description": "Parse in reverse",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1848,19 +1848,28 @@ export default (options = {}) => {
1848
1848
  TSMappedType(node, context) {
1849
1849
  context.write('{[');
1850
1850
 
1851
- if (node.typeParameter) {
1852
- context.visit(node.typeParameter);
1851
+ const legacy_type_parameter = node.typeParameter;
1852
+ const key = node.key ?? legacy_type_parameter?.name;
1853
+ const constraint = node.constraint ?? legacy_type_parameter?.constraint;
1854
+
1855
+ if (key && typeof key === 'object') {
1856
+ context.visit(key);
1853
1857
  } else {
1854
- context.visit(node.key);
1858
+ context.write(key, node);
1859
+ }
1860
+
1861
+ if (constraint) {
1855
1862
  context.write(' in ');
1856
- context.visit(node.constraint);
1863
+ context.visit(constraint);
1857
1864
  }
1858
1865
 
1859
1866
  context.write(']');
1867
+
1860
1868
  if (node.typeAnnotation) {
1861
1869
  context.write(': ');
1862
1870
  context.visit(node.typeAnnotation);
1863
1871
  }
1872
+
1864
1873
  context.write('}');
1865
1874
  },
1866
1875
 
@@ -2019,9 +2028,15 @@ export default (options = {}) => {
2019
2028
 
2020
2029
  TSModuleDeclaration(node, context) {
2021
2030
  if (node.declare) context.write('declare ');
2022
- else context.write('namespace ');
2023
2031
 
2024
- context.visit(node.id);
2032
+ if (node.global) {
2033
+ context.write('global', node.id);
2034
+ } else {
2035
+ // @ts-expect-error `acorn-typescript` and `@typescript-eslint/types` have slightly different type definitions
2036
+ const kind = node.kind ?? (node.id.type === 'Literal' ? 'module' : 'namespace');
2037
+ context.write(kind + ' ');
2038
+ context.visit(node.id);
2039
+ }
2025
2040
 
2026
2041
  if (!node.body) return;
2027
2042
  context.visit(node.body);