Skip to content

File '@types/office-js/index.d.ts' is not a module #11420

@jozefizso

Description

@jozefizso

TypeScript Version: 2.0.3

Code

Install office-js types definition:

npm install --save-dev @types/office-js

Try to use the Office object in app.ts:

import {Office} from 'office-js'; // [ts] File 'node_modules/@types/office-js/index.d.ts' is not a module.

export class App {
  constructor() {
    let doc = Office.context.document;
  }
}

TypeScript configuration in tsconfig.json:

{
  "compilerOptions": {
    "target": "es5",
    "module": "amd",
    "moduleResolution": "node",
    "lib": ["es2015", "dom"],
    "typeRoots": [
      "node_modules/@types"
    ]
  }
}

Expected behavior:
TypeScript 2.0 should use the types definitions that are available from npm @types.

Actual behavior:
TypeScript reports error: File 'node_modules/@types/office-js/index.d.ts' is not a module.
TypeScript does not recognize the Office as valid object and does not provide intellisense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions