Giter VIP home page Giter VIP logo

Comments (8)

patrickjuchli avatar patrickjuchli commented on May 19, 2024 2

There is no elegant way to solve this except by rewriting the library in Typescript. Typescript doesn't let users use JSDoc when using Typescript. Conversion tools exist but they are either not maintained well or don't work well enough.

This is not as crazy as it sounds because everything is already strictly typed using JSDoc. Should be straightforward, let's go this way, work has already started.

from basic-ftp.

patrickjuchli avatar patrickjuchli commented on May 19, 2024

The source itself defines types using JSDoc sufficiently to satisfy even strict and noImplicitAny compiler settings. In VSCode, just using checkJs with a regular Javascript project works well.

But I haven't tested this with an actual Typescript project. I will have a look but I want to make it work using JSDoc only.

from basic-ftp.

AnsonYeung avatar AnsonYeung commented on May 19, 2024

It is actually written in JS. I am not able to use the types correctly in JSDoc.

const ftp = require("basic-ftp");

Should it be

/**
 * @type {typeof ftp.Client}
 */

It would be interpreted as a normal function however.

or

/**
 * @type {ftp.Client}
 */

This would become any type.

The types are actually loaded but the notice still shows up. Should it be an issue of
TypeScript and JavaScript Language Features vscode.typescript-language-features
instead?

from basic-ftp.

patrickjuchli avatar patrickjuchli commented on May 19, 2024

Javascript projects should work fine, no? Using the following two lines with "javascript.implicitProjectConfig.checkJs": true works fine in VSCode: It shows an error for my first argument when trying to instantiate ftp.Client.

const ftp = require("basic-ftp")
const bla = new ftp.Client("VSCode SHOULD MARK ERROR HERE");

from basic-ftp.

patrickjuchli avatar patrickjuchli commented on May 19, 2024

But it looks like there's something missing for Typescript projects. I will look into it.

from basic-ftp.

deziev avatar deziev commented on May 19, 2024

@patrickjuchli hi, i think the best way to solve this issue would be adding native typings to repo. Im talking about index.d.ts file which defines package typings. That will significantly help to use basic-ftp in typescript projects.
Anyway, i'd happy to make pull request with described feature.

from basic-ftp.

patrickjuchli avatar patrickjuchli commented on May 19, 2024

There are some open issues on the Typescript repository about leveraging JSDoc annotations instead of having to specify type definitions a second time. It seems they want to support that. In the short term, we probably do need a d.ts type definition file. I don't like the idea of having two separate type definitions for the same things, though. Go ahead with the pull request if you want to give it a try.

from basic-ftp.

patrickjuchli avatar patrickjuchli commented on May 19, 2024

Fixed in 3.2.0

from basic-ftp.

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.