forked from buefy/buefy
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TypeScript Rollout Tier 8 - Select (#368)
* feat(lib): rewrite Select in TS Rewrites `components/select/Select.vue` in TypeScript: - Replaces chaining of `emit` and `checkHtml5Validity` on blur events with a call of the `onBlur` method provided by `FormElementMixin`. This also fixes the issue @ntohq/buefy-next#271. - Casts `modelValue` as `ModelValue` which is equal to `any` (see below), because Vue fails to infer the prop type if the `type` array includes `null` and ends up with failing to infer the entire component type. Explicitly casting `modelValue` with `PropType` works around the problem. - Introduces a new type `ModelValue` which represents the type of the `modelValue` prop to avoid spreading `any` all around the code. I chose `any` for the model value type, because it is intended to accept any values. - Trivial changes: - Imports `BIcon` and explicitly gives it the name when it is registered so that type checking works. No type checking works on globally registered components - Gives minimal types - Adds `lang="ts"` to the `setup` section - Wraps the entire component with a `defineComponent` call - Makes a comment non-JSDoc style so that `@microsoft/api-extractor` won't pick it up Rewrites `components/select/index` in TypeScript: - Replaces the extension: `.js` → `.ts` - Types the `Plugin.install` method * test(lib): rewrite Select.spec in TS Rewrites `components/select/Select.spec` in TypeScript. Changes are all straightforward: - Replaces the extension: `.js` → `.ts` - Imports necessary functions from `vitest` - Appends the `.vue` extension to the line importing `BSelect` - Types `wrapper` with `VueWrapper` Replaces the test snapshot in `components/select/__snapshots__`: - `Select.spec.js.snap` → `Select.spec.ts.snap` * chore(lib): bundle select as TS `rollup.config.mjs` removes "select" from `JS_COMPONENTS`. * feat(docs): rewrite Select docs in TS Rewrites docs for `Select` in `pages/components/select`. All the changes are straightforward. Here is a TypeScript migration tip: - Explicitly import and register components so that they are type checked. No type-checking is performed for globally registered components.
- Loading branch information
Showing
12 changed files
with
78 additions
and
33 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
6 changes: 4 additions & 2 deletions
6
...next/src/components/select/Select.spec.js → ...next/src/components/select/Select.spec.ts
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
7 changes: 0 additions & 7 deletions
7
packages/buefy-next/src/components/select/__snapshots__/Select.spec.js.snap
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
packages/buefy-next/src/components/select/__snapshots__/Select.spec.ts.snap
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,7 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`BSelect > render correctly 1`] = ` | ||
"<div class=\\"control\\"><span class=\\"select is-empty\\"><select><!--v-if--></select></span> | ||
<!--v-if--> | ||
</div>" | ||
`; |
3 changes: 2 additions & 1 deletion
3
...buefy-next/src/components/select/index.js → ...buefy-next/src/components/select/index.ts
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
File renamed without changes.
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
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