Skip to content

Commit 9a38983

Browse files
committed
remove schema-export.js, rename schema to .d.ts
1 parent 7cd7cde commit 9a38983

File tree

6 files changed

+8
-25
lines changed

6 files changed

+8
-25
lines changed

packages/mql-typescript/out/schema-export.js

Lines changed: 0 additions & 2 deletions
This file was deleted.
File renamed without changes.

packages/mql-typescript/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
"license": "Apache-2.0",
2929
"main": "dist/index.js",
3030
"exports": {
31-
"require": "./dist/index.js",
32-
"import": "./dist/.esm-wrapper.mjs"
31+
"./schema": {
32+
"types": "./dist/schema/schema.d.ts"
33+
}
3334
},
3435
"types": "./dist/index.d.ts",
3536
"scripts": {

packages/mql-typescript/src/schema-generator.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type { YamlFiles } from './generator';
33
import { GeneratorBase } from './generator';
44
import { Operator } from './metaschema';
55
import { capitalize } from './utils';
6-
import * as fs from 'fs/promises';
76

87
type ArgType = NonNullable<
98
typeof Operator._type.arguments
@@ -14,12 +13,11 @@ type SyntheticVariables = NonNullable<
1413
>[number]['syntheticVariables'];
1514

1615
export class SchemaGenerator extends GeneratorBase {
17-
private schemaOutputFile = path.resolve(__dirname, '..', 'out', 'schema.ts');
18-
private schemaExportFile = path.resolve(
16+
private schemaOutputFile = path.resolve(
1917
__dirname,
2018
'..',
2119
'out',
22-
'schema-export.js',
20+
'schema.d.ts',
2321
);
2422

2523
private toTypeName(type: string): string {
@@ -579,19 +577,5 @@ export class SchemaGenerator extends GeneratorBase {
579577
} = ${[...new Set(interfaces)].join('|')};`,
580578
);
581579
}
582-
583-
// Generate the schema-export.js which will be used by the autocomplete package to load the types
584-
// Switch to the new file that will just export the types as a giant string:
585-
// exports.schema = "** contents of the out/schema.ts file **";
586-
await this.emitToFile(this.schemaExportFile);
587-
const schemaDefinition = await fs.readFile(this.schemaOutputFile, 'utf8');
588-
this.emit("exports.schema = '");
589-
this.emit(
590-
schemaDefinition
591-
.replace(/\\/g, '\\\\') // Escape backslashes
592-
.replace(/'/g, "\\'") // Escape double quotes
593-
.replace(/\n/g, '\\n'), // Escape newlines
594-
);
595-
this.emit("'\n");
596580
}
597581
}

packages/mql-typescript/tests/expression/regexFindAll.spec.ts

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)