Skip to content

Commit

Permalink
fix assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
roni-frantchi committed May 19, 2022
1 parent 288e7a3 commit 533f8b9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "env0-ts-transform-json-schema",
"version": "2.0.15",
"version": "2.0.16",
"description": "Generate inline JSON schema from TypeScript types",
"files": [
"lib",
Expand Down
6 changes: 3 additions & 3 deletions src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ export const getTransformer = (program: ts.Program) => {
if (!generator) {
const tsconfig = program.getCompilerOptions().configFilePath as string;
const projectApi = tsconfig.replace('tsconfig.json', 'api.d.ts');
const hasApiFile = program.getSourceFiles().map(f => f.fileName).includes(projectApi);

if (!hasApiFile) throw 'Project must have an api.d.ts file that includes the type'

config = {
path: projectApi,
Expand Down Expand Up @@ -70,6 +67,9 @@ export const getTransformer = (program: ts.Program) => {
throw new Error(`Could not find symbol for passed type`);
}

const hasApiFile = program.getSourceFiles().map(f => f.fileName).includes(config.path);
if (!hasApiFile) throw 'Project must have an api.d.ts file that includes the type'

// @ts-ignore typeName exists in real but not on the type
const namespacedTypeName = getFullyQualifiedTypeName(typeArgument.typeName);

Expand Down

0 comments on commit 533f8b9

Please sign in to comment.