This file contains hidden or 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
const INIT_VIEW: Pick<MapProps, 'center'|'zoom'|'pitch'|'bearing'|'style'> = { | |
center: [-73.991284, 40.741263], | |
zoom: [14.5], | |
pitch: [45], | |
bearing: [-17.6], | |
style: "mapbox://styles/mapbox/streets-v9" | |
}; |
This file contains hidden or 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
const INIT_VIEW: Partial<Props> = { | |
center: [-73.991284, 40.741263], | |
zoom: [14.5], | |
pitch: [45], | |
bearing: [-17.6], | |
}; | |
export function render(): JSX.Element { | |
return ( | |
<Map |
This file contains hidden or 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
export interface Props { | |
style: string | MapboxGl.Style; | |
center?: [number, number]; | |
zoom?: [number]; | |
maxBounds?: MapboxGl.LngLatBounds | FitBounds; | |
fitBounds?: FitBounds; | |
fitBoundsOptions?: FitBoundsOptions; | |
bearing?: [number]; | |
pitch?: [number]; | |
containerStyle?: React.CSSProperties; |
This file contains hidden or 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
import * as React from 'react'; | |
import ReactMapboxGl from 'react-mapbox-gl'; | |
const Map = ReactMapboxGl({ | |
accessToken: '....', | |
}); | |
export function render(): JSX.Element { | |
return ( | |
<Map |
This file contains hidden or 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
interface Order { | |
what: Product; | |
how: 'bitcoin' | 'usd'; | |
} | |
const order: Order = { | |
what: 'Macbook Air', | |
how: 'bitcoin' | |
}; | |
purchase(order.what); // ok |
This file contains hidden or 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
const order = { | |
what: 'Macbook Air' as Product, // or "as 'MacbookAir'" | |
how: 'bitcoin' | |
}; | |
purchase(order.what); // ok |
This file contains hidden or 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
const order = { | |
what: 'Macbook Air', | |
how: 'bitcoin' | |
}; | |
order.what = 'Lenovo'; // valid |
This file contains hidden or 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
let newToy: Product = 'Macbook Air'; | |
purchase(newToy); // ok |
This file contains hidden or 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
purchase('Macbook Air'); | |
const newToy = 'Macbook Air'; | |
purchase(newToy); // ok |
This file contains hidden or 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
type Product = 'iPad' | 'Mac Mini' | 'Macbook Air' | 'Macbook Pro'; | |
export function purchase(what: Product) { | |
// mine bitcoin… | |
// send to apple… | |
} |