Let's dive into a TypeScript and Azure integration question:
Within my Node.js code for an Azure function:
import {
app,
HttpRequest,
HttpResponseInit,
InvocationContext,
} from "@azure/functions";
import { workerExec } from "./worker";
export async function myappfunction1(
request: HttpRequest,
context: InvocationContext
): Promise<HttpResponseInit> {
context.log(`Http function processed request for url "${request.url}"`);
try {
console.log(`Incoming event: ${JSON.stringify(event)}`);
const result = await workerExec(event, context);
console.log("Successfully processed event;");
return result;
} catch (err) {
console.log(err);
throw err;
}
}
app.http("myappfunction1", {
methods: ["GET", "POST"],
authLevel: "anonymous",
handler: myappfunction1,
});
Encountering this error while using the tsc
command:
error TS2305: Module '"@azure/functions"' has no exported member 'app'.
error TS2724: '"@azure/functions"' has no exported member named 'HttpResponseInit'.
error TS2305: Module '"@azure/functions"' has no exported member 'InvocationContext'
Configuration in my tsconfig.json is as follows:
{
"compilerOptions": {
"target": "es2020",
"strict": true,
"preserveConstEnums": true,
"noEmit": true,
"sourceMap": false,
"module": "es2015",
"moduleResolution": "node",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": "src/functions",
"paths": {
"*": [
"*",
"node_modules/*"
]
},
},
"exclude": [
"node_modules",
"**/*.test.ts"
],
"include": [
"**/*"
]
}
What seems to be causing the issue?