Skip to content

Import declarations seems to break namespace compilation #24432

Closed
@nikkatalnikov

Description

@nikkatalnikov

TypeScript Version: 2.8.1

Search Terms:
namespace
import
Code

import { Moment } from 'moment'

declare namespace Models {
  export interface ITimeFrame {
    [key: string]: Array<{
      foo: number
      start: Moment
      end: Moment
    }>
  }
}

Expected behavior:
Compiles fine

Actual behavior:
Webstorm spits out an error.

**/service.ts
Error:(12, 17) TS2503: Cannot find namespace 'Models'.
Error:(30, 30) TS2503: Cannot find namespace 'Models'.
Error:(99, 11) TS2503: Cannot find namespace 'Models'.
Error:(100, 6) TS2503: Cannot find namespace 'Models'.
Error:(119, 11) TS2503: Cannot find namespace 'Models'.
Error:(120, 6) TS2503: Cannot find namespace 'Models'.
Error:(146, 11) TS2503: Cannot find namespace 'Models'.
Error:(146, 56) TS2503: Cannot find namespace 'Models'.
Error:(147, 6) TS2503: Cannot find namespace 'Models'.

once import declaration and

start: Moment
end: Moment

are removed, it compiles fine.

also, even import declaration by itself, without

start: Moment
end: Moment

breaks compilation with the same result.

tsconfig:

{
  "compilerOptions": {
    "target": "es2015",
    "module": "commonjs",
    "noImplicitAny": false,
    "alwaysStrict": true,
    "strictNullChecks": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  },
  "exclude":[
    "node_modules",
    "./src/**/*.spec.ts"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions