Skip to content

Commit

Permalink
Typescriptify VII 📺 (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeeJab authored Dec 16, 2020
1 parent e8454e3 commit 79a37b6
Show file tree
Hide file tree
Showing 12 changed files with 788 additions and 821 deletions.
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

0 comments on commit 79a37b6

Please sign in to comment.