Skip to content

Commit

Permalink
Refactor std/types (denoland/deno#4713)
Browse files Browse the repository at this point in the history
  • Loading branch information
Soremwar authored Apr 13, 2020
1 parent 3aef099 commit 1fe4321
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 33,085 deletions.
31 changes: 18 additions & 13 deletions types/README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
# std/types

Contains types for popular external packages that are compatible with Deno.
Contains type definitions for popular external packages that are compatible with
Deno.

Because Deno only resolves fully qualified file names, type definitions that
import other type definitions might not work with Deno. Also, when some type
definition supply some global interfaces, they can conflict with Deno. The types
located here have been validated to work with Deno.

The types that are currently available:

- `react.d.ts` - For React 16. Sources known to work well for Deno:
- Pika CDN: `https://cdn.pika.dev/_/react/v16`
- JSPM: `https://dev.jspm.io/react@16`
- `react-dom.d.ts` - For ReactDOM 16. Sources known to work well for Deno:
- Pika CDN: `https://cdn.pika.dev/_/react-dom/v16`
- JSPM: `https://dev.jspm.io/react-dom@16`

There are several ways these type definitions can be referenced. Likely the
"best" way is that the CDN provider provides a header of `X-TypeScript-Types`
which points to the type definitions. We are working to have this available, but
currently you would need to use the compiler hint of `@deno-types`. For example
to import React:

```ts
// @deno-types="https://deno.land/std/types/react.d.ts"
import React from "https://cdn.pika.dev/_/react/v16";
```typescript
// @deno-types="https://deno.land/std/types/react/@16.13.1/react.d.ts"
import React from "https://cdn.pika.dev/@pika/react@v16.13.1";
```

or

```typescript
// @deno-types="https://deno.land/std/types/react/@16.13.1/react.d.ts"
import React from "https://dev.jspm.io/react@16.13.1";
```

#### Notes:

JSPM transformation of most libraries export everything through the default
namespace, so most of the time it might not be suited to work along with this
definition library.
15 changes: 15 additions & 0 deletions types/prop-types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Types for Facebook's Prop-Types library.

[![npm version](https://img.shields.io/npm/v/prop-types.svg?style=flat)](https://www.npmjs.com/package/prop-types)

You can use prop-types to document the intended types of properties passed to
functions and classes. This library is intended for his use alongside Facebook's
React library, but can be used freely for runtime type checking outside of the
React environment.

### Usage Examples

```typescript
// @deno-types="https://deno.land/std/types/prop-types/v15.7.2/prop-types.d.ts"
import PropTypes from "https://cdn.pika.dev/prop-types@15.7.2";
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// These types are adapted from
// https://github.com/DefinitelyTyped/DefinitelyTyped to work under Deno.
//
// Type definitions for prop-types 15.7
// Project: https://github.com/reactjs/prop-types, https://facebook.github.io/react
// Definitions by: DovydasNavickas <https://github.com/DovydasNavickas>
// Ferdy Budhidharma <https://github.com/ferdaber>
Expand Down
13 changes: 13 additions & 0 deletions types/react-dom/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Types for Facebook's React DOM library.

[![npm version](https://img.shields.io/npm/v/react-dom.svg?style=flat)](https://www.npmjs.com/package/react-dom)

This package serves as the entry point to the DOM and server renderers for
Facebook's React library.

### Usage Examples

```typescript
// @deno-types="https://deno.land/std/types/react-dom/v16.13.1/react-dom.d.ts"
import ReactDOM from "https://cdn.pika.dev/@pika/react-dom@v16.13.1";
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// These types are adapted from
// https://github.com/DefinitelyTyped/DefinitelyTyped to work under Deno.
//
// Type definitions for React (react-dom) 16.9
// Project: http://facebook.github.io/react/
// Definitions by: Asana <https://asana.com>
// AssureSign <http://www.assuresign.com>
Expand Down Expand Up @@ -31,7 +30,7 @@ import {
DOMElement,
ReactNode,
ReactPortal,
} from "./react.d.ts";
} from "../../react/v16.13.1/react.d.ts";

export function findDOMNode(
instance: ReactInstance | null | undefined
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

// @deno-types="../react.d.ts"
// @deno-types="../../../react/v16.13.1/react.d.ts"
import React from "./react_mock.js";
// @deno-types="../react-dom.d.ts"
import ReactDOM from "./react-dom_mock.js";

import { assertEquals } from "../../testing/asserts.ts";
import { assertEquals } from "../../../../testing/asserts.ts";

const { test } = Deno;

Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions types/react/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Types for Facebook's React library.

[![npm version](https://img.shields.io/npm/v/react.svg?style=flat)](https://www.npmjs.com/package/react)

React is a JavaScript library for building user interfaces.

### Usage Examples

```typescript
// @deno-types="https://deno.land/std/types/react/v16.13.1/react.d.ts"
import React from "https://cdn.pika.dev/@pika/react@v16.13.1";
```
Loading

0 comments on commit 1fe4321

Please sign in to comment.