These are chat archives for DefinitelyTyped/DefinitelyTyped

17th
Jul 2017
Chris Krycho
@chriskrycho
Jul 17 16:26

Quick question: the FAQ states:

The master branch is automatically published to the @types scope on NPM thanks to types-publisher. This usually happens within an hour of changes being merged.

However, I'm not seeing a new set of type defs that DefinitelyTyped/DefinitelyTyped#17727 a few days ago. Anyone know what's up?

Ireneusz Patalas
@ipatalas
Jul 17 18:58
hi guys, anyone had an issue with 'Older version X must have a path mapping for itself.' when running npm test?
Ireneusz Patalas
@ipatalas
Jul 17 21:09

figured it out by myself (I was missing some configuration in tsconfig.json) - however I have different error now: https://travis-ci.org/ipatalas/DefinitelyTyped/builds/254588905

I get similar error on my machine (spawn C:\Windows\system32\cmd.exe ENOENT) but have no clue why.. I was even debugging the tests and can't figure anything here

I have added new typings for glob package (it was only available for v5 and we have v7 today) - linter reports no issues for both versions but npm test is still failing
Isaac Brown
@Progdom
Jul 17 22:54
declare module 'amaterasu/config' {

    import * as config from 'config';

    export default config;
}
How do I get the config types?
// Type definitions for node-config
// Project: https://github.com/lorenwest/node-config
// Definitions by: Roman Korneev <https://github.com/RWander>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped



declare var c: c.IConfig;

declare namespace c {

    // see https://github.com/lorenwest/node-config/wiki/Using-Config-Utilities
    interface IUtil {
        // Extend an object (and any object it contains) with one or more objects (and objects contained in them).
        extendDeep(mergeInto: any, mergeFrom: any, depth?: number): any;

        // Return a deep copy of the specified object.
        cloneDeep(copyFrom: any, depth?: number): any;

        // Return true if two objects have equal contents.
        equalsDeep(object1: any, object2: any, dept?: number): boolean;

        // Returns an object containing all elements that differ between two objects.
        diffDeep(object1: any, object2: any, depth?: number): any;

        // Make a javascript object property immutable (assuring it cannot be changed from the current value).
        makeImmutable(object: any, propertyName?: string, propertyValue?: string): any;

        // Make an object property hidden so it doesn't appear when enumerating elements of the object.
        makeHidden(object: any, propertyName: string, propertyValue?: string): any;

        // Get the current value of a config environment variable
        getEnv(varName: string): string;

        // Return the config for the project based on directory param if not directory then return default one (config).
        loadFileConfigs(configDir: string): any;

        // Return the sources for the configurations
        getConfigSources(): IConfigSource[];
    }

    interface IConfig {
        get<T>(setting: string): T;
        has(setting: string): boolean;
        util: IUtil;
    }

    interface IConfigSource {
        name: string;
        original?: string;
        parsed: any;
    }
}

export = c;
It has this file here, but intelliJ says that it cna't find the IConfig methodfs
the consumer files says that it can't find .get on the config object.

I'm importing like so ``` javascript

import * as config from 'amaterasu/config'

```

I have to manually declare a function for get in that file, but I feel like it should pickup the typings from that file, no?
Adrian Leonhard
@NaridaL
Jul 17 22:58
declare module 'amaterasu/config' {

    import * as config from 'config';

    export = config;
}
try that
Isaac Brown
@Progdom
Jul 17 22:58
That gives me a different error about it being a non-module entity.
Adrian Leonhard
@NaridaL
Jul 17 22:59
can you paste the complete error?
Isaac Brown
@Progdom
Jul 17 22:59
src/server.ts(6,25): error TS2497: Module ''amaterasu/config'' resolves to a non-module entity and cannot be imported using this construct.
Adrian Leonhard
@NaridaL
Jul 17 23:00
export * from 'config'
?
Isaac Brown
@Progdom
Jul 17 23:00
Where do I put that?
Adrian Leonhard
@NaridaL
Jul 17 23:00
declare module 'amaterasu/config' {

    export * from 'config';
}
Isaac Brown
@Progdom
Jul 17 23:01
That fixes the import error, but I still can't find the .get typing
Adrian Leonhard
@NaridaL
Jul 17 23:01
what is 'config' ?
Isaac Brown
@Progdom
Jul 17 23:02

``` javascript
// Type definitions for node-config
// Project: https://github.com/lorenwest/node-config
// Definitions by: Roman Korneev https://github.com/RWander
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

declare var c: c.IConfig;

declare namespace c {

// see https://github.com/lorenwest/node-config/wiki/Using-Config-Utilities
interface IUtil {
    // Extend an object (and any object it contains) with one or more objects (and objects contained in them).
    extendDeep(mergeInto: any, mergeFrom: any, depth?: number): any;

    // Return a deep copy of the specified object.
    cloneDeep(copyFrom: any, depth?: number): any;

    // Return true if two objects have equal contents.
    equalsDeep(object1: any, object2: any, dept?: number): boolean;

    // Returns an object containing all elements that differ between two objects.
    diffDeep(object1: any, object2: any, depth?: number): any;

    // Make a javascript object property immutable (assuring it cannot be changed from the current value).
    makeImmutable(object: any, propertyName?: string, propertyValue?: string): any;

    // Make an object property hidden so it doesn't appear when enumerating elements of the object.
    makeHidden(object: any, propertyName: string, propertyValue?: string): any;

    // Get the current value of a config environment variable
    getEnv(varName: string): string;

    // Return the config for the project based on directory param if not directory then return default one (config).
    loadFileConfigs(configDir: string): any;

    // Return the sources for the configurations
    getConfigSources(): IConfigSource[];
}

interface IConfig {
    get<T>(setting: string): T;
    has(setting: string): boolean;
    util: IUtil;
}

interface IConfigSource {
    name: string;
    original?: string;
    parsed: any;
}

}

export = c;

```

node-config
Adrian Leonhard
@NaridaL
Jul 17 23:05
ok, sorry, I was confused because it said 'node-config' in the header
why are you re-exporting anyway, why not just import 'config' in your server.ts