Coder Social home page Coder Social logo

Comments (5)

aabounegm avatar aabounegm commented on May 28, 2024

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.

TorstenDittmann avatar TorstenDittmann commented on May 28, 2024

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.

metonym avatar metonym commented on May 28, 2024

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.

aabounegm avatar aabounegm commented on May 28, 2024

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.

metonym avatar metonym commented on May 28, 2024

@aabounegm The @default comment notation is omitted in v0.9.0

from sveld.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.