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

Add all typescript types for web-js #68

Closed
wants to merge 4 commits into from

Conversation

mario-fehr
Copy link

@mario-fehr mario-fehr commented Jan 25, 2022

closes #67

Copy link
Member

@alexander-schranz alexander-schranz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mfehr94 Thx for the pull request. I think in some files the jsdocs is missing and so some any was added to some methods. We should where possible fix the jsdocs and update the typescript types. Also analyse why some .d.ts seems to have some methods or props just missing.

tsconfig.json Outdated
Comment on lines 1 to 10
{
"include": ["packages/**/*"],
"compilerOptions": {
"allowJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "types",
"declarationMap": true
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
"include": ["packages/**/*"],
"compilerOptions": {
"allowJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "types",
"declarationMap": true
}
}
{
"include": ["packages/**/*"],
"compilerOptions": {
"allowJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "types",
"declarationMap": true
}
}

@@ -0,0 +1,5 @@
declare function _exports(): {
initialize: (el: HTMLElement, options: object) => void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we can provide a interface for this? So we don't need declare this over again?

@@ -0,0 +1,6 @@
export declare function get(uri: any, data: any): Promise<any>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uri: any looks false, same for data: any

@@ -0,0 +1,5 @@
export const registerComponent: any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks weird?

Why looks this different then the core.js?

Copy link
Author

@mario-fehr mario-fehr May 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of this declaration:

var lazy = {
       componentRegistry: {},
       serviceRegistry: {},
       deferredComponents: {},
       deferredServices: {},
   };

@@ -0,0 +1,14 @@
declare namespace web { }
import registerComponent = web.registerComponent;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does typescript correctly read the types from jsdocs here?

* @param {String} name
* @param {Object} component
* @param {Object} defaultOptions

So it will correctly fail if it is called with something else?

@@ -0,0 +1,3 @@
declare function _exports(func: any, wait: any, immediate: any): (...args: any[]) => void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsdocs should be defined correctly so it will also get func: any, wait: int correctly:

* Extracted from UnderscoreJS
*
* @ignore

initialize: (el: HTMLElement, options: object) => void;
};
export = _exports;
//# sourceMappingURL=accordion.d.ts.map
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the map files?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexander-schranz if you want to provide autocomplitons for IDE yes, if not it can be disabled with "declarationMap": false

@@ -0,0 +1 @@
{"version":3,"file":"accordion.d.ts","sourceRoot":"","sources":["../../../packages/components/accordion/accordion.js"],"names":[],"mappings":"AAIiB;qBAsCF,WAAW,WACX,MAAM;EA0EpB"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are this files required?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexander-schranz if you want to provide autocomplitons for IDE yes, if not it can be disabled with "declarationMap": false

Comment on lines +1 to +2
export const key: string;
export const promise: any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me looks here are all methods missing.

@mario-fehr
Copy link
Author

@alexander-schranz thank you for the first review and the suggestions. This are autogenerated types from typescript compiler and just a quick starting point for me to work on. I will check the JSCodes and try to fix them, also adding the missing props and methods as soon as possible.

@alexander-schranz
Copy link
Member

@mfehr94 Do we even need the .ts files if we provide all type information over JSDocs: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html ?

@mario-fehr
Copy link
Author

mario-fehr commented Jan 29, 2022

@alexander-schranz good possible, I must test that and add the missing JSDocs. At the moment type script don't like the import of the web in custom JS components in my test project.

deferredComponents: {},
deferredServices: {},
};
var lazy = {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var lazy = {};
var lazy = {
componentRegistry: {},
serviceRegistry: {},
deferredComponents: {},
deferredServices: {},
};

This object should stay as before.

@mario-fehr mario-fehr closed this Sep 21, 2023
@mario-fehr mario-fehr deleted the feature/typescript-types branch September 21, 2023 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide Typescript types
2 participants