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

Use TypeScript instead of JavaScript #3

Open
Jaykingamez opened this issue Oct 28, 2022 · 3 comments
Open

Use TypeScript instead of JavaScript #3

Jaykingamez opened this issue Oct 28, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@Jaykingamez
Copy link
Contributor

It will be pretty annoying to declare types for the various HTML elements, but it has to be done.

Still, if we do so, what bundler should we use rollup or webpack?

@Linnest2020
Copy link
Owner

Yep, Typescript is neccessary for developing, change the repo into Typescript was listed in TODO list, however, it is limitied by two problem

  1. I haven't learn how to use Typescript yet
  2. Using Typescript may bring some barrier for adding new features, thoght the editor started to get stable

@Jaykingamez
Copy link
Contributor Author

Jaykingamez commented Oct 28, 2022

Perhaps you would like to organize it around a framework like React or Angular?

Anyway, the current JS code can be pasted in typescript, the only things to change would be declaring types.

@Linnest2020
Copy link
Owner

type state_detail_private_type = {
state_type:"corporated"|"incorporated"|"treaty_port"|("corporated"|"incorporated"|"treaty_port")[]
country:string
owned_provinces:string[]
}
type state_detail_type = {
create_state:(state_detail_private_type|state_detail_private_type[])
add_claim?:string|string[]
add_homeland?:string|string[]
}
type history_dict_type = {
STATES:{[key:string]:state_detail_type}
}

You can see I post a ROUGH TypeScript Version on it, and the code above is the interface of 00_states.txt, however, when it comes with actual usage:

full_map_data.histroy_state_dict["STATES"][old_state]["create_state"]["owned_provinces"] = full_map_data.histroy_state_dict["STATES"][old_state]["create_state"]["owned_provinces"].filter((item:string) => item!=prov)

It would raise error

And then, when I complite with tsc, it don't works(warning at Uncaught ReferenceError: exports is not defined at index.js:2:1)

@Linnest2020 Linnest2020 pinned this issue Oct 29, 2022
@Linnest2020 Linnest2020 added the enhancement New feature or request label Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants