Cannot find module '@foundry/ontology-api' or its corresponding type declarations

Viewed 295

When opening a branch in a Typescript repository, the following error appears against one of the modules @foundry/ontology-api in the import statement:

[typescript] Cannot find module '@foundry/ontology-api' or its corresponding type declarations

This appears after the Code Assist feature has loaded successfully.

2 Answers

There appears to be a timing issue between the environment fully loading all the modules and Code Assist recognising them. My often used workaround is to allow Code Assist to finish loading and then refresh the browser (i.e. F5). After the second attempt at loading Code Assist completes, the modules are no longer flagged as unrecognised.

 {
  "name": "my-functions",
  "version": "0.0.1",
  "description": "My Functions",
  "main": "dist/index.js",
  "types": "dist/index.d.ts",
  "dependencies": {
    "@foundry/functions-api": "0.54.0",
    "@foundry/functions-typescript-runtime-internal-api": "0.33.0",
    "@foundry/functions-utils": "0.4.0"
  },
  "devDependencies": {
    "@foundry/functions-typescript-authoring-dev": "0.44.0",
    "@foundry/functions-typescript-ontology-code-generator": "0.45.0",
    "@foundry/functions-typescript-discovery": "0.30.0",
    "@foundry/functions-typescript-object-set-base": "1.31.0",
    "@foundry/functions-testing-lib": "0.16.0",
    "jest": "27.5.1",
    "ts-jest": "27.1.3"
  },
  "scripts": {
    "build": "../gradlew build",
    "check": "../gradlew check",
    "test": "../gradlew test",
    "jest": "jest"
  },
  "license": "UNLICENSED"
}
Related