-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Remove hand crafted types for text-encoding #6
Conversation
.gitignore
Outdated
@@ -6,3 +6,4 @@ assets.go | |||
msg.pb.go | |||
msg.pb.js | |||
msg.pb.d.ts | |||
.vscode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, you can ignore this file globally so you don't have to add it to each repo individually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's nice and I did it on my machine. I think it's good to have it here too since VSCode is pretty popular these days :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it it best to keep the files in each repository specific to that project instead of about the people editing it. This project has no reliance on or interactions with VS Code. But it all comes down to personal preference in the end.
declarations.d.ts
Outdated
@@ -0,0 +1,14 @@ | |||
declare module "*.pb" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protobuf auto-generates this file based on contents inside msg.proto
, look at msg.pb.d.ts
after running:
make deno
or in case you don't want to build v8 (which takes ~30min)
make msg.pb.d.ts
@mohsen1 thanks! I applaud the effort. If you can remove text-encoding.d.ts while also not depending on |
@ry you can't import from https://github.com/ry/deno/blob/a4d89f2ee1ddde786f2335eada86f00e3efd1174/globals.ts#L54 This is the minimal declaration if you don't like to have a dependency just for types. |
tsconfig.json
Outdated
@@ -1,14 +1,13 @@ | |||
{ | |||
"compilerOptions": { | |||
"allowJs": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why removing this option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shoot! I didn't meant to dod that!
runtime.ts
Outdated
@@ -149,7 +149,7 @@ export function resolveModule( | |||
let fetchResponse; | |||
try { | |||
fetchResponse = os.codeFetch(moduleSpecifier, containingFile); | |||
} catch(e) { | |||
} catch (e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change might be fixed at #73 :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Moshen, it looks good to me, I have a few comments...
Also, please squash : )
.gitignore
Outdated
@@ -6,3 +6,4 @@ assets.go | |||
msg.pb.go | |||
msg.pb.js | |||
msg.pb.d.ts | |||
.vscode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change
package.json
Outdated
"lint": "tslint -p tsconfig.json -c tslint.json", | ||
"fmt": "prettier --write *.ts* *.js *.json" | ||
"lint": "tslint -p . && prettier --list-different \"{*.ts,js,json}\"", | ||
"fmt": "prettier --write \"{*.ts,js,json}\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change
runtime.ts
Outdated
@@ -149,7 +149,7 @@ export function resolveModule( | |||
let fetchResponse; | |||
try { | |||
fetchResponse = os.codeFetch(moduleSpecifier, containingFile); | |||
} catch(e) { | |||
} catch (e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated change
cdc3f8c
to
e5f09fe
Compare
e5f09fe
to
e54ba89
Compare
This doesn't solve the TODO. Thanks for researching it. We can revisit later with that TS issue is fixed. |
I don't understand how it would be possible to import from text-encoding module if you don't want to depend on |
A module with "text-encoding" specifier is not defined in lib.dom.d.ts. If I'm reading the code correctly you are importing a runtime value from the text encoding module and assigning it to global object. |
Right.. so somehow we need to import the implementation (polyfill) but not have typescript complain about types missing. |
To import those values from "text-encoding" module there should be a module declaration somewhere. There are two options :
|
Still WIP but comments are welcome
This change:
text-encoding
module and uses@types/text-encoding
TODO List:
TextDecoder
andTextEncoder
. It already exist indom.d.ts
*.pb
(protobuf?) files. I need help with this. Should we have a declaration per file? Can we use something like Proto2TypeScript to automate it?