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:
parent
25bd6868e5
commit
8397cd52a5
14 changed files with 74 additions and 33085 deletions
|
@ -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
std/types/prop-types/README.md
Normal file
15
std/types/prop-types/README.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
Types for Facebook's Prop-Types library.
|
||||
|
||||
[](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";
|
||||
```
|
|
@ -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>
|
13
std/types/react-dom/README.md
Normal file
13
std/types/react-dom/README.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
Types for Facebook's React DOM library.
|
||||
|
||||
[](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";
|
||||
```
|
|
@ -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
|
|
@ -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
12
std/types/react/README.md
Normal file
|
@ -0,0 +1,12 @@
|
|||
Types for Facebook's React library.
|
||||
|
||||
[](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";
|
||||
```
|
33062
std/types/react/csstype.d.ts
vendored
33062
std/types/react/csstype.d.ts
vendored
File diff suppressed because it is too large
Load diff
|
@ -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;
|
9
std/types/react/v16.13.1/tests/react_mock.js
Normal file
9
std/types/react/v16.13.1/tests/react_mock.js
Normal 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;
|
|
@ -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;
|
||||
|
Loading…
Add table
Reference in a new issue