Microsoft-authentication-library-for-js: TypeScript Error: "Declaration or statement expected." in msal-browser/dist/src/index.d.ts

Created on 12 May 2020  路  3Comments  路  Source: AzureAD/microsoft-authentication-library-for-js

Library

Framework

[email protected] with [email protected]

Description

When including the @azure/msal-browser in the project, the following error appears:

TypeScript error in D:/project_name/node_modules/@azure/msal-browser/dist/src/index.d.ts(5,1):
Declaration or statement expected.  TS1128

    3 | export { BrowserAuthError, BrowserAuthErrorMessage } from "./error/BrowserAuthError";
    4 | export { BrowserConfigurationAuthError, BrowserConfigurationAuthErrorMessage } from "./error/BrowserConfigurationAuthError";
  > 5 | export type { AuthCallback } from "./types/AuthCallback";
      | ^
    6 | export { AuthenticationParameters, TokenExchangeParameters, AuthResponse, TokenResponse, InteractionRequiredAuthError, AuthError, AuthErrorMessage, INetworkModule, Logger, LogLevel } from "@azure/msal-common";

Security

No.

Regression

Don't know.

Configuration

Please provide your MSAL configuration options.

// Provide configuration values here.
// For Azure B2C issues, please include your policies.

Expected behavior

When export type { AuthCallback } from './types/AuthCallback' is changed to export { AuthCallback } from './types/AuthCallback' it is compiling successfully.

Could be related to my tsconfig

{
  "compilerOptions": {
    "target": "es5",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "allowJs": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react"
  },
  "include": [
    "src"
  ]
}

Browsers

Is this issue browser-specific? If so, please detail which browsers are impacted (e.g. IE 11, Safari).''
No.

bug

Most helpful comment

@ninio Could you try upgrading to Typescript 3.8? This version introduced type-only imports and exports which is why you may be seeing the above error.

All 3 comments

@ninio Could you try upgrading to Typescript 3.8? This version introduced type-only imports and exports which is why you may be seeing the above error.

The update fixes this.

Thanks!

Solved me issue, you may want to add this to the documentation on getting started. I am upgrading a project that was using older version of TypeScript and was hitting this error.

Was this page helpful?
0 / 5 - 0 ratings