Skip to content

Commit

Permalink
Restrict strict notation to type literals
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienGllmt committed Apr 19, 2021
1 parent 90aa2da commit aad331a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/__tests__/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,25 @@ it("should handle basic keywords", () => {
expect(result).toBeValidFlowTypeDeclarations();
}
});

it("should handle class types", () => {
const ts = `
declare export class Foo {
}`;

{
const result = compiler.compileDefinitionString(ts, { quiet: true });
expect(beautify(result)).toMatchSnapshot();
expect(result).toBeValidFlowTypeDeclarations();
}

{
const result = compiler.compileDefinitionString(ts, {
quiet: true,
inexact: false,
});
expect(beautify(result)).toMatchSnapshot();
expect(result).toBeValidFlowTypeDeclarations();
}
});

2 changes: 1 addition & 1 deletion src/printers/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const interfaceType = <T>(
.filter(Boolean) // Filter rows which didn't print properly (private fields et al)
.join(withSemicolons ? ";" : ",");

return isInexact
return isInexact || !ts.isTypeLiteralNode(node)
? `{${inner}}`
: `{|${inner}|}`;
};
Expand Down

0 comments on commit aad331a

Please sign in to comment.