-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix broken types for Vue, React and Preact (#101)
* chore: improve tests delays * tests(vue): add types and errors tests * fix(vue): sync-map types * tests(react): add types and errors tests * fix(react): sync-map types * tests(preact): add types and errors tests * fix(preact): sync-map types * chore: cleanup
- Loading branch information
Showing
10 changed files
with
190 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { MapStore} from 'nanostores' | ||
import { map } from 'nanostores' | ||
|
||
import { syncMapTemplate } from '../sync-map-template/index.js' | ||
import { useFilter, useSync } from './index.js' | ||
|
||
type Post = { | ||
id: string | ||
title: string | ||
} | ||
|
||
let $post = syncMapTemplate<Post>('posts') | ||
|
||
let post = useSync($post, '10') | ||
let postList = useFilter($post, { id: '10' }) | ||
|
||
let $custom = (id: string): MapStore<Post> => map({ id, text: 'A' }) | ||
let custom = useSync($custom, '10') | ||
|
||
if (post.isLoading) { | ||
// THROWS Property 'title' does not exist | ||
post.title = 'New title' | ||
} | ||
|
||
let postListItem = postList.stores.get('10')!.value! | ||
if (postListItem.isLoading) { | ||
// THROWS Property 'title' does not exist | ||
postListItem.title = 'New title' | ||
} | ||
|
||
if (custom.isLoading) { | ||
// THROWS Property 'title' does not exist | ||
custom.title = 'B' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { MapStore} from 'nanostores' | ||
import { map } from 'nanostores' | ||
|
||
import { syncMapTemplate } from '../sync-map-template/index.js' | ||
import { useFilter, useSync } from './index.js' | ||
|
||
type Post = { | ||
id: string | ||
title: string | ||
} | ||
|
||
let $post = syncMapTemplate<Post>('posts') | ||
|
||
let post = useSync($post, '10') | ||
let postList = useFilter($post, { id: '10' }) | ||
|
||
let $custom = (id: string): MapStore<Post> => map({ id, text: 'A' }) | ||
let custom = useSync($custom, '10') | ||
let customList = useFilter($custom, { id: '10' }) | ||
|
||
console.log({ custom, customList, post, postList }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { MapStore} from 'nanostores' | ||
import { map } from 'nanostores' | ||
|
||
import { syncMapTemplate } from '../sync-map-template/index.js' | ||
import { useFilter, useSync } from './index.js' | ||
|
||
type Post = { | ||
id: string | ||
title: string | ||
} | ||
|
||
let $post = syncMapTemplate<Post>('posts') | ||
|
||
let post = useSync($post, '10') | ||
let postList = useFilter($post, { id: '10' }) | ||
|
||
let $custom = (id: string): MapStore<Post> => map({ id, text: 'A' }) | ||
let custom = useSync($custom, '10') | ||
|
||
if (post.isLoading) { | ||
// THROWS Property 'title' does not exist | ||
post.title = 'New title' | ||
} | ||
|
||
let postListItem = postList.stores.get('10')!.value! | ||
if (postListItem.isLoading) { | ||
// THROWS Property 'title' does not exist | ||
postListItem.title = 'New title' | ||
} | ||
|
||
if (custom.isLoading) { | ||
// THROWS Property 'title' does not exist | ||
custom.title = 'B' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { MapStore} from 'nanostores' | ||
import { map } from 'nanostores' | ||
|
||
import { syncMapTemplate } from '../sync-map-template/index.js' | ||
import { useFilter, useSync } from './index.js' | ||
|
||
type Post = { | ||
id: string | ||
title: string | ||
} | ||
|
||
let $post = syncMapTemplate<Post>('posts') | ||
|
||
let post = useSync($post, '10') | ||
let postList = useFilter($post, { id: '10' }) | ||
|
||
let $custom = (id: string): MapStore<Post> => map({ id, text: 'A' }) | ||
let custom = useSync($custom, '10') | ||
let customList = useFilter($custom, { id: '10' }) | ||
|
||
console.log({ custom, customList, post, postList }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import type { MapStore} from 'nanostores' | ||
import { map } from 'nanostores' | ||
|
||
import { syncMapTemplate } from '../sync-map-template/index.js' | ||
import { useFilter, useSync } from './index.js' | ||
|
||
type Post = { | ||
id: string | ||
title: string | ||
} | ||
|
||
let $post = syncMapTemplate<Post>('posts') | ||
|
||
let post = useSync($post, '10') | ||
let postList = useFilter($post, { id: '10' }) | ||
|
||
let $custom = (id: string): MapStore<Post> => map({ id, text: 'A' }) | ||
let custom = useSync($custom, '10') | ||
|
||
if (post.value.isLoading) { | ||
// THROWS Property 'title' does not exist | ||
post.value.title = 'New title' | ||
} else { | ||
// THROWS Cannot assign to 'title' because it is a read-only | ||
post.value.title = 'New title' | ||
} | ||
|
||
let postListItem = postList.value.stores.get('10')!.value! | ||
if (postListItem.isLoading) { | ||
// THROWS Property 'title' does not exist | ||
postListItem.title = 'New title' | ||
} else { | ||
// THROWS Cannot assign to 'title' because it is a read-only | ||
postListItem.title = 'New title' | ||
} | ||
|
||
if (custom.value.isLoading) { | ||
// THROWS Property 'title' does not exist | ||
custom.value.title = 'B' | ||
} else { | ||
// THROWS Cannot assign to 'title' because it is a read-only | ||
custom.value.title = 'B' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { MapStore} from 'nanostores' | ||
import { map } from 'nanostores' | ||
|
||
import { syncMapTemplate } from '../sync-map-template/index.js' | ||
import { useFilter, useSync } from './index.js' | ||
|
||
type Post = { | ||
id: string | ||
title: string | ||
} | ||
|
||
let $post = syncMapTemplate<Post>('posts') | ||
|
||
let post = useSync($post, '10') | ||
let postList = useFilter($post, { id: '10' }) | ||
|
||
let $custom = (id: string): MapStore<Post> => map({ id, text: 'A' }) | ||
let custom = useSync($custom, '10') | ||
let customList = useFilter($custom, { id: '10' }) | ||
|
||
console.log({ custom, customList, post, postList }) |