-
Notifications
You must be signed in to change notification settings - Fork 78
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
When producing types declarations, also emit the static types of the interfaces for TypeScript declarations. #284
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,10 @@ function Module(moduleName: string, schema: IProtocol): string { | |
s += line(" *--------------------------------------------------------------------------------------------*/"); | ||
s += line(); | ||
|
||
//s += comment(schema.description); | ||
s += comment({ description: 'Declaration module describing the VS Code debug protocol.\nAuto-generated from json schema. Do not edit manually.'}); | ||
|
||
s += line(); | ||
|
||
s += comment({ description: schema.description }); | ||
s += openBlock(`export declare module ${moduleName}`); | ||
|
||
for (let typeName in schema.definitions) { | ||
|
@@ -77,7 +78,7 @@ function Interface(interfaceName: string, definition: P.Definition, superType?: | |
|
||
let s = line(); | ||
|
||
s += comment({ description : desc }); | ||
s += comment({ description: desc }); | ||
|
||
let x = `interface ${interfaceName}`; | ||
if (superType) { | ||
|
@@ -247,11 +248,7 @@ function property(name: string, optional: boolean, prop: P.PropertyType): string | |
s += comment(prop); | ||
const type = propertyType(prop); | ||
const propertyDef = `${name}${optional ? '?' : ''}: ${type}`; | ||
if (type[0] === '\'' && type[type.length-1] === '\'' && type.indexOf('|') < 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, can you give an example of what changed here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, it's basically all of the type/event/command parameters. It's not clear to me why we are emitting these commented out. And does add a constraint but, for example, if you implemented one of the event types and set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think TypeScript will check that the event type (or type, etc.) matches the expected value if you where to try to use the wrong type. |
||
s += line(`// ${propertyDef};`); | ||
} else { | ||
s += line(`${propertyDef};`); | ||
} | ||
s += line(`${propertyDef};`); | ||
return s; | ||
} | ||
|
||
|
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.
Not sure about this, it seems like the intent is not to emit DAP events but just errors and the like.
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.
The emitter is typed as emitting
DebugProtocolMessage
's, but that's just an empty interface 🤷 I think it'd make sense to emit them hereThere 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.
But it's weird that it's also emitting non-DAP errors from the same emitter. But also that events currently aren't going anywhere? Do you have some more context on how this works at all currently @ashgti?
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 wasn't sure if there was a way to get DAP events if you used the adapter programmatically, but when I added the types here I noticed that events weren't being handled.
I can revert this part, it just seemed like a missing piece of the adapter.
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 think this method is only handling the data stream from the client, so this would only be hit if the client sends an event. I don't think that happens for any event types, or does it?
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.
It doesn't happen for any event types, removed.