Skip to content

Commit c993c36

Browse files
committed
Fix import clause overload and apply prettier
Switch helper_types.ts back to SyntaxKind.TypeKeyword to match google#213. Also run npm run fix:prettier to apply the requested TS/MD formatting updates.
1 parent ac132a0 commit c993c36

4 files changed

Lines changed: 20 additions & 22 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ const p: WithContext<Person> = {
5959

6060
### Merging multiple concrete types
6161

62-
Some Schema.org objects can legitimately carry multiple concrete `@type`
63-
values. For those advanced cases, `schema-dts` exports leaf types alongside the
64-
usual union aliases, plus a `MergeLeafTypes` helper for combining them:
62+
Some Schema.org objects can legitimately carry multiple concrete `@type` values.
63+
For those advanced cases, `schema-dts` exports leaf types alongside the usual
64+
union aliases, plus a `MergeLeafTypes` helper for combining them:
6565

6666
```ts
6767
import type {

packages/schema-dts-gen/src/ts/helper_types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function HelperTypes(context: Context, {hasRole}: {hasRole: boolean}) {
9999
factory.createImportDeclaration(
100100
/*modifiers=*/ [],
101101
factory.createImportClause(
102-
/*isTypeOnly=*/ true,
102+
SyntaxKind.TypeKeyword,
103103
/*name=*/ undefined,
104104
factory.createNamedImports([
105105
factory.createImportSpecifier(

packages/schema-dts-lib/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ type UnionToIntersection<T> = (
2525
? I
2626
: never;
2727

28-
type CheckLeaf<T extends LeafLike> = UnionToIntersection<T['@type']> extends never
29-
? LeafTypesError<T>
30-
: T;
28+
type CheckLeaf<T extends LeafLike> =
29+
UnionToIntersection<T['@type']> extends never ? LeafTypesError<T> : T;
3130

3231
type OmitTypeProperty<T extends LeafLike> = T extends unknown
3332
? Omit<T, '@type'>

packages/schema-dts/README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,22 @@ import type {
8282
WithContext,
8383
} from 'schema-dts';
8484

85-
const app: WithContext<
86-
MergeLeafTypes<[ProductLeaf, SoftwareApplicationLeaf]>
87-
> = {
88-
'@context': 'https://schema.org',
89-
'@type': ['Product', 'SoftwareApplication'],
90-
name: 'My App',
91-
offers: {
92-
'@type': 'Offer',
93-
price: 89,
94-
priceCurrency: 'USD',
95-
},
96-
operatingSystem: 'Any',
97-
};
85+
const app: WithContext<MergeLeafTypes<[ProductLeaf, SoftwareApplicationLeaf]>> =
86+
{
87+
'@context': 'https://schema.org',
88+
'@type': ['Product', 'SoftwareApplication'],
89+
name: 'My App',
90+
offers: {
91+
'@type': 'Offer',
92+
price: 89,
93+
priceCurrency: 'USD',
94+
},
95+
operatingSystem: 'Any',
96+
};
9897
```
9998

100-
`MergeLeafTypes` is intended for concrete leaf types like `ProductLeaf`, not
101-
for union aliases like `Product`.
99+
`MergeLeafTypes` is intended for concrete leaf types like `ProductLeaf`, not for
100+
union aliases like `Product`.
102101

103102
### Graphs and IDs
104103

0 commit comments

Comments
 (0)