Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot find namespace in d.ts #769

Closed
kaktus40 opened this issue Oct 14, 2016 · 6 comments
Closed

cannot find namespace in d.ts #769

kaktus40 opened this issue Oct 14, 2016 · 6 comments

Comments

@kaktus40
Copy link
Contributor

Hello,
in alasql.d.ts you change :

declare var alasql: alaSQLSpace.AlaSQL;

for

export declare var alasql: alaSQLSpace.AlaSQL;

with the export declaration, typescript can't use the definition in the file. I have this error:

error TS2503: Cannot find namespace 'alaSQLSpace'.

Is it possible to revert to the previous version please?

@mathiasrw
Copy link
Member

Interesting...

The change came from #752 where the point is to be able to do a

import * as alasql from "alasql"

rather than roling it back I suggest we look into why namespace 'alaSQLSpace' is not found. It might be because the namespace is not also public (exported)

I have made a change to https://github.com/agershun/alasql/blob/develop/dist/alasql.d.ts - but have no way to test it. Could you test the new file and let me know if it made it better?

@kaktus40
Copy link
Contributor Author

with the following it's OK:

// Project: https://github.com/agershun/alasql

declare namespace alaSQLSpace {
    interface AlaSQLCallback {
        (data?: any, err?: Error): void;
    }

    interface AlaSQLOptions {
        errorlog: boolean;
        valueof: boolean;
        dropifnotexists: boolean; // drop database in any case
        datetimeformat: string; // how to handle DATE and DATETIME types
        casesensitive: boolean; // table and column names are case sensitive and converted to lower-case
        logtarget: string; // target for log. Values: 'console', 'output', 'id' of html tag
        logprompt: boolean; // print SQL at log
        modifier: any; // values: RECORDSET, VALUE, ROW, COLUMN, MATRIX, TEXTSTRING, INDEX
        columnlookup: number; // how many rows to lookup to define columns
        autovertex: boolean; // create vertex if not found
        usedbo: boolean; // use dbo as current database (for partial T-SQL comaptibility)
        autocommit: boolean; // the AUTOCOMMIT ON | OFF
        cache: boolean; // use cache
        nocount: boolean; // for SET NOCOUNT OFF
        nan: boolean; // check for NaN and convert it to undefined
        angularjs: boolean;
        tsql: boolean;
        mysql: boolean;
        postgres: boolean;
        oracle: boolean;
        sqlite: boolean;
        orientdb: boolean;
    }

    // compiled Statement
    interface AlaSQLStatement {
        (params?: any, cb?: AlaSQLCallback, scope?: any): any;
    }

    // abstract Syntax Tree
    interface AlaSQLAST {
        compile(databaseid: string): AlaSQLStatement;
    }

    // https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/es6-promise/es6-promise.d.ts
    interface Thenable<T> {
        then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
        then<U>(onFulfilled?: (value: T) => U | Thenable<U>, onRejected?: (error: any) => void): Thenable<U>;
        catch<U>(onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
    }

    // see https://github.com/agershun/alasql/wiki/User%20Defined%20Functions
    interface userDefinedFunction {
        (x: any): any;
    }
    interface userDefinedFunctionLookUp {
        [x: string]: userDefinedFunction;
    }
    // see https://github.com/agershun/alasql/wiki/User%20Defined%20Functions
    interface userAggregator {
        (value: any, accumulator: any, stage: number): any;
    }
    interface userAggregatorLookUp {
        [x: string]: userAggregator;
    }

    interface AlaSQL {
        options: AlaSQLOptions;
        error: Error;
        (sql: any, params?: any, cb?: AlaSQLCallback, scope?: any): any;
        parse(sql): AlaSQLAST;
        promise(sql: any, params?: any): Thenable<any>;
        fn: userDefinedFunctionLookUp;
        aggr: userAggregatorLookUp;
        autoval(tablename: string, colname: string, getNext?:boolean): number;
    }
}

declare var alasql: alaSQLSpace.AlaSQL;
declare module 'alasql' {
    export = alasql;
}

@jnath should test if it's ok for him.

@mathiasrw
Copy link
Member

@jnath any chance you can test if this is working for you?

@mathiasrw
Copy link
Member

@jnath have you had a change to check the version provided by @kaktus40 ?

@kaktus40
Copy link
Contributor Author

I don't like to process like this but is it possible to put my proposition into the next release of alasql. 24 days without answer of @jnath....

@mathiasrw
Copy link
Member

Good point. Lets role it back.

@jnath I will role your change back - please comment on this issue when you are back so we can work together to find a solution that fits the usage of both of you...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants