allow extension use with unrecognized boards #29
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I tried to use this extension with my MagTag but MagTag isn't a recognized board so when I tried to select the serial monitor I got an error from project.ts about board being undefined. I put the vid and pid into settings.json, and then after reloading the window the extension failed to initialize because of board being undefined. This code makes it so if an unknown vid and pid are selected the extension continues to function, but obviously the board.pyi file will not be found.
Board.lookup just makes up a board instead of returning undefined. This makes the various places that call Board.lookup and don't check that they get a board back happy, but because the boards don't know they aren't recognized it's possible places that were expecting only CircuitPython boards will see other serial ports as if they were CircuitPython boards.
About Map and BoardData: JSON.parse never returns Map objects. Typescript doesn't know what JSON.parse is going to return so it allows you to write code that assumes the returned value will contain Maps, and because of the (lack of) runtime type system in Typescript this doesn't cause any problems as long as you don't try to use the returned value as a Map.