2

I have encountered dificulties using the ApplicationCustomizerContext type and the TypesSript

1) I have created a spfx application customizer

2) I have added in the application customizer main ts file:

import ApplicationCustomizerContext from "@microsoft/sp-application-base/lib/extensibility/ApplicationCustomizerContext";

3) And I have added on its onInit() method:

var ctx: ApplicationCustomizerContext = this.context;

The TypeScript compiler (ver 2.4.2) ended up with error:

error TS90010: Type 'ApplicationCustomizerContext' is not assignable to type 'ApplicationCustomizerContext'. Two different types with this name exist, but they are unrelated.

Do you know by chance how the import should be defined in order the typescript didn't complain any more? (Or is there any problem in the spfx 1.5.1 infrastructure, that it does not allow - It doesn't seem to be a problem in the spfx 1.4.1??)

additional info: the project was generated using "@microsoft/generator-sharepoint 1.5.1

"environment": "spo", 
"version": "1.5.1", 
"packageManager": "npm", 
"componentType": "extension", 
"extensionType": "ApplicationCustomizer"

The tsconfig.json left untouched (as generated originally)

  "compilerOptions": {
    "target": "es5",
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "jsx": "react",
    "declaration": true,
    "sourceMap": true,
    "experimentalDecorators": true,
    "skipLibCheck": true,
    "typeRoots": [
      "./node_modules/@types",
      "./node_modules/@microsoft"
    ],
    "types": [
      "es6-promise",
      "webpack-env"
    ],
    "lib": [
      "es5",
      "dom",
      "es2015.collection"
    ]

1 Answer 1

0

Looks like there is some change in the way ApplicationCustomizerContext import is done in SPFx v1.5.1 compared to the way it was done in 1.4.1

Modify your import statement as below:

import { ApplicationCustomizerContext } from "@microsoft/sp-application-base";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.