In Definitely Typed repository I see a bunch of ambient module declarations without quotes, such as:

[shagen@shabunc-MBP DefinitelyTyped (master)]$ ag "declare module [^\'\"]" | head

types/lockr/index.d.ts:8:declare module lockr {
types/nes/index.d.ts:44:declare module nes {
types/swig/index.d.ts:38:export declare module lexer {
types/swig/index.d.ts:103:export declare module parser {
types/swig/index.d.ts:128:export declare module loaders {
types/fibjs/declare/iconv.d.ts:197:declare module __iconv {
types/fibjs/declare/bson.d.ts:197:declare module __bson {
types/lokijs/index.d.ts:2027:declare module LokiConstructor {
types/angular-deferred-bootstrap/index.d.ts:11:declare module angular {

My understanding is though declaration like declare module something are not equivalent to declare modules "something". For instance, this code won't compile (it will fail with error TS2305: Module '"fs"' has no exported member 'ping'.):

declare module fs {
    function ping(): boolean;
}

import {ping} from "fs";

ping();

While adding quotes will help:

declare module "fs" {
    function ping(): boolean;
}

import {ping} from "fs";

ping();
          

I'm failing to find in documentation any decent explanation what `declare module name_without_quites" kind of declarations are used for - and it looks like my understanding is incomplete.

0

There are 0 answers