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

Typescriptify VII 📺 #751

Merged
merged 1 commit into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ export default args => [
}
},
{
input: 'tests/index.js',
input: 'tests/index.ts',
plugins: [
...commonPlugins(),
globImport(),
globImport({
// without this option, the plugin will try to parse imported files (as
// JS) and fail with TS files
format: 'import'
}),
copy({
targets: [
{ src: 'dist/mobiledoc.js', dest: 'assets/demo' },
Expand Down
4 changes: 2 additions & 2 deletions src/js/models/atom-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface AtomRenderOptions {
payload: JsonData
}

export type AtomRenderHook = (options: AtomRenderOptions) => Maybe<Element>
export type AtomRenderHook = (options: AtomRenderOptions) => Maybe<Element | Text> | void

export type AtomData = {
name: string
Expand Down Expand Up @@ -46,7 +46,7 @@ export default class AtomNode {
model: { value, payload },
} = this
// cache initial render
this._rendered = this.atom.render({ options, env, value, payload })
this._rendered = this.atom.render({ options, env, value, payload }) || null
}

this._validateAndAppendRenderResult(this._rendered!)
Expand Down
13 changes: 7 additions & 6 deletions src/js/models/card-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Dict, Maybe } from '../utils/types'

export type CardNodeOptions = Dict<unknown>

export type CardRenderHook = (...args: any[]) => Maybe<Element>
export type CardRenderHook = (...args: any[]) => void | Maybe<Element>

type DidRenderCallback = null | (() => void)
type TeardownCallback = null | (() => void)
Expand Down Expand Up @@ -54,11 +54,12 @@ export default class CardNode {
let method = this.card[methodName]

assert(`Card is missing "${methodName}" (tried to render mode: "${mode}")`, !!method)
let rendered = method({
env: this.env,
options: this.options,
payload: this.section.payload,
})
let rendered =
method({
env: this.env,
options: this.options,
payload: this.section.payload,
}) || null

this._validateAndAppendRenderResult(rendered)
}
Expand Down
197 changes: 0 additions & 197 deletions tests/acceptance/basic-editor-test.js

This file was deleted.

Loading