Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ulisses-alves/elm-types
https://github.com/ulisses-alves/elm-types
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ulisses-alves/elm-types
- Owner: ulisses-alves
- License: mit
- Created: 2020-02-14T10:14:37.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-14T13:25:06.000Z (almost 5 years ago)
- Last Synced: 2024-11-05T19:08:35.620Z (2 months ago)
- Language: TypeScript
- Size: 4.88 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elm-types
TypeScript type definitions for Elm bundled applications.```
npm install -D elm-types
```## Usage:
1. First create type definitions for your application:
```typescript
// App.ts
import * as Elm from 'elm-types'export type App = Elm.Document
export type Flags = {}
export type Ports = Elm.Ports<{
sayHello: Elm.IncomingPort
}>```
2. Then type definitions for the .elm file. This only applies if you are using a bundler such as Parcel, Webpack, Rollup, etc, where you import the .elm file directly:
```typescript
// App.elm.d.ts (must be placed next to your App.elm file)
import {Bundle} from 'elm-types'
import {App} from './App.ts'export const Elm: Bundle<{App: App}>
```3. Finally import the .elm file. If everything worked correctly, all the code below will be correctly typed.
```typescript
// main.ts
import {Elm} from './App.elm'const app = Elm.App.init({
flags: {}
})app.ports.sayHello.send('Hello from TypeScript!')
```Check out `example/` for a complete setup using Parcel.