mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[PR #484] [MERGED] Porting (most of) code to typescript #2647
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#2647
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/484
Author: @AndrewBastin
Created: 1/11/2020
Status: ✅ Merged
Merged: 1/12/2020
Merged by: @AndrewBastin
Base:
typescript← Head:refactor/typescript📝 Commits (10+)
d24b917added oauth token ui5377c69add oauth handlerb98d907fix token placement2e7e40cdisplay error & disable input based on user input83a20bdimplement oidc discovery2a818dccomment correctiondf48e85added token managementsf847cbeAdded token management161c0b7added token request managementfdedb1f⚡ Set credentials to true. Fix #443📊 Changes
53 files changed (+1689 additions, -555 deletions)
View changed files
📝
README.md(+5 -4)📝
assets/js/curlparser.js(+1 -1)➕
assets/js/oauth.js(+185 -0)📝
components/ace-editor.vue(+17 -14)📝
components/autocomplete.vue(+14 -11)📝
components/collections/addCollection.vue(+6 -4)📝
components/collections/addFolder.vue(+6 -4)📝
components/collections/collection.vue(+8 -6)📝
components/collections/editCollection.vue(+6 -4)📝
components/collections/editFolder.vue(+6 -4)📝
components/collections/editRequest.vue(+17 -9)📝
components/collections/folder.vue(+7 -5)📝
components/collections/importExportCollections.vue(+25 -15)📝
components/collections/index.vue(+29 -27)📝
components/collections/request.vue(+5 -3)📝
components/collections/saveRequestAs.vue(+13 -11)📝
components/graphql/field.vue(+40 -8)📝
components/graphql/type.vue(+10 -6)➕
components/graphql/typelink.vue(+36 -0)📝
components/history.vue(+49 -30)...and 33 more files
📄 Description
This PR intends to complete the Typescript work which began in the
typescriptbranch.It ports every code file (except tests and pages/index.vue) to TypeScript with as much types provided.
There are certain things to note about the TypeScript addition to the project though.
Some Important Changes
There is a change in the way components are imported.
Components before could be imported with this snippet
But from this PR on, it will be:
For Vue components, you have to include the file extension.
Default Vue component code is modified a bit
Vue component scripts are used to be written as
From this PR onwards it will be
NOTE : It is also best to include an empty component script even if the component has no code logic, sometimes the compiler doesn't pick up the Vue component otherwise
Directives and Middlewares have a new code format
The way directives and middlewares are written have been revamped to work with TypeScript, please check the code in the corresponding folders, to see how it is written in the new format
Some notes on the TypeScript and Vue interaction
I noticed while porting that TypeScript compiler will freak out if it can't resolve/infer types from the component code, so if you find TypeScript giving you weird errors like (
foo is not a property of this), try explicitly specifying types, that will usually resolve that sorta issues.While adding plugins, make sure to import them into vue-plugins.d.ts file and add it to the import declaration, sometimes, it will be automatically be picked up (its a bit finicky), if you still can't access the plugin, just add the plugin reference to the Vue interface present in the same file.
Now, this PR doesn't bring full TypeScript port, pages/index.vue is due a huge refactor and it will be rewritten in TypeScript during that process. Also, tests will still be written in JavaScript.
Also, another thing to note is that, I haven't fully brought types as much as possible, some places could use more typings (and less
any), particularly the types regarding the store are implemented withanyas a placeholder. This needs to be refactored into more meaningful type definitions in the future.Soooo, that's about it,
Happy hacking 😄
This PR may fix #467
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.