0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

Refactor std/types (#4713)

This commit is contained in:
Steven Guerrero 2020-04-13 12:15:18 -05:00 committed by GitHub
parent 25bd6868e5
commit 8397cd52a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 74 additions and 33085 deletions

View file

@ -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.

View file

@ -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";
```

View file

@ -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>

View file

@ -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";
```

View file

@ -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>
@ -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

View file

@ -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;

12
std/types/react/README.md Normal file
View file

@ -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";
```

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,6 @@
// These types are adapted from
// https://github.com/DefinitelyTyped/DefinitelyTyped to work under Deno.
//
// Type definitions for React 16.9
// Project: http://facebook.github.io/react/
// Definitions by: Asana <https://asana.com>
// AssureSign <http://www.assuresign.com>
@ -29,10 +28,10 @@
/* eslint-disable */
import "./react/react_global.d.ts";
import "./react_global.d.ts";
import * as CSS from "./react/csstype.d.ts";
import * as PropTypes from "./react/prop-types.d.ts";
import * as CSS from "https://cdn.jsdelivr.net/npm/csstype@2.2.0/index.d.ts";
import * as PropTypes from "../../prop-types/v15.7.2/prop-types.d.ts";
type NativeAnimationEvent = AnimationEvent;
type NativeClipboardEvent = ClipboardEvent;

View file

@ -0,0 +1,9 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
const React = {
createElement(type, props, ...children) {
return JSON.stringify({ type, props, children });
},
};
export default React;

View file

@ -2,7 +2,7 @@
// @deno-types="../react.d.ts"
import React from "./react_mock.js";
import { assertEquals } from "../../testing/asserts.ts";
import { assertEquals } from "../../../../testing/asserts.ts";
const { test } = Deno;