refactor: strictly typed

This commit is contained in:
harttle
2019-02-23 00:49:54 +08:00
parent 51f7e66f60
commit 5b6100d12b
86 changed files with 2630 additions and 2590 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ import * as chai from 'chai'
import Scope from 'src/scope/scope'
import Output from 'src/template/output'
import OutputToken from 'src/parser/output-token'
import Filter from 'src/template/filter'
import Filter from 'src/template/filter/filter'
const expect = chai.expect
@@ -35,7 +35,7 @@ describe('Output', function () {
return expect(html).equal('{"num":2,"circular":{"bar":"bar"}}')
})
it('should skip function property', async function () {
const scope = new Scope({ obj: { foo: 'foo', bar: x => x } })
const scope = new Scope({ obj: { foo: 'foo', bar: (x: any) => x } })
const output = new Output({ value: 'obj' } as OutputToken)
const html = await output.render(scope)
return expect(html).to.equal('{"foo":"foo"}')
@@ -53,7 +53,7 @@ describe('Output', function () {
return expect(str).to.equal('FOO')
})
it('should respect to .liquid_method_missing()', async () => {
const scope = new Scope({ obj: { liquid_method_missing: x => x.toUpperCase() } })
const scope = new Scope({ obj: { liquid_method_missing: (x: string) => x.toUpperCase() } })
const output = new Output({ value: 'obj.foo' } as OutputToken)
const str = await output.render(scope)
return expect(str).to.equal('FOO')