Skip to content

[typescript] Cannot find namespace 'ICAL' #908

@ebousse

Description

@ebousse

I have the following small typescript project with this dummy main file:

import icaljs from 'ical.js'

icaljs.parse("")

The following package.json:

{
  "scripts": {
    "build": "tsc"
  },
  "dependencies": {
    "ical.js": "2.2.0"
  },
  "devDependencies": {
    "typescript": "5.8.3"
  }
}

And the following tsconfig.json:

{
    "compilerOptions": {
        "rootDir": "src",
        "target": "es2022",
        "module": "commonjs",
        "sourceMap": true,
        "outDir": "build",
    },
    "exclude": [
        "node_modules"
    ]
}

When I try to build the project with npm run build, I obtain the following compilation error:

node_modules/ical.js/dist/types/period.d.ts:126:17 - error TS2503: Cannot find namespace 'ICAL'.

126     compare(dt: ICAL.Time | ICAL.Period): 0 | 1 | -1;
                    ~~~~

node_modules/ical.js/dist/types/period.d.ts:126:29 - error TS2503: Cannot find namespace 'ICAL'.

126     compare(dt: ICAL.Time | ICAL.Period): 0 | 1 | -1;
                                ~~~~


Found 2 errors in the same file, starting at: node_modules/ical.js/dist/types/period.d.ts:126

In ical.js code, replacing ICAL.Time with simply Time and ICAL.Period with simply Period seems to solve the above compilation problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions