refactor(iframe): [PKG-IFRAME-04] preserve types across module consumers

This commit is contained in:
Harvey Zhao committed 2026-09-13 01:43:09 +08:00
1 parent 1342de94ef
commit 047e2df945
24 files changed
+1496 -69

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
/* eslint-disable ts/no-require-imports -- Verify native TypeScript CommonJS constructor imports. */
import Iframe = require('artplayer-tool-iframe')
import Legacy = require('artplayer-tool-iframe/legacy')
declare const frame: HTMLIFrameElement
const option: Iframe.Option = { iframe: frame, url: '/frame' }
const tool: Iframe = new Iframe(option)
const old: Legacy = new Legacy(option)
const message: Iframe.Message<number> = { type: 'custom', data: 2 }
tool.postMessage(message)
old.commit(() => {
return 2
})
// @ts-expect-error Direct CommonJS constructor has no default namespace.
const wrong = Iframe.default
void wrong