-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat: allow free function exports in typewriter #1379
Merged
Merged
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
bca3e72
exported...
comcalvi 15925ef
tests
comcalvi 32e06e4
comment
comcalvi 873540c
Merge branch 'main' of github.com:cdklabs/awscdk-service-spec into co…
comcalvi b336c0a
build
comcalvi 985b7f1
empty
comcalvi b306d7d
un-empty
comcalvi 5416526
npx projen default generates a diff, but npx projen build doesn't, be…
comcalvi 2bd9ea1
Merge branch 'main' of github.com:cdklabs/awscdk-service-spec into co…
comcalvi 34c5688
projen
comcalvi cbb9fe9
chore: self mutation
invalid-email-address 3983ca9
exports
comcalvi 87cb07d
Merge branch 'comcalvi/function-exports' of github.com:cdklabs/awscdk…
comcalvi c8e7e2d
Merge branch 'main' of github.com:cdklabs/awscdk-service-spec into co…
comcalvi 02245c9
woot woot
comcalvi 4b4c23a
types!
comcalvi 35d2c20
f
comcalvi 3c74ed7
woops
comcalvi a88c9d0
woops2
comcalvi e85bd19
import order
comcalvi c507847
chore: self mutation
invalid-email-address 1439f78
Update packages/@cdklabs/typewriter/src/type-declaration.ts
mrgrain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { FreeFunction, Module, TypeScriptRenderer } from '../src'; | ||
|
||
const renderer = new TypeScriptRenderer(); | ||
let scope: Module; | ||
|
||
beforeEach(() => { | ||
scope = new Module('typewriter.test'); | ||
}); | ||
|
||
describe('functions', () => { | ||
test('functions are implicitly not exported', () => { | ||
new FreeFunction(scope, { | ||
name: 'freeFunction', | ||
}); | ||
|
||
expect(renderer.render(scope)).toMatchInlineSnapshot(` | ||
"/* eslint-disable prettier/prettier,max-len */ | ||
// @ts-ignore TS6133 | ||
function freeFunction(): void;" | ||
`); | ||
}); | ||
|
||
test('functions can be explicitly exported', () => { | ||
new FreeFunction(scope, { | ||
name: 'freeFunction', | ||
export: true, | ||
}); | ||
|
||
expect(renderer.render(scope)).toMatchInlineSnapshot(` | ||
"/* eslint-disable prettier/prettier,max-len */ | ||
// @ts-ignore TS6133 | ||
export function freeFunction(): void;" | ||
`); | ||
}); | ||
|
||
test('functions can be explicitly not exported', () => { | ||
new FreeFunction(scope, { | ||
name: 'freeFunction', | ||
export: false, | ||
}); | ||
|
||
expect(renderer.render(scope)).toMatchInlineSnapshot(` | ||
"/* eslint-disable prettier/prettier,max-len */ | ||
// @ts-ignore TS6133 | ||
function freeFunction(): void;" | ||
`); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is correct, we want to accept all
CallableDeclarations
not, just the ones that are also aTypeDeclaration
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we keep the signature as it is.
Then w can have a guard
isExported(x): is { exported: true } { ... }
to check ifexported
exists and is true.