Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose named export (fix TypeScript>=4.8 with native ESM) #207

Merged
merged 3 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ Schema generated:

## TypeScript

### CommonJS

With `"esModuleInterop": true` activated in the `tsconfig.json`:

```typescript
Expand All @@ -153,6 +155,19 @@ const schema = S.object()
.valueOf()
```

### ESM

A named export is also available to work with native ESM modules:

```typescript
import { S } from 'fluent-json-schema'

const schema = S.object()
.prop('foo', S.string())
.prop('bar', S.number())
.valueOf()
```

## Validation

Fluent schema **does not** validate a JSON schema. However, many libraries can do that for you.
Expand Down
1 change: 1 addition & 0 deletions src/FluentJSONSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,4 @@ const fluentSchema = {
}
module.exports = fluentSchema
module.exports.default = fluentSchema
module.exports.S = fluentSchema
5 changes: 3 additions & 2 deletions types/FluentJSONSchema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,5 +256,6 @@ export interface S extends BaseSchema<S> {
FORMATS: FORMATS
}

declare var s: S
export default s
export declare var S: S

export default S