Skip to content
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

Have trouble using plugin in typescript project #38

Open
chi-w-ng opened this issue Oct 1, 2023 · 3 comments
Open

Have trouble using plugin in typescript project #38

chi-w-ng opened this issue Oct 1, 2023 · 3 comments

Comments

@chi-w-ng
Copy link

chi-w-ng commented Oct 1, 2023

I encountered a 'could not resolve module' error while using it in a TypeScript project.
To replicate this issue, you can follow these steps:

Start with the Blockly TypeScript sample from:
https://github.com/google/blockly-samples/tree/master/examples/sample-app-ts

Change the tsconfig.json content to:

{
"compilerOptions": {
"baseUrl": "./",
"outDir": "dist",
"declaration": true,
"declarationMap": true,
"module": "ES2015",
"moduleResolution": "node",
"target": "ES2015",
"strict": false,
"sourceMap": true,
"allowJs": true
},
"include": ["desc.d.ts"]
}

Here is the desc.d.ts content that I add to the project root:

declare module "@mit-app-inventor/blockly-block-lexical-variables"

Add the plugin to index.ts of the blockly sample ts project. Build the project will error.

Is there a way to resolve this issue?

Thanks in advance.

@mark-friedman
Copy link
Collaborator

@chi-w-ng I don't have much Typescript experience, so I'll have to research this. One thing I would ask is whether you have run npm install mit-app-inventor/blockly-block-lexical-variables --save or the equivalent?

@chi-w-ng
Copy link
Author

chi-w-ng commented Oct 12, 2023

I have this in my package.json:

"dependencies": {
"@mit-app-inventor/blockly-block-lexical-variables": "^1.0.0",
"blockly": "^10.1.3"
}

so plugin is installed locally. I could see it in node_modules.

A duplicate of the blockly typescript sample project showing the problem is here:

https://github.com/chi-w-ng/blockly_typescript_sample

@mark-friedman
Copy link
Collaborator

@chi-w-ng I suspect that at least part of the problem is that there is no Typescript declaration file for this package. Since I don't have much Typescript experience, I wonder if you might be willing to work on this and submit a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants