chrome-promise
chrome-promise copied to clipboard
update to latest TypeScript
I am having problems with using [email protected] 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 [email protected]
, 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.
I also tried building a recompiled chrome-promise
using [email protected]
and es6, and es2020, and have got 7 errors :-
C:\Users\aaron\GitHub\chrome-promise>npm run compileTypescript
> [email protected] 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[];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
npm install --save-dev @types/[email protected]
from https://github.com/tfoxy/chrome-promise/issues/32 fixed the first errors.
But I think it would be good to update type-definitions
to use mode modern TypeScript code.
npm install --save-dev @types/[email protected]
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 https://github.com/extend-chrome/storage/issues/11
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.