forked from jashkenas/coffeescript
-
-
Notifications
You must be signed in to change notification settings - Fork 1
CoffeeScript To TypeScript Features
Erik Demaine edited this page Jan 23, 2022
·
32 revisions
This is a running list of supported and not-yet-supported features on my typescript branch. See this wiki page for another list of TypeScript features.
- Primitive types given by any identifier:
any,unknown,object,void,never,number,string,boolean,bigint,symbol,Function - Literal types: numbers, strings, booleans, and within
typeof,Infinity,NaN -
null,undefined, andvoidtypes - Function types:
(arg1 ~ ArgType, arg2 ~ ArgType) -> returnType(or ditto with=>)- Optional parameters:
(arg? ~ ArgType) ~ ReturnType -> ...
- Optional parameters:
- Constructor type:
new ... - Array types:
baseType[] - Tuple types:
[name ~ string, age ~ number] - Object types, including optional properties:
{key: string, value?: number}or omitting braces as usual in CoffeeScript:key: string value?: number
-
[keyExpr]: value
-
- Union types:
type1 | type2 - Intersection types:
type1 & type2 -
keyof,unique,readonlyoperators - Type indexing:
T["key"] - Namespace dereferencing:
space.T - Mapped types:
{[Key in keyof Type]: ...} -
typeofoperator - Template types, e.g.
ReturnType<T>,Partial<T>,Required<T>,Readonly<T>,Record<K,T>,Pick<T,K>,Omit<T,K>,Iterable<T>, ... - Conditional types:
if { legs: 4 } then Animal else never - Template string types:
"index.#{"en" | "fr"}.html" -
extendsassertion:T extends S - TypeScript passthrough:
`passthrough code`
-
~or:=assigning type to a variable:variable ~ Type - Assigning to variable as it's typed:
variable ~ Type = value- After-indented-type next-line assignment:
variable ~ key: string value?: number = key: 'hello' value: 7
- After-indented-type next-line assignment:
- Function typing
(arg1 ~ ArgType, arg2 ~ ArgType) ~ ReturnType -> ...- Optional parameters:
(arg? ~ ArgType) ~ ReturnType -> ...
- Optional parameters:
- Generic functions:
f = <T>(a ~ T[]) ~ T -> a[0] - Function overloads?
- Class attributes via
x ~ T - Generic classes:
class Box<T> -
class ... implements ... - Type guards:
(obj) ~ obj is Response ->(conflict with CoffeeScriptis?) - Type assertions:
(obj) ~ asserts obj is Response
-
type- Leading
|in multiline unions - Template types:
type Foo<T> -
extends
- Leading
-
interface- Template interfaces:
interface Foo<T> -
extends
- Template interfaces:
-
import type -
declare -
module -
namespace
- Nonnull assertion:
! -
as -
as const
-
private,protected,public,readonlyvariable modifiers -
enum -
#@tsc-ignore -
#/ <directive />