Pull CPP files (Online makecode.microbit.org)

Hi @mwest226,

I tried to create a fork and then “import” the fork (not add it as an extension, import the repo into MakeCode as a project). It didn’t work, which may mean there are still errors in the configuration. shim.d.ts should be automatically generated for you by the compile process. (Notice the “Auto-generated” comment in this example)

I think the error may be partly due to the lack of actual typescript shims. Most extensions have both a .ts version of functions and a .cpp version. The .ts version is used in the simulator and to specify the API for TypeScript and the .cpp code is used in compiled/deployed projects.

I suspect you’ll need a .ts file in the project with something like:

//% color=#00FFFF 
//% icon="\ue0b7"
//% block="Flash Storage"
namespace flashstorage {
    //% blockId="getData" block="get data for %key|"
    //% shim=flashstorage::getData
    export function getData(key: string): string {
        // Per https://github.com/microsoft/pxt-microbit/issues/4292
        0;
        // The above will do nothing in the simulator, but your application could actually use TypeScript map for simulation purposes. 
    }
}

The i2c project I mentioned earlier is a pretty minimal example: https://github.com/bsiever/microbit-pxt-i2cpins . The i2crr.cpp has a corresponding i2crr.ts that declares the API for TypeScript. This includes things like block names, hints, tool box names, toolbox color, etc. It also designates the C++ function that should be used when running on the device.