Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not use types #158

Closed
romitamgai opened this issue Dec 28, 2017 · 6 comments
Closed

Could not use types #158

romitamgai opened this issue Dec 28, 2017 · 6 comments
Labels

Comments

@romitamgai
Copy link

I want to define an interface in my project:

import { ServiceProvider, IdentityProvider } from 'samlify';

interface Config {
  serviceProvider: ServiceProvider;
  identityProvider: IdentityProvider;
}

export default Config;

But I am getting an error saying Property 'serviceProvider' of an exported interface has or is using the private name 'ServiceProvider'.

Another issue is if I try to build my project I get an error:

$ cross-env NODE_ENV=production run-s clean transpile cp:static
node_modules/samlify/types/src/libsaml.d.ts(47,19): error TS7006: Parameter 'local' implicitly has an 'any' type.
node_modules/samlify/types/src/libsaml.d.ts(51,36): error TS7006: Parameter 'opts' implicitly has an 'any' type.
node_modules/samlify/types/src/libsaml.d.ts(52,36): error TS7006: Parameter 'fields' implicitly has an 'any' type.
node_modules/samlify/types/src/libsaml.d.ts(55,30): error TS7006: Parameter 'metadata' implicitly has an 'any' type.
node_modules/samlify/types/src/libsaml.d.ts(57,24): error TS7006: Parameter 'sourceEntity' implicitly has an 'any' type.
node_modules/samlify/types/src/libsaml.d.ts(57,38): error TS7006: Parameter 'targetEntity' implicitly has an 'any' type.
node_modules/samlify/types/src/libsaml.d.ts(58,24): error TS7006: Parameter 'here' implicitly has an 'any' type.
node_modules/samlify/types/src/libsaml.d.ts(61,20): error TS7006: Parameter 'xmlDoc' implicitly has an 'any' type.
node_modules/samlify/types/src/libsaml.d.ts(62,21): error TS7006: Parameter 'xmlDoc' implicitly has an 'any' type.
node_modules/samlify/types/src/libsaml.d.ts(63,32): error TS7006: Parameter 'xmlDoc' implicitly has an 'any' type.
node_modules/samlify/types/src/libsaml.d.ts(64,23): error TS7006: Parameter 'xmlDoc' implicitly has an 'any' type.
node_modules/samlify/types/src/libsaml.d.ts(65,21): error TS7006: Parameter 'xmlDoc' implicitly has an 'any' type.
node_modules/samlify/types/src/libsaml.d.ts(66,20): error TS7006: Parameter 'xmlDoc' implicitly has an 'any' type.
@tngan tngan added the question label Jan 1, 2018
@tngan
Copy link
Owner

tngan commented Jan 1, 2018

@romitamgai ServiceProvider is exported as an instance of a class by default, not a class.

samlify/src/entity-sp.ts

Lines 26 to 28 in c71f9f6

export default function(props: ServiceProviderSettings) {
return new ServiceProvider(props);
}

If you want to extends the class yourself, you should possibly import with a deeper link, such that

import { ServiceProvider } from 'samlify/src/entity-sp';
import { IdentityProvider } from 'samlify/src/entity-idp';

export default interface Provider {
  service: ServiceProvider
  identity: IdentityProvider
}

@romitamgai
Copy link
Author

romitamgai commented Jan 2, 2018

Thanks @tngan for your response. When I try your method I get following transpile error in my project:

$ cross-env NODE_ENV=production run-s clean transpile cp:static
node_modules/@types/xmldom/index.d.ts(13,16): error TS2304: Cannot find name 'DOMImplementation'.
node_modules/@types/xmldom/index.d.ts(26,64): error TS2304: Cannot find name 'Document'.
node_modules/@types/xmldom/index.d.ts(30,33): error TS2304: Cannot find name 'Node'.
node_modules/samlify/src/binding-post.ts(13,7): error TS6133: 'xmlTag' is declared but its value is never read.
node_modules/samlify/src/binding-post.ts(206,24): error TS2532: Object is possibly 'undefined'.
node_modules/samlify/src/binding-redirect.ts(8,8): error TS6133: 'Entity' is declared but its value is never read.
node_modules/samlify/src/binding-redirect.ts(57,53): error TS2339: Property 'length' does not exist on type 'string | ParsedUrlQuery | never[]'.
  Property 'length' does not exist on type 'ParsedUrlQuery'.
node_modules/samlify/src/binding-redirect.ts(67,235): error TS2345: Argument of type 'null' is not assignable to parameter of type 'boolean | undefined'.
node_modules/samlify/src/binding-redirect.ts(87,20): error TS2532: Object is possibly 'undefined'.
node_modules/samlify/src/binding-redirect.ts(132,20): error TS2532: Object is possibly 'undefined'.
node_modules/samlify/src/binding-redirect.ts(180,24): error TS2532: Object is possibly 'undefined'.
node_modules/samlify/src/entity-idp.ts(6,36): error TS6133: 'ParseResult' is declared but its value is never read.
node_modules/samlify/src/entity-idp.ts(14,8): error TS6133: 'utility' is declared but its value is never read.
node_modules/samlify/src/entity-idp.ts(16,8): error TS6133: 'redirectBinding' is declared but its value is never read.
node_modules/samlify/src/entity-idp.ts(19,13): error TS6133: 'xml' is declared but its value is never read.
node_modules/samlify/src/entity-idp.ts(21,7): error TS6133: 'bindDict' is declared but its value is never read.
node_modules/samlify/src/entity-idp.ts(22,7): error TS6133: 'xmlTag' is declared but its value is never read.
node_modules/samlify/src/entity-idp.ts(23,7): error TS6133: 'metaWord' is declared but its value is never read.
node_modules/samlify/src/entity-idp.ts(54,47): error TS2532: Object is possibly 'undefined'.
node_modules/samlify/src/entity-idp.ts(85,16): error TS2345: Argument of type '((...args: any[]) => any) | undefined' is not assignable to parameter of type '(template: string) => BindingContext'.
  Type 'undefined' is not assignable to type '(template: string) => BindingContext'.
node_modules/samlify/src/entity-sp.ts(6,72): error TS6133: 'ParseResult' is declared but its value is never read.
node_modules/samlify/src/entity-sp.ts(13,8): error TS6133: 'utility' is declared but its value is never read.
node_modules/samlify/src/entity-sp.ts(17,13): error TS6133: 'xml' is declared but its value is never read.
node_modules/samlify/src/entity-sp.ts(19,7): error TS6133: 'bindDict' is declared but its value is never read.
node_modules/samlify/src/entity-sp.ts(20,7): error TS6133: 'xmlTag' is declared but its value is never read.
node_modules/samlify/src/entity-sp.ts(21,7): error TS6133: 'metaWord' is declared but its value is never read.
node_modules/samlify/src/entity-sp.ts(74,104): error TS2345: Argument of type '((...args: any[]) => any) | undefined' is not assignable to parameter of type '(template: string) => BindingContext'.
  Type 'undefined' is not assignable to type '(template: string) => BindingContext'.
node_modules/samlify/src/entity.ts(10,8): error TS6133: 'Metadata' is declared but its value is never read.
node_modules/samlify/src/entity.ts(15,33): error TS6133: 'isArray' is declared but its value is never read.
node_modules/samlify/src/entity.ts(15,42): error TS6133: 'get' is declared but its value is never read.
node_modules/samlify/src/entity.ts(16,13): error TS6133: 'url' is declared but its value is never read.
node_modules/samlify/src/entity.ts(154,13): error TS2532: Object is possibly 'undefined'.
node_modules/samlify/src/entity.ts(154,40): error TS2532: Object is possibly 'undefined'.
node_modules/samlify/src/entity.ts(171,82): error TS6133: 'decryptAssertion' is declared but its value is never read.
node_modules/samlify/src/libsaml.ts(8,10): error TS6133: 'pki' is declared but its value is never read.
node_modules/samlify/src/libsaml.ts(11,8): error TS6133: 'xpath' is declared but its value is never read.
node_modules/samlify/src/libsaml.ts(16,8): error TS6133: 'crpyto' is declared but its value is never read.
node_modules/samlify/src/libsaml.ts(24,7): error TS6133: 'requestTags' is declared but its value is never read.
node_modules/samlify/src/libsaml.ts(165,39): error TS2538: Type 'undefined' cannot be used as an index type.
node_modules/samlify/src/libsaml.ts(200,7): error TS2322: Type 'undefined' is not assignable to type 'string'.
node_modules/samlify/src/libsaml.ts(226,17): error TS2345: Argument of type '{}' is not assignable to parameter of type 'never'.
node_modules/samlify/src/libsaml.ts(254,39): error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.
node_modules/samlify/src/libsaml.ts(292,19): error TS2345: Argument of type '{}' is not assignable to parameter of type 'never'.
node_modules/samlify/src/libsaml.ts(315,17): error TS2345: Argument of type 'any' is not assignable to parameter of type 'never'.
node_modules/samlify/src/libsaml.ts(334,17): error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.
node_modules/samlify/src/libsaml.ts(440,29): error TS2350: Only a void function can be called with the 'new' keyword.
node_modules/samlify/src/libsaml.ts(440,49): error TS2345: Argument of type 'string | Buffer' is not assignable to parameter of type 'string'.
  Type 'Buffer' is not assignable to type 'string'.
node_modules/samlify/src/libsaml.ts(441,59): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
  Type 'undefined' is not assignable to type 'string'.
node_modules/samlify/src/libsaml.ts(575,65): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
  Type 'undefined' is not assignable to type 'string'.
node_modules/samlify/src/libsaml.ts(606,12): error TS2339: Property 'getKey' does not exist on type '{ createXPath: (local: any, isExtractAll?: boolean | undefined) => string; getQueryParamByType: (...'.
node_modules/samlify/src/libsaml.ts(622,17): error TS6133: 'targetEntitySetting' is declared but its value is never read.
node_modules/samlify/src/libsaml.ts(623,17): error TS6133: 'sourceEntityMetadata' is declared but its value is never read.
node_modules/samlify/src/libsaml.ts(627,17): error TS6133: 'assertionNode' is declared but its value is never read.
node_modules/samlify/src/libsaml.ts(707,15): error TS6133: 'currentDirectory' is declared but its value is never read.
node_modules/samlify/src/metadata-idp.ts(109,36): error TS2345: Argument of type '({ localName: string; attributes: string[]; } | { localName: { tag: string; key: string; }; attri...' is not assignable to parameter of type 'never[] | undefined'.
  Type '({ localName: string; attributes: string[]; } | { localName: { tag: string; key: string; }; attri...' is not assignable to type 'never[]'.
    Type '{ localName: string; attributes: string[]; } | { localName: { tag: string; key: string; }; attrib...' is not assignable to type 'never'.
      Type '{ localName: string; attributes: string[]; }' is not assignable to type 'never'.
node_modules/samlify/src/metadata-sp.ts(85,9): error TS2532: Object is possibly 'undefined'.
node_modules/samlify/src/metadata-sp.ts(91,9): error TS2532: Object is possibly 'undefined'.
node_modules/samlify/src/metadata-sp.ts(97,35): error TS2532: Object is possibly 'undefined'.
node_modules/samlify/src/metadata-sp.ts(111,11): error TS2532: Object is possibly 'undefined'.
node_modules/samlify/src/metadata-sp.ts(126,11): error TS2532: Object is possibly 'undefined'.
node_modules/samlify/src/metadata-sp.ts(153,36): error TS2345: Argument of type '{ localName: string; attributes: string[]; }[]' is not assignable to parameter of type 'never[] | undefined'.
  Type '{ localName: string; attributes: string[]; }[]' is not assignable to type 'never[]'.
    Type '{ localName: string; attributes: string[]; }' is not assignable to type 'never'.
node_modules/samlify/src/metadata.ts(7,8): error TS6133: 'utility' is declared but its value is never read.
node_modules/samlify/src/metadata.ts(36,69): error TS2345: Argument of type '(string | { localName: string; attributes: string[]; } | { localName: { tag: string; key: string;...' is not assignable to parameter of type 'ReadonlyArray<never>'.
  Types of property 'concat' are incompatible.
    Type '{ (...items: ReadonlyArray<string | { localName: string; attributes: string[]; } | { localName: {...' is not assignable to type '{ (...items: ReadonlyArray<never>[]): never[]; (...items: ReadonlyArray<never>[]): never[]; }'.
      Type '(string | { localName: string; attributes: string[]; } | { localName: { tag: string; key: string;...' is not assignable to type 'never[]'.
        Type 'string | { localName: string; attributes: string[]; } | { localName: { tag: string; key: string; ...' is not assignable to type 'never'.
          Type 'string' is not assignable to type 'never'.
node_modules/samlify/src/metadata.ts(119,56): error TS2345: Argument of type 'string' is not assignable to parameter of type 'never'.
node_modules/samlify/src/utility.ts(6,13): error TS6133: 'fs' is declared but its value is never read.
node_modules/samlify/src/utility.ts(10,10): error TS6133: 'DOMParser' is declared but its value is never read.
node_modules/samlify/src/utility.ts(118,33): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
node_modules/xpath/xpath.d.ts(1,22): error TS2304: Cannot find name 'Node'.
node_modules/xpath/xpath.d.ts(1,29): error TS2304: Cannot find name 'Attr'.
node_modules/xpath/xpath.d.ts(3,33): error TS2304: Cannot find name 'Node'.
node_modules/xpath/xpath.d.ts(4,32): error TS2304: Cannot find name 'Node'.
node_modules/xpath/xpath.d.ts(7,52): error TS2304: Cannot find name 'Node'.
node_modules/xpath/xpath.d.ts(8,59): error TS2304: Cannot find name 'Node'.
node_modules/xpath/xpath.d.ts(8,75): error TS2304: Cannot find name 'XPathNSResolver'.
node_modules/xpath/xpath.d.ts(8,114): error TS2304: Cannot find name 'XPathResult'.
node_modules/xpath/xpath.d.ts(8,128): error TS2304: Cannot find name 'XPathResult'.
error Command failed with exit code 2.
ERROR: "transpile" exited with 1.
error Command failed with exit code 1.

I am using samlify version 2.3.6.

@tngan
Copy link
Owner

tngan commented Jan 2, 2018

@romitamgai Can you show me your tsconfig.json ?

@romitamgai
Copy link
Author

romitamgai commented Jan 2, 2018

@tngan Here is my tsconfig.json

{
  "compilerOptions": {
    "outDir": "./dist",
    "allowJs": false,
    "target": "es5",
    "sourceMap": true,
    "module": "commonjs",
    "strictNullChecks": true,
    "declaration": true,
    "declarationDir": "./dist",
    "strict": true,
    "alwaysStrict": true,
    "noImplicitAny": false,
    "removeComments": false,
    "lib": ["es2015", "es2016", "es2017"],
    "types": ["node"],
    "noUnusedLocals": true,
    "allowSyntheticDefaultImports": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "test/**/*"]
}

Also, we are using typescript version 2.6.1

@tngan
Copy link
Owner

tngan commented Jan 30, 2018

@romitamgai I can reproduce this issue, will seek for a fix during the coming weekend.

@tngan
Copy link
Owner

tngan commented Oct 20, 2018

Please checkout our latest example repository. react-samlify

@tngan tngan closed this as completed Oct 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants