Comments (5)
On the other hand, I just found out that renamed exports are not documented. If I have
let _class = null;
export { _class as class };
for example (which I do have in many components), neither _class
nor class
make it to the generated declaration file.
from sveld.
This is a blocker for me as well right now 👍🏻
But for me it is exporting an object containing functions.
/** @type {AccountCreateActions} */
export const actions = {
create: async (email, password, name = "") => {
try {
const response = await Appwrite.sdk.account.create(
email,
password,
name
);
dispatch("success", response);
return response;
} catch (error) {
dispatch("failure", error);
}
},
};
is generated into:
export interface CreateProps {
/**
* @constant
* @default { create: async (email, password, name = "") => { try { const response = await Appwrite.sdk.account.create( email, password, name ); dispatch("success", response); return response; } catch (error) { dispatch("failure", error); } }, }
*/
actions?: { create: async (email, password, name = "") => { try { const response = await Appwrite.sdk.account.create( email, password, name ); dispatch("success", response); return response; } catch (error) { dispatch("failure", error); } }, };
}
Using export let actions
makes it generate valid definitions und uses my @typedef
at least, but still sets the wrong @default
notation.
export interface AccountCreateActions {
actions: {
create: (email: string, password: string, name?: string) => Promise<object>;
};
}
export interface CreateProps {
/**
* @default { create: async (email, password, name = "") => { try { const response = await Appwrite.sdk.account.create( email, password, name ); dispatch("success", response); return response; } catch (error) { dispatch("failure", error); } }, }
*/
actions?: AccountCreateActions;
}
from sveld.
in v0.8.1, function declarations are now typed as accessors on the SvelteComponentTyped interface.
Input
<script>
export let fnA = () => {};
export const fnB = () => {};
export function add(a, b) {
return a + b;
}
/**
* Multiplies two numbers
* @type {(a: number, b: number) => number}
*/
export function multiply(a, b) {
return a * b;
}
</script>
<h1 on:click={fnA}>Heading</h1>
Output
/// <reference types="svelte" />
import { SvelteComponentTyped } from "svelte";
export interface InputProps {
/**
* @default () => {}
*/
fnA?: () => {};
/**
* @constant
* @default () => {}
*/
fnB?: () => {};
}
export default class Input extends SvelteComponentTyped<InputProps, {}, {}> {
add: () => any;
/**
* Multiplies two numbers
*/
multiply: (a: number, b: number) => number;
}
from sveld.
Great! I can confirm that the exported function is now treated as an accessor, but for some reason it still emits a @default
annotation for it that contains the full implementation of the function, as outlined in the original comment on this issue.
from sveld.
@aabounegm The @default
comment notation is omitted in v0.9.0
from sveld.
Related Issues (20)
- @slot and @event description bugs HOT 11
- Type definitions for setContext
- ComponentParser: Cannot read properties of null (reading 'type')
- Allow specifying an entry point in programmatic usage
- Svelte #8512 PR Compatability HOT 1
- event description/detail?
- Copy Component-level doc comments to generated definitions HOT 1
- Type annotations for module="context" scripts exports HOT 3
- SvelteKit Support (Vite compatibility?) HOT 9
- When generating d.ts, is it possible to export Props as well?
- Generated `filePath` in API is platform dependent HOT 2
- Support programmatic usage
- Configure output folder where sveld outputs the type definitions HOT 2
- Use type-only imports in generated TypeScript files
- Default slot name should be `null`
- Type definition for exported module functions is incorrect HOT 2
- Unable to use .glob option HOT 1
- `sveltekit:` attributes replaced with valid HTML data attributes
- Grabbing other tags HOT 2
- //ts-ignore after JSDoc block wipes out description on entity
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sveld.