Giter Club home page Giter Club logo

dts-dom's People

Contributors

943297456 avatar agankarin avatar antriel avatar ark120202 avatar cspotcode avatar dependabot[bot] avatar englercj avatar harryparkdotio avatar jdanyow avatar jpoehnelt avatar jskrzypek avatar junoatwork avatar knisterpeter avatar kozi avatar leonard-thieu avatar miralemd avatar newfuture avatar ryancavanaugh avatar sjbarag avatar unstubbable avatar wehrstedt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dts-dom's Issues

Thank you for including /lib in your npm packages!

Just came to say thank you. I'm writing some code that depends on the typescript types, based on the path inside the package (e.g. require('dts-dom/lib/index.ts')). I'm not asking for any changes, however- if in the future you decide to only include your built /bin directory (which many packages do), please consider it a breaking change for your version number. ๐Ÿ™๐Ÿผ

Thanks again for this useful package!

Release 0.0.15

Can you do a push for 0.0.15? My repo relies on the indexSignature changes recently added but they haven't made it to npm yet.

Thanks!

Including unescaped code

I'm trying to transform an API response into some type definitions. Unfortunately, some argument and property types are already strings in JSDoc notation, e.g. Array.<string|number>|Buffer. I'm currently converting that to Array<string|number>|Buffer so its valid TS, but I'm nervous about trying to parse it to determine the correct ts-dom structure.

Is there a way to pass that to this library and have it emitted unmodified?

multiple types for members/parameters etc

Is there a way to create a member with multiple types?
If I want to create a property I can only pass one type. But in typescript you can declare a class member like this:

declare class myClass {
    prop: string | number;
} 

Am I right that it's currently not possible?

published package is missing functions

Im using the latest version of this package (3.6.0) but the published version of this package is missing functions, e. g. interfaces does not support type parameters (left: repo version, right: published version in the registry):
image

This feature was added 6 years ago so it should be already published, right?

Latest version has outdated generated files.

Looks like in the latest release (0.1.8) the generated files are not up to date with the latest source.

I recommend adding a prepublish script that builds the bin/ folder to ensure it is automatically updated when publishing.

Testing

Following up on this comment:

What happens if we add hundreds of tests like this, then decide that the default output formatting should place the brace on the next line, or that large type aliases of unions should be split into multiple lines? Now we have to hand-edit hundreds of string literals in a .ts file; that's a nightmare.

We could easily add snapshot tests with Jest to avoid migration issues like this. Would you be open to a PR that adds this?

references between different namespaces

The following

const intfA = dom.create.interface('A');
const intfB = dom.create.interface('B');
intfB.baseTypes.push(intfA);

const foo = dom.create.namespace('Foo');
const bar = dom.create.namespace('Bar');
foo.members.push(intfB);
foo.members.push(bar);
bar.members.push(intfA);

console.log(dom.emit(foo));

generates:

declare namespace Foo {
    interface B extends A{
    }

    namespace Bar {
        interface A {
        }

    }

}

Which causes error because A isn't defined in namespace Foo. It should be interface B extends Bar.A.
Is this intended and the solution is to supply a dummy ObjectTypeReference with full relative name, or it's a bug?

Class member function vs method

Is there a specific reason why you differ between functionDeclaration and methodDeclaration?
I ask because I was wondering why my class members won't be parsed :D

writeDeclartion doesn't handle methods

I'm not very familiar with TypeScript so forgive me if this is silly issue or in some way incompatible.

I would like to use this library to convert JSDoc comments to a typescript definition file (like the tsd-jsdoc projcect) but I run into problems when comments hit the writeDeclaration function. In our library most everything is interpreted as a method by JSDocs since they exist inside our global namespace. There shouldn't theoretically be any reason they cannot be passed as an case in which calls writeFunction.

I've attempted to get this working to put in a PR but am running into some type errors that I'm working through, you might know a better way to resolve this.

Parameters with default value

As far as I can see there is no possibility to create parameters with initial value like

function myFunc(param: boolean = false)

Do you have a suggestion how to extend the function create.parameter to pass in a default value? If a default value is passed, the parameter flags can be implicit set to DeclarationFlags.Optional.

I would create a PR, but I didn't find a good way to apply these changes without breaking the API.
Do you have any suggestions?

Type alias NamespaceMember should include EnumDeclaration

This is the closest authoratative reference I could find, although it appears to be quite old: https://github.com/microsoft/TypeScript/blob/master/doc/spec.md#102-namespace-body

The following is valid typescript, according to my [email protected]:

declare namespace N {
    enum E {
        A = "a",
        B = "b",
    }
}

and can be generated with

const n = dom.create.namespace('N')
const e = dom.create.enum('E')
e.members.push(dom.create.enumValue('A','a'))
e.members.push(dom.create.enumValue('B','b'))
n.members.push(e)
dom.emit(n)

However the type of n.members, NamespaceMember[], does not include EnumDeclaration.

In my code, I've worked around it with a // @ts-ignore

I'm happy to create a PR if you agree with this change.

Namespaces can contain enums

Namespaces can contain enums:

declare namespace Fuu {
    export enum Bar {
        ONE: number;
        TWO: number;
    }
}

But the type NamespaceMember is missing type EnumDeclaration

Comment vs JSDoc

Is there a reason why the example comment is not JSDoc?

Your example:

declare namespace SomeNamespace {
    // This is my nice interface
    interface MyInterface {
        getThing?(x: number): void;
    }
}

I would expect the output to be:

declare namespace SomeNamespace {
    /**
     * This is my nice interface
     */
    interface MyInterface {
        getThing?(x: number): void;
    }
}

How to return a typed Promise from a method

I'm trying to generate the following:

declare interface PartitionService {
    shell(req: ShellRequest): Promise<ShellResponse>;
}

Everything works fine except for the Promise<ShellResponse>. I'm not sure how to generate that piece. Any help? Thanks!

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.