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

5 update add type declaration dts file #6

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

dpeachpeach
Copy link

Adding type declarations for the src code.

@dpeachpeach dpeachpeach linked an issue Sep 1, 2023 that may be closed by this pull request
@lixun910
Copy link
Member

lixun910 commented Sep 5, 2023

Thanks @dpeachpeach! The next step is to combine these d.ts files into index.d.ts, which will work with index.js under lib directory. To make the type declaration index.d.ts working, you also need to add the following line in package.json:

  "main": "./lib/index.js",
 + "types": "./lib/index.d.ts",

@@ -18,6 +18,7 @@
"babelify": "^10.0.0",
"base64-js": "^1.5.1",
"compression-webpack-plugin": "^7.1.2",
"dts-bundle": "^0.7.3",
Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines +1 to +2
import GeoDaLisa from './geoda-lisa';
import GeoDaWeights from './geoda-weights';
Copy link
Member

Choose a reason for hiding this comment

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

import types GeoDaLisa and GeoDaWeights that have been used in functions like getDistanceWeights(): GeoDaWeights instead of getDistanceWeights(): any

Comment on lines +1 to +3
import GeoDaWasm from "./geoda-proxy";

export function New(): Promise<GeoDaWasm>;
Copy link
Member

Choose a reason for hiding this comment

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

Manually added index.d.ts to expose New() function, which is the only entry of the jsgeoda library, and return GeoDaWasm type.

Comment on lines +12 to +15
dts.bundle({
name: 'jsgeoda',
main: 'src/index.d.ts',
out: '../lib/index.d.ts'
Copy link
Member

Choose a reason for hiding this comment

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

Use dts-bundle in webpack to merge multiple d.ts typings into lib/index.d.ts @dpeachpeach

@lixun910
Copy link
Member

lixun910 commented Sep 5, 2023

@dpeachpeach See my changes and comments above. You should be able to run yarn and then yarn build:bundle to generate the file lib/index.d.ts for the library.

@lixun910 lixun910 force-pushed the 5-update-add-type-declaration-dts-file branch from 4f73eb1 to f4e5d69 Compare September 5, 2023 20:47
@dpeachpeach
Copy link
Author

Hey @lixun910 , I successfully generated the file and it is more precise but it still seems like it sets multiple type signatures to any. We can discuss in the meeting.

@lixun910
Copy link
Member

lixun910 commented Sep 8, 2023

@dpeachpeach I've made some changes to this branch, you can do git pull to get these changes on your side. The index.d.ts should be auto-generated when you run yarn build.

@lixun910
Copy link
Member

lixun910 commented Sep 8, 2023

@dpeachpeach Please also update the version to 0.2.10 in package.json Thanks!

@@ -37,6 +38,7 @@
"version": "0.2.9",
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
"version": "0.2.9",
"version": "0.2.10",

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

Successfully merging this pull request may close these issues.

Update: add type declaration d.ts file
2 participants