flowgen icon indicating copy to clipboard operation
flowgen copied to clipboard

Outputting exports incorrectly

Open bradennapier opened this issue 8 years ago • 1 comments

It does not appear to be handling exports in a way that works. Mainly due to the fact it is missing module.exports and declare export

image

This is also for the uws conversion.

https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/uws/index.d.ts

bradennapier avatar Oct 30 '17 00:10 bradennapier

I have added a test case with that file, and it does break but it seems from a different reason. I use prettier to validate the output of the compiler. this is the output before prettier:

declare module.exports: typeof WebSocket
      declare var npm$namespace$WebSocket: {
        createServer: typeof WebSocket$createServer,
connect: typeof WebSocket$connect,
createConnection: typeof WebSocket$createConnection,
      }declare type WebSocket$VerifyClientCallbackSync = (
info: {
origin: string,
secure: boolean,
req: http.IncomingMessage
}) => boolean;

declare type WebSocket$VerifyClientCallbackAsync = (
info: {
origin: string,
secure: boolean,
req: http.IncomingMessage
},
callback: (res: boolean) => void) => void;

declare export interface WebSocket$IClientOptions {
protocol?: string,
agent?: http.Agent,
headers?: {
[key: string]: string
},
protocolVersion?: any,
host?: string,
origin?: string,
pfx?: any,
key?: any,
passphrase?: string,
cert?: any,
ca?: any[],
ciphers?: string,
rejectUnauthorized?: boolean
} 

declare export interface WebSocket$IPerMessageDeflateOptions {
serverNoContextTakeover?: boolean,
clientNoContextTakeover?: boolean,
serverMaxWindowBits?: number,
clientMaxWindowBits?: number,
memLevel?: number,
serverNoContextTakeover?: boolean,
clientNoContextTakeover?: boolean,
serverMaxWindowBits?: number,
clientMaxWindowBits?: number,
memLevel?: number
} 

declare export interface WebSocket$IServerOptions {
host?: string,
port?: number,
server?: http.Server | https.Server,
verifyClient?: WebSocket$VerifyClientCallbackAsync | WebSocket$VerifyClientCallbackSync,
handleProtocols?: any,
path?: string,
noServer?: boolean,
disableHixie?: boolean,
clientTracking?: boolean,
perMessageDeflate?: boolean | WebSocket$IPerMessageDeflateOptions
} 

declare export class Server mixins events.EventEmitter {
options: WebSocket$IServerOptions;
path: string;
clients: WebSocket[];
constructor(options?: WebSocket$IServerOptions, callback?: Function): this;
close(cb?: (err?: any) => void): void;
handleUpgrade(
request: http.IncomingMessage,
socket: net.Socket,
upgradeHead: ArrayBuffer,
callback: (client: WebSocket) => void): void;
on(event: 'error', cb: (err: Error) => void): this;
on(event: 'headers', cb: (headers: string[]) => void): this;
on(event: 'connection', cb: (this: WebSocket, client: WebSocket) => void): this;
on(event: string, listener: (...args: any[]) => void): this;
addListener(event: 'error', cb: (err: Error) => void): this;
addListener(event: 'headers', cb: (headers: string[]) => void): this;
addListener(event: 'connection', cb: (client: WebSocket) => void): this;
addListener(event: string, listener: (...args: any[]) => void): this
}

declare export interface WebSocket$UwsHttp {
createServer(
requestListener?: (request: http.IncomingMessage, response: http.ServerResponse) => void): http.Server,
getExpressApp(express: any): any,
getResponsePrototype(): http.ServerResponse,
getRequestPrototype(): http.IncomingMessage
} 

declare export var http: WebSocket$UwsHttp;

declare export function WebSocket$createServer(
options?: WebSocket$IServerOptions,
connectionListener?: (client: WebSocket) => void): WebSocket$Server


declare export function WebSocket$connect(address: string, openListener?: Function): void


declare export function WebSocket$createConnection(address: string, openListener?: Function): void

The problem is here: image

@orta @joarwilk Do you have any pointers where is the faulted code?

talshani avatar May 25 '18 04:05 talshani