Skip to content

Add Typescript typechecking, generate types with tsc#153

Merged
nrabinowitz merged 5 commits into
uber:masterfrom
nrabinowitz:typescript-libdef
Aug 22, 2022
Merged

Add Typescript typechecking, generate types with tsc#153
nrabinowitz merged 5 commits into
uber:masterfrom
nrabinowitz:typescript-libdef

Conversation

@nrabinowitz
Copy link
Copy Markdown
Collaborator

  • Adds type-checking via tsc --noEmit
  • Updates types in JSDoc comments to fix TS errors
  • Drops tsd-jsdoc in favor of generating the library types with tsc --declaration
  • Adds types for CoordPair and SplitLong, post-processing the libdef to use [number, number] instead of number[] (this is a workaround for Support Tuples jsdoc/jsdoc#1703, which kills doc generation if we use [number, number] directly in JSDoc comments)

Fixes #152

@isaacbrodsky
Copy link
Copy Markdown
Collaborator

Can this be merged after v4.0.0 is released in both core library & JS?

@nrabinowitz
Copy link
Copy Markdown
Collaborator Author

Can this be merged after v4.0.0 is released in both core library & JS?

Technically changing types could be considered breaking for TS users, so I'd prefer to land this pre-release.

Nick Rabinowitz added 2 commits August 22, 2022 09:43
@coveralls
Copy link
Copy Markdown

coveralls commented Aug 22, 2022

Pull Request Test Coverage Report for Build 2907065074

  • 22 of 22 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.2%) to 99.844%

Totals Coverage Status
Change from base Build 2878765090: -0.2%
Covered Lines: 529
Relevant Lines: 529

💛 - Coveralls

Comment thread package.json Outdated
"build-docs": "jsdoc2md --no-cache --global-index-format grouped --partial doc-files/scope.hbs --helper ./doc-files/insert-version.js --separators --template doc-files/README.tmpl.md lib/h3core.js lib/errors.js > README.md",
"build-tsd-core": "jsdoc -t node_modules/tsd-jsdoc/dist -d console lib/h3core.js | sed 's/\"h3\"/\"h3-js\"/g' > dist/types.d.ts",
"build-tsd-core": "tsc lib/h3core.js --noResolve --skipLibCheck --allowJs --declaration --emitDeclarationOnly --outFile dist/types.d.ts && yarn build-tsd-core-postprocess",
"build-tsd-core-postprocess": "sed 's/module \"h3core\"/module \"h3-js\"/g' dist/types.d.ts > types.d.ts.tmp && sed -E -e 's/(CoordPair|SplitLong) = number\\[\\]/\\1 = [number,number]/g' types.d.ts.tmp > dist/types.d.ts && rm types.d.ts.tmp",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Maybe this logic should be in a script file so that comments can be added to it? This is a little 'magical'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Agree, I can take a look at moving this into a script

@nrabinowitz nrabinowitz merged commit ece84ef into uber:master Aug 22, 2022
@nrabinowitz nrabinowitz deleted the typescript-libdef branch August 22, 2022 21:15
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.

Documentation of the [lat, lng] tuple

3 participants