mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Use the type definition of pyodide (#535)
* Import the type definition * Add type annotations
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
} from '../stores';
|
||||
import { addClasses, htmlDecode } from '../utils';
|
||||
import { BaseEvalElement } from './base';
|
||||
import type { PyodideInterface } from '../pyodide';
|
||||
|
||||
// Premise used to connect to the first available pyodide interpreter
|
||||
let pyodideReadyPromise;
|
||||
@@ -25,11 +26,6 @@ mode.subscribe(value => {
|
||||
currentMode = value;
|
||||
});
|
||||
|
||||
// TODO: use type declaractions
|
||||
type PyodideInterface = {
|
||||
registerJsModule(name: string, module: object): void;
|
||||
};
|
||||
|
||||
export class PyScript extends BaseEvalElement {
|
||||
constructor() {
|
||||
super();
|
||||
@@ -143,7 +139,7 @@ async function initHandlers() {
|
||||
}
|
||||
|
||||
/** Initializes an element with the given pys-on* attribute and its handler */
|
||||
async function createElementsWithEventListeners(pyodide: any, pysAttribute: string) {
|
||||
async function createElementsWithEventListeners(pyodide: PyodideInterface, pysAttribute: string): Promise<void> {
|
||||
const matches: NodeListOf<HTMLElement> = document.querySelectorAll(`[${pysAttribute}]`);
|
||||
for (const el of matches) {
|
||||
if (el.id.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user