-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
svelte-kit package: Generate type definitions #1646
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
Merged
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
69948d9
svelte-kit package: Generate type definitions
f33dcd5
only create types for lib + packagejson field
0f95426
use new svelte2tsx which handles dts transformation internally
87acbbf
fix validation: return option, not omit it
e5704ac
add types option
47bbda1
bump svelte-check
35b28f8
make . the default for types
0766165
fix tests
4ba1d53
fix tests
dummdidumm a0d08ed
lint
dummdidumm c5d9a25
changeset
83dde9d
fix packagejson types field
cf9c298
split types option in two
e1f0258
docs
a14619d
fix tests
be8dc9c
Update documentation/docs/14-configuration.md
dummdidumm 86a3a66
wording
dummdidumm 4e743eb
docs cleanup
dummdidumm b8adea5
Merge branch 'master' into package-type-defs
dc127ea
rename, bump svelte2tsx
2fa060b
Merge branch 'master' into package-type-defs
Rich-Harris a8d5edc
doing blind commits on the phone
dummdidumm 0f11b53
ok, laptop it is
a8842f6
Merge branch 'master' into package-type-defs
e7f3929
remove types option
9937137
fix generation of JSdoc->dts
7e0d3f6
do type generation first
bf250b4
add tests, fix uncovered bugs
1f67bf9
ignore test folder for eslint
b018c95
ignore
4d2d72f
remove optional chaining
8692afd
wtf these ordering problems
a3190dd
bye bye nullish coalescing
c859d69
Add warning when file will be overwritten
ccf76c9
Merge branch 'package-type-defs' of github.com:sveltejs/kit into pack…
Rich-Harris 5e278b1
force some compileroptions, now jsconfig works, too
7aa7108
moved emitDts functionality into svelte2tsx, adjust accordingly
24768fb
update config.md
22c57ca
cleanup
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 hidden or 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,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
Add types generation to svelte-kit package command |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
12 changes: 12 additions & 0 deletions
12
packages/kit/src/core/make_package/test/fixtures/javascript/expected/Test.svelte
This file contains hidden or 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,12 @@ | ||
<script> | ||
import { createEventDispatcher } from 'svelte'; | ||
/** | ||
* @type {string} | ||
*/ | ||
export const astring; | ||
|
||
const dispatch = createEventDispatcher(); | ||
dispatch('event', true); | ||
</script> | ||
|
||
<slot {astring} /> |
40 changes: 40 additions & 0 deletions
40
packages/kit/src/core/make_package/test/fixtures/javascript/expected/Test.svelte.d.ts
This file contains hidden or 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,40 @@ | ||
/** @typedef {typeof __propDef.props} TestProps */ | ||
/** @typedef {typeof __propDef.events} TestEvents */ | ||
/** @typedef {typeof __propDef.slots} TestSlots */ | ||
export default class Test extends SvelteComponentTyped< | ||
{ | ||
astring: string; | ||
}, | ||
{ | ||
event: CustomEvent<any>; | ||
} & { | ||
[evt: string]: CustomEvent<any>; | ||
}, | ||
{ | ||
default: { | ||
astring: string; | ||
}; | ||
} | ||
> { | ||
get astring(): string; | ||
} | ||
export type TestProps = typeof __propDef.props; | ||
export type TestEvents = typeof __propDef.events; | ||
export type TestSlots = typeof __propDef.slots; | ||
import { SvelteComponentTyped } from 'svelte'; | ||
declare const __propDef: { | ||
props: { | ||
astring: string; | ||
}; | ||
events: { | ||
event: CustomEvent<any>; | ||
} & { | ||
[evt: string]: CustomEvent<any>; | ||
}; | ||
slots: { | ||
default: { | ||
astring: string; | ||
}; | ||
}; | ||
}; | ||
export {}; |
6 changes: 6 additions & 0 deletions
6
packages/kit/src/core/make_package/test/fixtures/javascript/expected/Test2.svelte
This file contains hidden or 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,6 @@ | ||
<script> | ||
/** | ||
* @type {import('./foo').Foo} | ||
*/ | ||
export let foo; | ||
</script> |
26 changes: 26 additions & 0 deletions
26
packages/kit/src/core/make_package/test/fixtures/javascript/expected/Test2.svelte.d.ts
This file contains hidden or 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,26 @@ | ||
/** @typedef {typeof __propDef.props} Test2Props */ | ||
/** @typedef {typeof __propDef.events} Test2Events */ | ||
/** @typedef {typeof __propDef.slots} Test2Slots */ | ||
export default class Test2 extends SvelteComponentTyped< | ||
{ | ||
foo: boolean; | ||
}, | ||
{ | ||
[evt: string]: CustomEvent<any>; | ||
}, | ||
{} | ||
> {} | ||
export type Test2Props = typeof __propDef.props; | ||
export type Test2Events = typeof __propDef.events; | ||
export type Test2Slots = typeof __propDef.slots; | ||
import { SvelteComponentTyped } from 'svelte'; | ||
declare const __propDef: { | ||
props: { | ||
foo: import('./foo').Foo; | ||
}; | ||
events: { | ||
[evt: string]: CustomEvent<any>; | ||
}; | ||
slots: {}; | ||
}; | ||
export {}; |
1 change: 1 addition & 0 deletions
1
packages/kit/src/core/make_package/test/fixtures/javascript/expected/foo.d.ts
This file contains hidden or 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 @@ | ||
export type Foo = boolean; |
1 change: 1 addition & 0 deletions
1
packages/kit/src/core/make_package/test/fixtures/javascript/expected/index.d.ts
This file contains hidden or 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 @@ | ||
export { default as Test } from './Test.svelte'; |
1 change: 1 addition & 0 deletions
1
packages/kit/src/core/make_package/test/fixtures/javascript/expected/index.js
This file contains hidden or 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 @@ | ||
export { default as Test } from './Test.svelte'; |
13 changes: 13 additions & 0 deletions
13
packages/kit/src/core/make_package/test/fixtures/javascript/expected/package.json
This file contains hidden or 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,13 @@ | ||
{ | ||
"name": "javascript", | ||
"version": "1.0.0", | ||
"description": "package-javascript-test", | ||
"type": "module", | ||
"exports": { | ||
"./package.json": "./package.json", | ||
"./index.js": "./index.js", | ||
"./Test.svelte": "./Test.svelte", | ||
"./Test2.svelte": "./Test2.svelte", | ||
".": "./index.js" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/kit/src/core/make_package/test/fixtures/javascript/jsconfig.json
This file contains hidden or 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,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"checkJs": true, | ||
"paths": { | ||
"$lib/*": ["src/lib/*"] | ||
} | ||
}, | ||
"include": ["src/**/*.d.ts", "src/**/*.js", "src/**/*.svelte"] | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/kit/src/core/make_package/test/fixtures/javascript/package.json
This file contains hidden or 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,5 @@ | ||
{ | ||
"name": "javascript", | ||
"version": "1.0.0", | ||
"description": "package-javascript-test" | ||
} |
12 changes: 12 additions & 0 deletions
12
packages/kit/src/core/make_package/test/fixtures/javascript/src/app.html
This file contains hidden or 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,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
%svelte.head% | ||
</head> | ||
<body> | ||
<div id="svelte">%svelte.body%</div> | ||
</body> | ||
</html> |
12 changes: 12 additions & 0 deletions
12
packages/kit/src/core/make_package/test/fixtures/javascript/src/lib/Test.svelte
This file contains hidden or 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,12 @@ | ||
<script> | ||
import { createEventDispatcher } from 'svelte'; | ||
/** | ||
* @type {string} | ||
*/ | ||
export const astring; | ||
|
||
const dispatch = createEventDispatcher(); | ||
dispatch('event', true); | ||
</script> | ||
|
||
<slot {astring} /> |
6 changes: 6 additions & 0 deletions
6
packages/kit/src/core/make_package/test/fixtures/javascript/src/lib/Test2.svelte
This file contains hidden or 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,6 @@ | ||
<script> | ||
/** | ||
* @type {import('./foo').Foo} | ||
*/ | ||
export let foo; | ||
</script> |
1 change: 1 addition & 0 deletions
1
packages/kit/src/core/make_package/test/fixtures/javascript/src/lib/foo.d.ts
This file contains hidden or 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 @@ | ||
export type Foo = boolean; |
1 change: 1 addition & 0 deletions
1
packages/kit/src/core/make_package/test/fixtures/javascript/src/lib/index.js
This file contains hidden or 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 @@ | ||
export { default as Test } from './Test.svelte'; |
Empty file.
8 changes: 8 additions & 0 deletions
8
packages/kit/src/core/make_package/test/fixtures/typescript/expected/Test.svelte
This file contains hidden or 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,8 @@ | ||
<script lang="ts"> | ||
import { createEventDispatcher } from 'svelte'; | ||
export const astring; | ||
const dispatch = createEventDispatcher(); | ||
dispatch('event', true); | ||
</script> | ||
|
||
<slot {astring} /> |
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.
Uh oh!
There was an error while loading. Please reload this page.