-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1242 from iuioiua/deprecation-guide
docs: point to new "Deno 1.x to 2.x Migration Guide"
- Loading branch information
Showing
2 changed files
with
48 additions
and
163 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,170 +1,55 @@ | ||
Warns the usage of the deprecated Deno APIs | ||
Warns the usage of the deprecated - Deno APIs | ||
|
||
The following APIs in the `Deno` namespace are now marked as deprecated and will | ||
be removed from the namespace in Deno 2.0. | ||
|
||
**IO APIs** | ||
The following APIs will be removed from the `Deno.*` namespace but have newer | ||
APIs to migrate to. See the | ||
[Deno 1.x to 2.x Migration Guide](https://docs.deno.com/runtime/manual/advanced/migrate_deprecations) | ||
for migration instructions. | ||
|
||
- `Deno.Buffer` | ||
- `Deno.copy` | ||
- `Deno.iter` | ||
- `Deno.iterSync` | ||
- `Deno.readAll` | ||
- `Deno.readAllSync` | ||
- `Deno.writeAll` | ||
- `Deno.writeAllSync` | ||
|
||
Most of these APIs have been moved to [`std/io`](https://deno.land/std/io) of | ||
the Deno Standard Library. For more detail, see | ||
[the tracking issue](https://github.com/denoland/deno/issues/9795). | ||
|
||
**Sub Process API** | ||
|
||
- `Deno.run` | ||
|
||
`Deno.run` was deprecated in favor of `Deno.Command`. See | ||
[deno#9435](https://github.com/denoland/deno/discussions/9435) for more details. | ||
|
||
**Custom Inspector API** | ||
|
||
- `Deno.Closer` | ||
- `Deno.close()` | ||
- `Deno.Conn.rid` | ||
- `Deno.copy()` | ||
- `Deno.customInspect` | ||
|
||
`Deno.customInspect` was deprecated in favor of | ||
`Symbol.for("Deno.customInspect")`. Replace the usages with this symbol | ||
expression. See [deno#9294](https://github.com/denoland/deno/issues/9294) for | ||
more details. | ||
|
||
**File system API** | ||
|
||
- `Deno.File` | ||
|
||
`Deno.File` was deprecated in favor of `Deno.FsFile`. Replace the usages with | ||
new class name. | ||
|
||
### Invalid: | ||
|
||
```typescript | ||
// buffer | ||
const a = new Deno.Buffer(); | ||
|
||
// read all | ||
const b = await Deno.readAll(reader); | ||
const c = Deno.readAllSync(reader); | ||
|
||
// write all | ||
await Deno.writeAll(writer, data); | ||
Deno.writeAllSync(writer, data); | ||
|
||
// iter | ||
for await (const x of Deno.iter(xs)) {} | ||
for (const y of Deno.iterSync(ys)) {} | ||
|
||
// copy | ||
await Deno.copy(reader, writer); | ||
|
||
// custom inspector | ||
class A { | ||
[Deno.customInspect]() { | ||
return "This is A"; | ||
} | ||
} | ||
|
||
// file | ||
function foo(file: Deno.File) { | ||
// ... | ||
} | ||
``` | ||
|
||
### Valid: | ||
|
||
```typescript | ||
// buffer | ||
import { Buffer } from "https://deno.land/std/io/buffer.ts"; | ||
const a = new Buffer(); | ||
|
||
// read all | ||
import { readAll, readAllSync } from "https://deno.land/std/io/read_all.ts"; | ||
const b = await readAll(reader); | ||
const c = readAllSync(reader); | ||
|
||
// write all | ||
import { writeAll, writeAllSync } from "https://deno.land/std/io/write_all.ts"; | ||
await writeAll(writer, data); | ||
writeAllSync(writer, data); | ||
|
||
// iter | ||
// reader is `ReadableStream` | ||
for await (const chunk of reader) { | ||
// do something | ||
} | ||
|
||
// copy | ||
// reader is `ReadableStream` and writer is `WritableStream` | ||
await reader.pipeTo(writer); | ||
|
||
// custom inspector | ||
class A { | ||
[Symbol.for("Deno.customInspect")]() { | ||
return "This is A"; | ||
} | ||
} | ||
|
||
// file | ||
function foo(file: Deno.FsFile) { | ||
// ... | ||
} | ||
``` | ||
|
||
- `Deno.isatty` | ||
|
||
`Deno.isatty` was deprecated in favor of `Deno.stdin.isTerminal()`, | ||
`Deno.stdout.isTerminal()` and `Deno.stderr.isTerminal()`. | ||
|
||
### Invalid: | ||
|
||
```typescript | ||
Deno.isatty(Deno.stdin.rid); | ||
Deno.isatty(Deno.stdout.rid); | ||
Deno.isatty(Deno.stderr.rid); | ||
``` | ||
|
||
### Valid: | ||
|
||
```typescript | ||
Deno.stdin.isTerminal(); | ||
Deno.stdout.isTerminal(); | ||
Deno.stderr.isTerminal(); | ||
``` | ||
|
||
- `Deno.close` | ||
|
||
`Deno.close` was deprecated in favor of `.close()` method available on relevant | ||
objects. | ||
|
||
### Invalid: | ||
|
||
```typescript | ||
const file = await Deno.open("foo.txt"); | ||
Deno.close(file.rid); | ||
``` | ||
|
||
### Valid: | ||
|
||
```typescript | ||
const file = await Deno.open("foo.txt"); | ||
file.close(); | ||
``` | ||
- `Deno.fstatSync()` | ||
- `Deno.fstat()` | ||
- `Deno.FsWatcher.rid` | ||
- `Deno.ftruncateSync()` | ||
- `Deno.ftruncate()` | ||
- `Deno.futimeSync()` | ||
- `Deno.futime()` | ||
- `Deno.isatty()` | ||
- `Deno.Listener.rid` | ||
- `Deno.ListenTlsOptions.certFile` | ||
- `Deno.ListenTlsOptions.keyFile` | ||
- `Deno.readAllSync()` | ||
- `Deno.readAll()` | ||
- `Deno.Reader` | ||
- `Deno.ReaderSync` | ||
- `Deno.readSync()` | ||
- `Deno.read()` | ||
- `Deno.run()` | ||
- `Deno.seekSync()` | ||
- `Deno.seek()` | ||
- `Deno.serveHttp()` | ||
- `Deno.Server` | ||
- `Deno.shutdown` | ||
- `Deno.stderr.rid` | ||
- `Deno.stdin.rid` | ||
- `Deno.stdout.rid` | ||
- `Deno.TlsConn.rid` | ||
- `Deno.UnixConn.rid` | ||
- `Deno.writeAllSync()` | ||
- `Deno.writeAll()` | ||
- `Deno.Writer` | ||
- `Deno.WriterSync` | ||
- `Deno.writeSync()` | ||
- `Deno.write()` | ||
- `new Deno.FsFile()` | ||
|
||
The following APIs will be removed from the `Deno.*` namespace without | ||
replacement. | ||
|
||
- `Deno.resources()` | ||
|
||
Deno.resources() was deprecated. There are no replacements for this API. | ||
|
||
- `Deno.metrics()` | ||
|
||
Deno.metrics() was deprecated. There are no replacements for this API. | ||
|
||
**HTTP server API** | ||
|
||
- `Deno.serveHttp` | ||
|
||
`Deno.serveHttp` was deprecated in favor of `Deno.serve`. |
This file contains 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