-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Typed library #29
base: master
Are you sure you want to change the base?
Typed library #29
Conversation
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.
- Please move all typings to
/types
, see example: https://github.com/metarhia/metatests - Add https://www.npmjs.com/package/@types/node to dependencies for builtin node.js libraries, for example
BaseOptions
- Use interfaces in most cases
lib/loader.d.ts
Outdated
import { BaseOptions } from 'vm'; | ||
import { MetaScript } from './vm'; | ||
|
||
export declare const readScript: ( |
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.
export declare const readScript: ( | |
export declare { | |
function readScript( |
lib/vm.d.ts
Outdated
type VMCtxNodeKeys = | ||
| 'Buffer' | ||
| 'console' | ||
| 'queueMicrotask' | ||
| 'setTimeout' | ||
| 'setImmediate' | ||
| 'setInterval' | ||
| 'clearTimeout' | ||
| 'clearImmediate' | ||
| 'clearInterval'; | ||
|
||
type VMContextNodeTypes = { | ||
[key in VMCtxNodeKeys]: NodeJS.Global[key]; | ||
}; |
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.
We don't need to specify this certain list
lib/vm.d.ts
Outdated
[key in VMCtxNodeKeys]: NodeJS.Global[key]; | ||
}; | ||
|
||
type VMContextLibDOMTypes = { |
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.
Use interfaces instead of types
lib/vm.d.ts
Outdated
constructor( | ||
name: string, | ||
src: string, | ||
options?: vm.ScriptOptions & { context: vm.Context } |
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.
Need new interface for options
lib/vm.d.ts
Outdated
export declare const createScript: ( | ||
name: string, | ||
src: string, | ||
options?: vm.ScriptOptions & { context: vm.Context } | ||
) => MetaScript; |
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.
export declare const createScript: ( | |
name: string, | |
src: string, | |
options?: vm.ScriptOptions & { context: vm.Context } | |
) => MetaScript; | |
function createScript(name: string, src: string, options?: MetaOptions): MetaScript; |
Tried replacing the parts you emphasized on. May I ask why would it be necessary to stick with interfaces? I was pretty concerned that the "type" structure is more powerful until now. |
Hello, please review the typings I wrote and approve if valid.