deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

Include type assertion utils in std library

Open Danielduel opened this issue 4 years ago • 4 comments

It would be handy to have a standard way of writing type assertions. Main use-case is to check typings that you add on top of node module.

Examples of type assertion utils that I like:

Lib https://github.com/type-challenges/type-challenges/blob/main/utils/index.d.ts Usage https://github.com/type-challenges/type-challenges/blob/main/utils/index.d.test.ts

Lib https://github.com/TypeStrong/ts-expect/blob/master/src/index.ts Usage https://github.com/TypeStrong/ts-expect/blob/master/src/index.spec.ts Or in my PR (temporally included it from raw) https://github.com/denoland/deno_std/pull/2111/files#diff-e03f76ef798baccc36a2d182d5a954a6567fb7a18c9707a9cc8763c360759fe5R65

Danielduel avatar Apr 23 '22 15:04 Danielduel

There's also conditional-type-checks by @dsherret

kt3k avatar May 16 '22 07:05 kt3k

@kt3k I like those utils done by @dsherret, do we want to add them as dependency and reexport or should we include their copy to std after asking the author if they will be okay with that?

Danielduel avatar May 16 '22 20:05 Danielduel

@Duelsik We should include the copy of them with copyright attribution in the file header (In principle, std shouldn't depend on any external deps. ref: https://github.com/denoland/deno_std#deno-standard-modules). Copying is ok without authors' permission because they are licensed under MIT.

kt3k avatar May 17 '22 03:05 kt3k

@Duelsik We should include the copy of them with copyright attribution in the file header (In principle, std shouldn't depend on any external deps. ref: https://github.com/denoland/deno_std#deno-standard-modules). Copying is ok without authors' permission because they are licensed under MIT.

Thank you @kt3k, not sure if I did everything correctly, but did a PR that copies essential code from https://github.com/dsherret/conditional-type-checks, I've tried to infer how to put proper headers from nodes mjs file - comments are very welcome, I feel very new to copy-pasting code between repos :)

Danielduel avatar May 21 '22 15:05 Danielduel

@kt3k this issue should probably be closed now that #2864 landed?

lino-levan avatar Nov 28 '22 16:11 lino-levan