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

update to latest TypeScript #33

Open
AaronNGray opened this issue Jun 19, 2020 · 5 comments
Open

update to latest TypeScript #33

AaronNGray opened this issue Jun 19, 2020 · 5 comments

Comments

@AaronNGray
Copy link

I am having problems with using TypeScript@3.9.5 with chrome-promise. My project needs tsc v3.9.5 to compile as it uses es2020 and other features.

I have installed @types/node:latest and typescript@3.9.5, and am getting the following :-

node_modules/chrome-promise/chrome-promise.d.ts:73:51 - error TS2694: Namespace 'chrome.accessibilityFeatures' has no exported member 'AccessibilityFeaturesGetArg'.

73         get(details: chrome.accessibilityFeatures.AccessibilityFeaturesGetArg): Promise<chrome.accessibilityFeatures.AccessibilityFeaturesCallbackArg>;
                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/chrome-promise/chrome-promise.d.ts:73:118 - error TS2694: Namespace 'chrome.accessibilityFeatures' has no exported member 'AccessibilityFeaturesCallbackArg'.

73         get(details: chrome.accessibilityFeatures.AccessibilityFeaturesGetArg): Promise<chrome.accessibilityFeatures.AccessibilityFeaturesCallbackArg>;
                                                                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/chrome-promise/chrome-promise.d.ts:81:51 - error TS2694: Namespace 'chrome.accessibilityFeatures' has no exported member 'AccessibilityFeaturesSetArg'.

81         set(details: chrome.accessibilityFeatures.AccessibilityFeaturesSetArg): Promise<void>;
                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/chrome-promise/chrome-promise.d.ts:89:53 - error TS2694: Namespace 'chrome.accessibilityFeatures' has no exported member 'AccessibilityFeaturesClearArg'.

89         clear(details: chrome.accessibilityFeatures.AccessibilityFeaturesClearArg): Promise<void>;
                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 4 errors.
@AaronNGray
Copy link
Author

I also tried building a recompiled chrome-promise using typescript@3.9.5 and es6, and es2020, and have got 7 errors :-

C:\Users\aaron\GitHub\chrome-promise>npm run compileTypescript

> chrome-promise@3.0.5 compileTypescript C:\Users\aaron\GitHub\chrome-promise
> tsc type-definitions/create-type-definitions.ts --lib es5,es2015,dom

type-definitions/classes.ts:92:32 - error TS2345: Argument of type 'Identifier' is not assignable to parameter of type 'LiteralExpression | BooleanLiteral | PrefixUnaryExpression'.
  Type 'Identifier' is not assignable to type 'LiteralExpression'.
    Property '_literalExpressionBrand' is missing in type 'Identifier'.

92       ts.createLiteralTypeNode(ts.createIdentifier(typeName)),
                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


type-definitions/classes.ts:102:11 - error TS2322: Type 'NodeArray<HeritageClause> | undefined[]' is not assignable to type 'HeritageClause[]'.
  Type 'NodeArray<HeritageClause>' is not assignable to type 'HeritageClause[]'.
    Property '[Symbol.unscopables]' is missing in type 'NodeArray<HeritageClause>'.

102     const heritageClauses: ts.HeritageClause[] = interfaceDeclaration.heritageClauses || [];
              ~~~~~~~~~~~~~~~


type-definitions/classes.ts:113:7 - error TS2345: Argument of type 'NodeArray<Decorator>' is not assignable to parameter of type 'Decorator[]'.
  Property '[Symbol.unscopables]' is missing in type 'NodeArray<Decorator>'.

113       interfaceDeclaration.decorators,
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


type-definitions/create-type-definitions.ts:43:23 - error TS2339: Property 'push' does not exist on type 'NodeArray<Statement>'.

43 outputFile.statements.push(chromepClass);
                         ~~~~


type-definitions/create-type-definitions.ts:45:23 - error TS2339: Property 'push' does not exist on type 'NodeArray<Statement>'.

45 outputFile.statements.push(...chromepApiStatements);
                         ~~~~


type-definitions/create-type-definitions.ts:62:102 - error TS2345: Argument of type 'Identifier' is not assignable to parameter of type 'LiteralExpression | BooleanLiteral | PrefixUnaryExpression'.
  Type 'Identifier' is not assignable to type 'LiteralExpression'.

62     ts.createPropertySignature(undefined, 'Promise', createQuestionToken(), ts.createLiteralTypeNode(ts.createIdentifier('Function')), undefined),
                                                                                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


type-definitions/helpers.ts:18:10 - error TS2352: Type 'NodeArray<Node>' cannot be converted to type 'Modifier[]'.
  Property '[Symbol.unscopables]' is missing in type 'NodeArray<Node>'.

18   return ts.createNodeArray(kinds.map(k => ts.createNode(k))) as ts.Modifier[];
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@AaronNGray
Copy link
Author

towards a quick fix :-

  • ts.createIdentifier(...) can be replaced by ts.createLiteral(...)
  • outputFile.statements.push(...) does not seem to be valid code anymore

Looking at this code it would be better replaced by a transformer.

@AaronNGray
Copy link
Author

npm install --save-dev @types/chrome@0.0.96

from #32 fixed the first errors.
But I think it would be good to update type-definitions to use mode modern TypeScript code.

@nikage
Copy link

nikage commented Sep 6, 2020

npm install --save-dev @types/chrome@0.0.96

from #32 fixed the first errors.
But I think it would be good to update type-definitions to use mode modern TypeScript code.

this kinda work around helped me in this case extend-chrome/storage#11

@tscislo
Copy link

tscislo commented Oct 2, 2022

If anybody is still wondering... apparently this lib is not longer needed with Chrome manifest v3, because all Chrome APIs are already promisified. So basically there is no need for this library. @Quantumplation @tfoxy. Currently I only use it for backwards compatibility for chrome extensions that still run manifest v3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants