diff --git a/notNeededPackages.json b/notNeededPackages.json
index e0e880c3e6..e1a2f2e6cd 100644
--- a/notNeededPackages.json
+++ b/notNeededPackages.json
@@ -1278,6 +1278,12 @@
"sourceRepoURL": "https://github.com/zalmoxisus/redux-devtools-extension",
"asOfVersion": "2.13.2"
},
+ {
+ "libraryName": "redux-little-router",
+ "typingsPackageName": "redux-little-router",
+ "sourceRepoURL": "https://github.com/FormidableLabs/redux-little-router",
+ "asOfVersion": "15.1.0"
+ },
{
"libraryName": "redux-persist",
"typingsPackageName": "redux-persist",
diff --git a/react-table-filter/index.d.ts b/react-table-filter/index.d.ts
deleted file mode 100644
index 8f9c50a26f..0000000000
--- a/react-table-filter/index.d.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-// Type definitions for react-table-filter 1.0.0
-// Project: https://github.com/cheekujha/react-table-filter
-// Definitions by: Gnanavel N
-// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
-// TypeScript Version: 2.8
-
-import * as React from 'react';
-
-export interface TabfilterProps {
- rows: string | Array | { [name: string]: boolean; };
- onFilterUpdate: (filteredArray: Array, currentFilters: any[]) => any[] | void;
- rowClass?: string;
- initialFilters?: string | Array | { [name: string]: boolean; };
-}
-
-export declare class TableFilter extends React.Component {}
\ No newline at end of file
diff --git a/types/abstract-leveldown/abstract-leveldown-tests.ts b/types/abstract-leveldown/abstract-leveldown-tests.ts
index c5edadf069..070065f425 100644
--- a/types/abstract-leveldown/abstract-leveldown-tests.ts
+++ b/types/abstract-leveldown/abstract-leveldown-tests.ts
@@ -11,3 +11,7 @@ const test = (levelDown: AbstractLevelDOWN) => {
test(new AbstractLevelDOWN('here'));
// $ExpectType void
test(AbstractLevelDOWN('there'));
+// $ExpectType void
+test(new AbstractLevelDOWN('here'));
+// $ExpectType void
+test(AbstractLevelDOWN('there'));
diff --git a/types/abstract-leveldown/index.d.ts b/types/abstract-leveldown/index.d.ts
index 2caf073432..ad8fab5d74 100644
--- a/types/abstract-leveldown/index.d.ts
+++ b/types/abstract-leveldown/index.d.ts
@@ -3,6 +3,7 @@
// Definitions by: Meirion Hughes
// Daniel Byrne
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+// TypeScript Version: 2.3
export interface AbstractOptions {
readonly [k: string]: any;
@@ -21,7 +22,7 @@ export interface AbstractGetOptions extends AbstractOptions {
asBuffer?: boolean;
}
-export interface AbstractLevelDOWN extends AbstractOptions {
+export interface AbstractLevelDOWN extends AbstractOptions {
open(cb: ErrorCallback): void;
open(options: AbstractOpenOptions, cb: ErrorCallback): void;
@@ -38,17 +39,23 @@ export interface AbstractLevelDOWN extends AbstractOptions {
batch(): AbstractChainedBatch;
batch(array: ReadonlyArray>, cb: ErrorCallback): AbstractChainedBatch;
- batch(array: ReadonlyArray>, options: AbstractOptions, cb: ErrorCallback): AbstractChainedBatch;
+ batch(
+ array: ReadonlyArray>,
+ options: AbstractOptions,
+ cb: ErrorCallback,
+ ): AbstractChainedBatch;
iterator(options?: AbstractIteratorOptions): AbstractIterator;
}
export interface AbstractLevelDOWNConstructor {
- new (location: string): AbstractLevelDOWN;
- (location: string): AbstractLevelDOWN;
+ // tslint:disable-next-line no-unnecessary-generics
+ new (location: string): AbstractLevelDOWN;
+ // tslint:disable-next-line no-unnecessary-generics
+ (location: string): AbstractLevelDOWN;
}
-export interface AbstractIteratorOptions extends AbstractOptions {
+export interface AbstractIteratorOptions extends AbstractOptions {
gt?: K;
gte?: K;
lt?: K;
@@ -61,20 +68,20 @@ export interface AbstractIteratorOptions extends AbstractOptions {
valueAsBuffer?: boolean;
}
-export type AbstractBatch = PutBatch | DelBatch;
+export type AbstractBatch = PutBatch | DelBatch;
-export interface PutBatch {
+export interface PutBatch {
readonly type: 'put';
readonly key: K;
readonly value: V;
}
-export interface DelBatch {
+export interface DelBatch {
readonly type: 'del';
readonly key: K;
}
-export interface AbstractChainedBatch extends AbstractChainedBatchConstructor, AbstractOptions {
+export interface AbstractChainedBatch extends AbstractOptions {
put: (key: K, value: V) => this;
del: (key: K) => this;
clear: () => this;
@@ -83,19 +90,23 @@ export interface AbstractChainedBatch extends AbstractChainedBatchConstruc
}
export interface AbstractChainedBatchConstructor {
- new(db: any): AbstractChainedBatch;
- (db: any): AbstractChainedBatch;
+ // tslint:disable-next-line no-unnecessary-generics
+ new (db: any): AbstractChainedBatch;
+ // tslint:disable-next-line no-unnecessary-generics
+ (db: any): AbstractChainedBatch;
}
-export interface AbstractIterator extends AbstractChainedBatchConstructor {
+export interface AbstractIterator extends AbstractOptions {
db: AbstractLevelDOWN;
next(cb: ErrorKeyValueCallback): this;
end(cb: ErrorCallback): void;
}
export interface AbstractIteratorConstructor {
- new(db: any): AbstractIterator;
- (db: any): AbstractIterator;
+ // tslint:disable-next-line no-unnecessary-generics
+ new (db: any): AbstractIterator;
+ // tslint:disable-next-line no-unnecessary-generics
+ (db: any): AbstractIterator;
}
export const AbstractLevelDOWN: AbstractLevelDOWNConstructor;
diff --git a/types/aws-lambda/aws-lambda-tests.ts b/types/aws-lambda/aws-lambda-tests.ts
index 94575006ab..5fa225eafd 100644
--- a/types/aws-lambda/aws-lambda-tests.ts
+++ b/types/aws-lambda/aws-lambda-tests.ts
@@ -400,10 +400,10 @@ cognitoUserPoolEvent.request.session![0].challengeName === "DEVICE_SRP_AUTH";
cognitoUserPoolEvent.request.session![0].challengeName === "DEVICE_PASSWORD_VERIFIER";
cognitoUserPoolEvent.request.session![0].challengeName === "ADMIN_NO_SRP_AUTH";
bool = cognitoUserPoolEvent.request.session![0].challengeResult;
-strOrUndefined = cognitoUserPoolEvent.request.session![0].challengeMetaData;
+strOrUndefined = cognitoUserPoolEvent.request.session![0].challengeMetadata;
strOrUndefined = cognitoUserPoolEvent.request.challengeName;
str = cognitoUserPoolEvent.request.privateChallengeParameters!["answer"];
-str = cognitoUserPoolEvent.request.challengeAnswer!["answer"];
+str = cognitoUserPoolEvent.request.challengeAnswer!;
boolOrUndefined = cognitoUserPoolEvent.response.answerCorrect;
strOrUndefined = cognitoUserPoolEvent.response.smsMessage;
strOrUndefined = cognitoUserPoolEvent.response.emailMessage;
@@ -413,7 +413,7 @@ boolOrUndefined = cognitoUserPoolEvent.response.issueTokens;
boolOrUndefined = cognitoUserPoolEvent.response.failAuthentication;
str = cognitoUserPoolEvent.response.publicChallengeParameters!["captchaUrl"];
str = cognitoUserPoolEvent.response.privateChallengeParameters!["answer"];
-strOrUndefined = cognitoUserPoolEvent.response.challengeMetaData;
+strOrUndefined = cognitoUserPoolEvent.response.challengeMetadata;
boolOrUndefined = cognitoUserPoolEvent.response.answerCorrect;
// CloudFormation Custom Resource
@@ -581,7 +581,7 @@ const CodePipelineEvent: AWSLambda.CodePipelineEvent = {
CodePipelineEvent["CodePipeline.job"].data.encryptionKey = { type: 'KMS', id: 'key' };
/* CloudFront events, see http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html */
-const CloudFrontRequestEvent: AWSLambda.CloudFrontRequestEvent = {
+const CloudFrontRequestWithCustomOriginEvent: AWSLambda.CloudFrontRequestEvent = {
Records: [
{
cf: {
@@ -630,7 +630,44 @@ const CloudFrontRequestEvent: AWSLambda.CloudFrontRequestEvent = {
"TLSv1",
"TLSv1.1"
]
- },
+ }
+ }
+ }
+ }
+ }
+ ]
+};
+
+const CloudFrontRequestWithS3OriginEvent: AWSLambda.CloudFrontRequestEvent = {
+ Records: [
+ {
+ cf: {
+ config: {
+ distributionDomainName: "d123.cloudfront.net",
+ distributionId: "EDFDVBD6EXAMPLE",
+ eventType: "viewer-request",
+ requestId: "MRVMF7KydIvxMWfJIglgwHQwZsbG2IhRJ07sn9AkKUFSHS9EXAMPLE=="
+ },
+ request: {
+ clientIp: "2001:0db8:85a3:0:0:8a2e:0370:7334",
+ method: "GET",
+ uri: "/picture.jpg",
+ querystring: "size=large",
+ headers: {
+ host: [
+ {
+ key: "Host",
+ value: "d111111abcdef8.cloudfront.net"
+ }
+ ],
+ "user-agent": [
+ {
+ key: "User-Agent",
+ value: "curl/7.51.0"
+ }
+ ]
+ },
+ origin: {
s3: {
authMethod: "origin-access-identity",
customHeaders: {
@@ -812,6 +849,56 @@ apiGtwProxyHandler = proxyHandler;
const codePipelineHandler: AWSLambda.CodePipelineHandler = (event: AWSLambda.CodePipelineEvent, context: AWSLambda.Context, cb: AWSLambda.Callback) => {};
const cloudFrontRequestHandler: AWSLambda.CloudFrontRequestHandler = (event: AWSLambda.CloudFrontRequestEvent, context: AWSLambda.Context, cb: AWSLambda.CloudFrontRequestCallback) => {
+ event = CloudFrontRequestWithCustomOriginEvent;
+ // $ExpectType CloudFrontRequestEvent
+ event;
+ let request = event.Records[0].cf.request;
+
+ let s3Origin: AWSLambda.CloudFrontS3Origin = {
+ authMethod: 'none',
+ customHeaders: {},
+ domainName: 'example.com',
+ path: '/',
+ region: 'us-east-1'
+ };
+
+ if (request.origin && request.origin.custom) {
+ request.origin.custom.domainName;
+ request.origin.custom.domainName = "example2.com";
+
+ // $ExpectError
+ s3Origin = request.origin.s3;
+
+ // $ExpectError
+ request.origin.s3.path = '/';
+ }
+
+ let customOrigin: AWSLambda.CloudFrontCustomOrigin = {
+ customHeaders: {},
+ domainName: 'example.com',
+ keepaliveTimeout: 60,
+ path: '/',
+ port: 80,
+ protocol: 'http',
+ readTimeout: 30,
+ sslProtocols: []
+ };
+
+ event = CloudFrontRequestWithS3OriginEvent;
+ // $ExpectType CloudFrontRequestEvent
+ event;
+ request = event.Records[0].cf.request;
+ if (request.origin && request.origin.s3) {
+ request.origin.s3.path;
+ request.origin.s3.path = "/new_path";
+
+ // $ExpectError
+ customOrigin = request.origin.custom;
+
+ // $ExpectError
+ request.origin.custom.path = '/';
+ }
+
cb();
cb(null);
cb(new Error(''));
diff --git a/types/aws-lambda/index.d.ts b/types/aws-lambda/index.d.ts
index 35d0b1d7a6..cce721e68c 100644
--- a/types/aws-lambda/index.d.ts
+++ b/types/aws-lambda/index.d.ts
@@ -21,6 +21,7 @@
// Jeremy Nagel
// Louis Larry
// Daniel Papukchiev
+// Oliver Hookins
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -250,11 +251,11 @@ export interface CognitoUserPoolTriggerEvent {
session?: Array<{
challengeName: "CUSTOM_CHALLENGE" | "PASSWORD_VERIFIER" | "SMS_MFA" | "DEVICE_SRP_AUTH" | "DEVICE_PASSWORD_VERIFIER" | "ADMIN_NO_SRP_AUTH";
challengeResult: boolean;
- challengeMetaData?: string;
+ challengeMetadata?: string;
}>;
challengeName?: string;
privateChallengeParameters?: { [key: string]: string };
- challengeAnswer?: { [key: string]: string };
+ challengeAnswer?: string;
};
response: {
autoConfirmUser?: boolean;
@@ -266,7 +267,7 @@ export interface CognitoUserPoolTriggerEvent {
failAuthentication?: boolean;
publicChallengeParameters?: { [key: string]: string };
privateChallengeParameters?: { [key: string]: string };
- challengeMetaData?: string;
+ challengeMetadata?: string;
answerCorrect?: boolean;
};
}
@@ -561,6 +562,9 @@ export interface CodePipelineEvent {
/**
* CloudFront events
* http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-event-structure.html
+ * Bear in mind that the "example" event structure in the page above includes
+ * both an S3 and a Custom origin, which is not strictly allowed. Only one
+ * of these per event may be present.
*/
export interface CloudFrontHeaders {
[name: string]: Array<{
@@ -569,6 +573,29 @@ export interface CloudFrontHeaders {
}>;
}
+export type CloudFrontOrigin =
+ | { s3: CloudFrontS3Origin, custom?: never }
+ | { custom: CloudFrontCustomOrigin, s3?: never };
+
+export interface CloudFrontCustomOrigin {
+ customHeaders: CloudFrontHeaders;
+ domainName: string;
+ keepaliveTimeout: number;
+ path: string;
+ port: number;
+ protocol: 'http' | 'https';
+ readTimeout: number;
+ sslProtocols: string[];
+}
+
+export interface CloudFrontS3Origin {
+ authMethod: 'origin-access-identity' | 'none';
+ customHeaders: CloudFrontHeaders;
+ domainName: string;
+ path: string;
+ region: string;
+}
+
export interface CloudFrontResponse {
status: string;
statusDescription: string;
@@ -581,6 +608,7 @@ export interface CloudFrontRequest {
uri: string;
querystring: string;
headers: CloudFrontHeaders;
+ origin?: CloudFrontOrigin;
}
export interface CloudFrontEvent {
diff --git a/types/bitcoinjs-lib/bitcoinjs-lib-tests.ts b/types/bitcoinjs-lib/bitcoinjs-lib-tests.ts
index 9576ba7289..cc24c6573b 100644
--- a/types/bitcoinjs-lib/bitcoinjs-lib-tests.ts
+++ b/types/bitcoinjs-lib/bitcoinjs-lib-tests.ts
@@ -1,4 +1,3 @@
-import bigi = require('bigi');
import bitcoin = require('bitcoinjs-lib');
// For testing only
@@ -8,19 +7,18 @@ function rng() {
// Generate a random bitcoin address
const keyPair1 = bitcoin.ECPair.makeRandom({rng});
-const address = keyPair1.getAddress();
+const { address } = bitcoin.payments.p2pkh({ pubkey: keyPair1.publicKey });
keyPair1.toWIF();
// Generate an address from a SHA256 hash
const hash = bitcoin.crypto.sha256(Buffer.from('correct horse battery staple', 'utf8'));
-const d = bigi.fromBuffer(hash);
-const keyPair2 = new bitcoin.ECPair(d);
+const keyPair2 = bitcoin.ECPair.fromPrivateKey(hash);
// Generate a random keypair for alternative networks
-const keyPair3 = bitcoin.ECPair.makeRandom({network: bitcoin.networks.litecoin, rng});
+const keyPair3 = bitcoin.ECPair.makeRandom({network: bitcoin.networks.testnet, rng});
keyPair3.toWIF();
-keyPair3.getAddress();
-const network = keyPair3.getNetwork();
+bitcoin.payments.p2pkh({ pubkey: keyPair3.publicKey });
+const network = keyPair3.network;
// Test TransactionBuilder and Transaction
const txb = new bitcoin.TransactionBuilder();
@@ -41,22 +39,3 @@ bitcoin.address.toBase58Check(rsBase58Check.hash, rsBase58Check.version);
bitcoin.address.toBech32(rsBech32.data, rsBech32.version, rsBech32.prefix);
bitcoin.address.toOutputScript(address);
bitcoin.address.toOutputScript(address, network);
-
-const redeemScript = bitcoin.script.multisig.output.encode(
- 2,
- [
- new Buffer('12345678901234567890123456789012'),
- new Buffer('12345678901234567890123456789012'),
- new Buffer('12345678901234567890123456789012'),
- ]
-);
-bitcoin.script.scriptHash.input.encode(
- bitcoin.script.multisig.input.encodeStack(
- [
- new Buffer('12345678901234567890123456789012'),
- new Buffer('12345678901234567890123456789012'),
- ],
- redeemScript,
- ),
- redeemScript,
-);
diff --git a/types/bitcoinjs-lib/index.d.ts b/types/bitcoinjs-lib/index.d.ts
index 2d0603b87c..4fb1bb16a7 100644
--- a/types/bitcoinjs-lib/index.d.ts
+++ b/types/bitcoinjs-lib/index.d.ts
@@ -1,4 +1,4 @@
-// Type definitions for bitcoinjs-lib 3.4
+// Type definitions for bitcoinjs-lib 4.0
// Project: https://github.com/bitcoinjs/bitcoinjs-lib
// Definitions by: Mohamed Hegazy
// Daniel
@@ -12,8 +12,6 @@
///
-import BigInteger = require('bigi');
-
export interface Out {
script: Buffer;
value: number;
@@ -68,29 +66,23 @@ export class Block {
}
export class ECPair {
- constructor(d: BigInteger, Q?: null, options?: { compressed?: boolean, network?: Network });
-
- constructor(d: null | undefined, Q: any, options?: { compressed?: boolean, network?: Network }); // Q should be ECPoint, but not sure how to define such type
-
- d: BigInteger;
-
readonly compressed: boolean;
+ readonly privateKey: Buffer;
+
+ readonly publicKey: Buffer;
+
readonly network: Network;
- getAddress(): string;
-
- getNetwork(): Network;
-
- getPublicKeyBuffer(): Buffer;
-
- sign(hash: Buffer): ECSignature;
+ sign(hash: Buffer): Buffer;
toWIF(): string;
- verify(hash: Buffer, signature: ECSignature): boolean;
+ verify(hash: Buffer, signature: Buffer): boolean;
- static fromPublicKeyBuffer(buffer: Buffer, network: Network): ECPair;
+ static fromPrivateKey(buffer: Buffer, options?: { compressed?: boolean, network?: Network }): ECPair;
+
+ static fromPublicKey(buffer: Buffer, options?: { compressed?: boolean, network?: Network }): ECPair;
static fromWIF(string: string, network?: Network): ECPair;
@@ -99,66 +91,6 @@ export class ECPair {
export type Rng = (size: number) => Buffer;
-export class ECSignature {
- constructor(r: BigInteger, s: BigInteger);
-
- toCompact(i: number, compressed: boolean): Buffer;
-
- toDER(): Buffer;
-
- toScriptSignature(hashType: number): Buffer;
-
- static fromDER(buffer: Buffer): ECSignature;
-
- static parseCompact(buffer: Buffer): { compressed: boolean, i: number, signature: ECSignature };
-
- static parseScriptSignature(buffer: Buffer): { signature: ECSignature, hashType: number };
-}
-
-export class HDNode {
- constructor(keyPair: ECPair, chainCode: Buffer);
-
- keyPair: ECPair;
-
- derive(index: number): HDNode;
-
- deriveHardened(index: number): HDNode;
-
- derivePath(path: string): HDNode;
-
- getAddress(): string;
-
- getFingerprint(): Buffer;
-
- getIdentifier(): Buffer;
-
- getNetwork(): Network;
-
- getPublicKeyBuffer(): Buffer;
-
- isNeutered(): boolean;
-
- neutered(): HDNode;
-
- sign(hash: Buffer): ECSignature;
-
- toBase58(): string;
-
- verify(hash: Buffer, signature: ECSignature): boolean;
-
- static HIGHEST_BIT: number;
-
- static LENGTH: number;
-
- static fromBase58(string: string, networks?: Network[] | Network): HDNode;
-
- static fromSeedBuffer(seed: Buffer, network?: Network): HDNode;
-
- static fromSeedHex(hex: string, network?: Network): HDNode;
-
- static MASTER_SECRET: Buffer;
-}
-
export class Transaction {
version: number;
locktime: number;
@@ -236,9 +168,6 @@ export interface Input {
}
export class TransactionBuilder {
- tx: Transaction;
- inputs: Input[];
-
constructor(network?: Network, maximumFeeRate?: number);
addInput(txhash: Buffer | string | Transaction, vout: number, sequence?: number, prevOutScript?: Buffer): number;
@@ -261,7 +190,6 @@ export class TransactionBuilder {
export const networks: {
bitcoin: Network;
- litecoin: Network;
testnet: Network;
};
@@ -391,7 +319,7 @@ export namespace address {
/** @since 3.2.0 */
function fromBech32(address: string): { data: Buffer, prefix: string, version: number };
- function fromOutputScript(outputScript: Buffer, network?: Network): string;
+ function fromOutputScript(output: Buffer, network?: Network): string;
function toBase58Check(hash: Buffer, version: number): string;
@@ -401,26 +329,6 @@ export namespace address {
function toOutputScript(address: string, network?: Network): Buffer;
}
-export namespace bufferutils {
- function pushDataSize(i: number): number;
-
- function readPushDataInt(buffer: Buffer, offset: number): { opcode: number, number: number, size: number };
-
- function readUInt64LE(buffer: Buffer, offset: number): number;
-
- function readVarInt(buffer: Buffer, offset: number): { number: number, size: number };
-
- function varIntBuffer(number: number, buffer: Buffer, offset: number): Buffer;
-
- function varIntSize(number: number): number;
-
- function writePushDataInt(buffer: Buffer, number: number, offset: number): number;
-
- function writeUInt64LE(buffer: Buffer, value: number, offset: number): number;
-
- function writeVarInt(buffer: Buffer, number: number, offset: number): number;
-}
-
export namespace crypto {
function hash160(buffer: Buffer): Buffer;
@@ -449,7 +357,7 @@ export namespace script {
function isCanonicalPubKey(buffer: Buffer): boolean;
- function isCanonicalSignature(buffer: Buffer): boolean;
+ function isCanonicalScriptSignature(buffer: Buffer): boolean;
function isDefinedHashType(hashType: any): boolean;
@@ -465,66 +373,48 @@ export namespace script {
function encode(number: number): Buffer;
}
+ namespace signature {
+ function decode(buffer: Buffer): { signature: Buffer, hashType: number };
+
+ function encode(signature: Buffer, hashType: number): Buffer;
+ }
+
const multisig: {
input: {
check(script: Buffer, allowIncomplete: boolean): boolean;
- decode(buffer: Buffer): Array;
- decodeStack(stack: Buffer[], allowIncomplete: boolean): Array;
- encode(signatures: Buffer[], scriptPubKey: Buffer): Buffer;
- encodeStack(signatures: Buffer[], scriptPubKey: Buffer): Buffer[];
};
output: {
check(script: Buffer, allowIncomplete: boolean): boolean;
- decode(buffer: Buffer, allowIncomplete: boolean): { m: number; pubKeys: Array };
- encode(m: number, pubKeys: Array): Buffer;
};
};
const pubKey: {
input: {
check(script: Buffer): boolean;
- decode(buffer: Buffer): Array;
- decodeStack(stack: Buffer[]): Array;
- encode(signature: Buffer): Buffer;
- encodeStack(signature: Buffer): Buffer[];
};
output: {
check(script: Buffer): boolean;
- decode(buffer: Buffer): Buffer | number;
- encode(pubKey: Buffer): Buffer;
};
};
const pubKeyHash: {
input: {
check(script: Buffer): boolean;
- decode(buffer: Buffer): { signature: Buffer; pubKey: Buffer };
- decodeStack(stack: Buffer[]): { signature: Buffer; pubKey: Buffer };
- encode(signature: Buffer, pubKey: Buffer): Buffer;
- encodeStack(signature: Buffer, pubKey: Buffer): [Buffer, Buffer];
};
output: {
check(script: Buffer): boolean;
- decode(buffer: Buffer): Buffer;
- encode(pubKeyHash: Buffer): Buffer;
};
};
const scriptHash: {
input: {
check(script: Buffer, allowIncomplete: boolean): boolean;
- decode(buffer: Buffer): { redeemScriptStack: Buffer[]; redeemScript: Buffer };
- decodeStack(stack: Buffer[]): { redeemScriptStack: Buffer[]; redeemScript: Buffer };
- encode(redeemScriptSig: Array, redeemScript: Buffer): Buffer;
- encodeStack(redeemScriptStack: Buffer[], redeemScript: Buffer): Buffer[];
};
output: {
check(script: Buffer): boolean;
- decode(buffer: Buffer): Buffer;
- encode(scriptHash: Buffer): Buffer;
};
};
@@ -539,36 +429,56 @@ export namespace script {
const witnessPubKeyHash: {
input: {
check(script: Buffer): boolean;
- decodeStack(stack: Buffer[]): { signature: Buffer; pubKey: Buffer };
- encodeStack(signature: Buffer, pubKey: Buffer): [Buffer, Buffer];
};
output: {
check(script: Buffer): boolean;
- decode(buffer: Buffer): Buffer;
- encode(pubKeyHash: Buffer): Buffer;
};
};
const witnessScriptHash: {
input: {
check(script: Buffer, allowIncomplete: boolean): boolean;
- decodeStack(stack: Buffer[]): { redeemScriptStack: Buffer[]; redeemScript: Buffer };
- encodeStack(redeemScriptStack: Buffer[], redeemScript: Buffer): Buffer[];
};
output: {
check(script: Buffer): boolean;
- decode(buffer: Buffer): Buffer;
- encode(scriptHash: Buffer): Buffer;
};
};
const nullData: {
output: {
check(script: Buffer): boolean;
- decode(buffer: Buffer): Buffer;
- encode(data: Buffer): Buffer;
};
};
}
+
+export namespace payments {
+ function p2data(a: { network?: Network, output?: Buffer, data?: Buffer[] }, opts?: { validate?: boolean }):
+ { output: Buffer, data: Buffer[] };
+
+ function p2ms(a: { network?: Network, m?: number, n?: number, output?: Buffer, pubkeys?: Buffer[], signatures?: Buffer[], input?: Buffer }, opts?: { validate?: boolean }):
+ { output: Buffer, m: number, n: number, pubkeys: Buffer[], signatures: Buffer[], input: Buffer, witness: Buffer[] };
+
+ function p2pk(a: { input?: Buffer, network?: Network, output?: Buffer, pubkey?: Buffer, signature?: Buffer }, opts?: { validate?: boolean }):
+ { output: Buffer, pubkey: Buffer, signature: Buffer, input: Buffer, witness: Buffer[] };
+
+ function p2pkh(a: { address?: string, hash?: Buffer, input?: Buffer, network?: Network, output?: Buffer, pubkey?: Buffer, signature?: Buffer }, opts?: { validate?: boolean }):
+ { address: string, hash: Buffer, output: Buffer, pubkey: Buffer, signature: Buffer, input: Buffer, witness: Buffer[] };
+
+ function p2sh(a: { address?: string, hash?: Buffer, input?: Buffer, network?: Network, output?: Buffer, witness?: Buffer[], redeem?: Redeem }, opts?: { validate?: boolean }):
+ { address: string, hash: Buffer, output: Buffer, redeem: Redeem, input: Buffer, witness: Buffer[] };
+
+ function p2wpkh(a: { address?: string, hash?: Buffer, input?: Buffer, network?: Network, output?: Buffer, pubkey?: Buffer, signature?: Buffer, witness?: Buffer[] },
+ opts?: { validate?: boolean }): { address: string, hash: Buffer, output: Buffer, pubkey: Buffer, signature: Buffer, input: Buffer, witness: Buffer[] };
+
+ function p2wsh(a: { address?: string, hash?: Buffer, input?: Buffer, network?: Network, output?: Buffer, witness?: Buffer[], redeem?: Redeem }, opts?: { validate?: boolean }):
+ { address: string, hash: Buffer, output: Buffer, redeem: Redeem, input: Buffer, witness: Buffer[] };
+
+ class Redeem {
+ input?: Buffer;
+ network?: Network;
+ output?: Buffer;
+ witness?: Buffer[];
+ }
+}
diff --git a/types/bloom-filter/bloom-filter-tests.ts b/types/bloom-filter/bloom-filter-tests.ts
new file mode 100644
index 0000000000..0b836a0f84
--- /dev/null
+++ b/types/bloom-filter/bloom-filter-tests.ts
@@ -0,0 +1,28 @@
+import BloomFilter = require('bloom-filter');
+
+const numElements = 3;
+const falsePositiveRate = 0.01;
+const filter = BloomFilter.create(numElements, falsePositiveRate);
+
+// elements
+const a = Buffer.from('99108ad8ed9bb6274d3980bab5a85c048f0950c8', 'hex');
+const c = Buffer.from('b5a2c786d9ef4658287ced5914b37a1b4aa32eee', 'hex');
+
+// insert elements
+// $ExpectType void
+filter.insert(a);
+
+// $ExpectType boolean
+!filter.contains(c);
+
+// reinstantiate from an object
+const serialized = filter.toObject();
+const woahFilter = new BloomFilter(serialized);
+
+// initialize directly
+const newFilter = new BloomFilter({
+ vData: Buffer.from('123', 'hex'), // the data of the filter
+ nHashFuncs: 3, // the number of hash functions to use
+ nTweak: 2147483649, // the seed used for the hash fuctions
+ nFlags: 0 // flags used to update the filter when matched
+});
diff --git a/types/bloom-filter/index.d.ts b/types/bloom-filter/index.d.ts
new file mode 100644
index 0000000000..22841f066b
--- /dev/null
+++ b/types/bloom-filter/index.d.ts
@@ -0,0 +1,38 @@
+// Type definitions for bloom-filter 0.2
+// Project: https://github.com/bitpay/bloom-filter
+// Definitions by: Daniel Byrne
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+///
+
+declare class Filter {
+ constructor(options: Filter.FilterOptions);
+ static create(elements: number, falsePositiveRate: number, nTweak?: number, nFlags?: number): Filter;
+ toObject(): Filter.FilterOptions;
+ hash(nHashNum: number, vDataToHash: Buffer): number;
+ insert(data: Buffer): void;
+ contains(data: Buffer): boolean;
+ clear(): void;
+ inspect(): string;
+ BLOOM_UPDATE_NONE: number;
+ BLOOM_UPDATE_ALL: number;
+ BLOOM_UPDATE_P2PUBKEY_ONLY: number;
+ MAX_BLOOM_FILTER_SIZE: number;
+ MAX_HASH_FUNCS: number;
+ MIN_HASH_FUNCS: number;
+ LN2SQUARED: number;
+ LN2: number;
+}
+
+declare namespace Filter {
+ interface FilterOptions {
+ vData: Buffer;
+ nHashFuncs: number;
+ nTweak?: number;
+ nFlags?: number;
+ }
+
+ function MurmurHash3(seed: number, data: Buffer): number;
+}
+
+export = Filter;
diff --git a/types/bloom-filter/tsconfig.json b/types/bloom-filter/tsconfig.json
new file mode 100644
index 0000000000..788542822b
--- /dev/null
+++ b/types/bloom-filter/tsconfig.json
@@ -0,0 +1,19 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "lib": ["es6"],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": true,
+ "strictFunctionTypes": true,
+ "baseUrl": "../",
+ "typeRoots": ["../"],
+ "types": [],
+ "noEmit": true,
+ "forceConsistentCasingInFileNames": true
+ },
+ "files": [
+ "index.d.ts",
+ "bloom-filter-tests.ts"
+ ]
+}
diff --git a/react-table-filter/tslint.json b/types/bloom-filter/tslint.json
similarity index 100%
rename from react-table-filter/tslint.json
rename to types/bloom-filter/tslint.json
diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts
index aa6cd54eb7..49027a2bea 100644
--- a/types/chart.js/index.d.ts
+++ b/types/chart.js/index.d.ts
@@ -391,6 +391,8 @@ declare namespace Chart {
easing?: string;
onProgress?(chart: any): void;
onComplete?(chart: any): void;
+ animateRotate?: boolean;
+ animateScale?: boolean;
}
interface ChartElementsOptions {
diff --git a/types/create-subscription/create-subscription-tests.tsx b/types/create-subscription/create-subscription-tests.tsx
index 891adc5ede..d1b3d3bda0 100644
--- a/types/create-subscription/create-subscription-tests.tsx
+++ b/types/create-subscription/create-subscription-tests.tsx
@@ -105,15 +105,7 @@ declare const wrongPromise: Promise;
;
// $ExpectError
-const MismatchSubscription = createSubscription({
- getCurrentValue: (a: number) => null,
- subscribe: (a: string, callback) => (() => undefined)
-});
+const MismatchSubscription = createSubscription({ getCurrentValue: (a: number) => null, subscribe: (a: string, callback) => (() => undefined) });
// $ExpectError
-const NoUnsubscribe = createSubscription({
- getCurrentValue: (a: number) => a,
- subscribe: (a: number, callback) => {
- // oops, should've returned a callback here
- }
-});
+const NoUnsubscribe = createSubscription({ getCurrentValue: (a: number) => a, subscribe: (a: number, callback) => { /* oops, should've returned a callback here */ }});
diff --git a/types/elliptic/elliptic-tests.ts b/types/elliptic/elliptic-tests.ts
new file mode 100644
index 0000000000..d587be5e8d
--- /dev/null
+++ b/types/elliptic/elliptic-tests.ts
@@ -0,0 +1,47 @@
+import elliptic = require('elliptic');
+
+const ec = new elliptic.ec('secp256k1');
+
+// Generate keys
+const key = ec.genKeyPair();
+
+// Sign the message's hash (input must be an array, or a hex-string)
+const msgHash = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+const signature = key.sign(msgHash);
+
+// Export DER encoded signature in Array
+const derSign = signature.toDER();
+
+// Verify signature
+console.log(key.verify(msgHash, derSign));
+
+// CHECK WITH NO PRIVATE KEY
+
+const pubPoint = key.getPublic();
+const x = pubPoint.getX();
+const y = pubPoint.getY();
+
+// Public Key MUST be either:
+// 1) '04' + hex string of x + hex string of y; or
+// 2) object with two hex string properties (x and y); or
+// 3) object with two buffer properties (x and y)
+const pub = pubPoint.encode('hex'); // case 1
+const aPub = { x: x.toString('hex'), y: y.toString('hex') }; // case 2
+const bPub = { x: x.toBuffer(), y: y.toBuffer() }; // case 3
+const cPub = { x: x.toArrayLike(Buffer), y: y.toArrayLike(Buffer) }; // case 3
+
+// Import public key
+const newKey = ec.keyFromPublic(pub, 'hex');
+
+// Signature MUST be either:
+// 1) DER-encoded signature as hex-string; or
+// 2) DER-encoded signature as buffer; or
+// 3) object with two hex-string properties (r and s); or
+// 4) object with two buffer properties (r and s)
+
+// const signature = '3046022100...'; // case 1
+// const signature = new Buffer('...'); // case 2
+// const signature = { r: 'b1fc...', s: '9c42...' }; // case 3
+
+// Verify signature
+console.log(key.verify(msgHash, signature));
diff --git a/types/elliptic/index.d.ts b/types/elliptic/index.d.ts
new file mode 100644
index 0000000000..f819d17497
--- /dev/null
+++ b/types/elliptic/index.d.ts
@@ -0,0 +1,158 @@
+// Type definitions for elliptic 6.4
+// Project: https://github.com/indutny/elliptic
+// Definitions by: Daniel Byrne
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+
+import BN = require('bn.js');
+
+// incomplete typings
+export const utils: any;
+export const rand: any;
+export const eddsa: any;
+
+export type BNInput = string | BN | number | Buffer | number[];
+
+export const version: number;
+
+export namespace curve {
+ class BaseCurve {
+ constructor(type: string, conf: BaseCurve.BaseCurveOptions)
+ p: BN;
+ type: string;
+ red: any; // ?
+ zero: any; // ?
+ one: any; // ?
+ two: any; // ?
+ n: BN | undefined | null;
+ g: any; // ?
+ redN: any; // ?
+ decodePoint(bytes: any, enc: string): any; // ?
+ }
+
+ namespace BaseCurve {
+ class BasePoint {
+ constructor(curve: any, type: string);
+ curve: any;
+ type: string;
+ precomputed: PrecomputedValues | null;
+ encode(enc: string, compact: boolean): BN;
+ encodeCompressed(enc: string): BN;
+ validate(): boolean;
+ precompute(power: number): BasePoint;
+ dblp(k: any): any; // ?
+ }
+
+ interface BaseCurveOptions {
+ p: number | string | number[] | Buffer | BN;
+ prime?: BN | string;
+ n?: number | BN | Buffer;
+ g?: any; // ?
+ gRed?: any; // ?
+ }
+
+ interface PrecomputedValues {
+ doubles: any; // ?
+ naf: any; // ?
+ beta: any; // ?
+ }
+ }
+}
+
+export namespace curves {
+ class PresetCurve {
+ constructor(options: PresetCurve.Options)
+ type: string;
+ g: any; // ?
+ n: BN | undefined | null;
+ hash: any; // ?
+ }
+
+ namespace PresetCurve {
+ interface Options {
+ type: string;
+ prime: string | null;
+ p: string;
+ a: string;
+ b: string;
+ n: string;
+ hash: any;
+ gRed: boolean;
+ g: any; // ?
+ beta?: string;
+ lambda?: string;
+ basis?: any; // ?
+ }
+ }
+}
+
+export class ec {
+ constructor(options: string | curves.PresetCurve)
+ curve: any;
+ n: BN | undefined | null;
+ nh: any;
+ g: any;
+ hash: any;
+
+ keyPair(options: ec.KeyPairOptions): ec.KeyPair;
+ keyFromPrivate(priv: Buffer | ec.KeyPair, enc?: string): ec.KeyPair;
+ keyFromPublic(pub: Buffer | ec.KeyPair, enc?: string): ec.KeyPair;
+ genKeyPair(options?: ec.GenKeyPairOptions): ec.KeyPair;
+ sign(msg: BNInput, key: Buffer | ec.KeyPair, enc: string, options?: ec.SignOptions): ec.Signature;
+ sign(msg: BNInput, key: Buffer | ec.KeyPair, options?: ec.SignOptions): ec.Signature;
+ verify(msg: BNInput, signature: ec.Signature | ec.SignatureOptions, key: Buffer | ec.KeyPair, enc?: string): boolean;
+ recoverPubKey(msg: BNInput, signature: ec.Signature | ec.SignatureOptions, j: number, enc?: string): any;
+ getKeyRecoveryParam(e: Error | undefined, signature: ec.Signature | ec.SignatureOptions, Q: BN, enc?: string): number;
+}
+
+export namespace ec {
+ interface GenKeyPairOptions {
+ pers: any;
+ entropy: any;
+ persEnc?: string;
+ entropyEnc?: string;
+ }
+
+ interface SignOptions {
+ pers: any;
+ persEnc?: string;
+ canonical?: boolean;
+ k?: BN;
+ }
+
+ class KeyPair {
+ static fromPublic(ec: ec, pub: Buffer | KeyPair, enc?: string): KeyPair;
+ static fromPrivate(ec: ec, priv: Buffer | KeyPair, enc?: string): KeyPair;
+ constructor(ec: ec, options: KeyPairOptions)
+ ec: ec;
+ validate(): { readonly result: boolean, readonly reason: string };
+ getPublic(compact: boolean, enc?: string): any; // ?
+ getPublic(enc?: string): any; // ?
+ getPrivate(enc?: 'hex'): Buffer | BN | string;
+ derive(pub: any): any; // ?
+ sign(msg: BNInput, enc: string, options?: SignOptions): Signature;
+ sign(msg: BNInput, options?: SignOptions): Signature;
+ verify(msg: BNInput, signature: Signature | SignatureOptions): boolean;
+ inspect(): string;
+ }
+
+ class Signature {
+ constructor(options: SignatureOptions | Signature, enc?: string)
+ r: BN;
+ s: BN;
+ recoveryParam: number | null;
+ toDER(enc?: string | null): any; // ?
+ }
+
+ interface SignatureOptions {
+ r: number;
+ s: number;
+ recoveryParam?: number;
+ }
+
+ interface KeyPairOptions {
+ priv?: Buffer;
+ privEnc?: string;
+ pub?: Buffer;
+ pubEnc?: string;
+ }
+}
diff --git a/types/elliptic/tsconfig.json b/types/elliptic/tsconfig.json
new file mode 100644
index 0000000000..505cd03374
--- /dev/null
+++ b/types/elliptic/tsconfig.json
@@ -0,0 +1,23 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "lib": [
+ "es6"
+ ],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": true,
+ "strictFunctionTypes": true,
+ "baseUrl": "../",
+ "typeRoots": [
+ "../"
+ ],
+ "types": [],
+ "noEmit": true,
+ "forceConsistentCasingInFileNames": true
+ },
+ "files": [
+ "index.d.ts",
+ "elliptic-tests.ts"
+ ]
+}
diff --git a/types/elliptic/tslint.json b/types/elliptic/tslint.json
new file mode 100644
index 0000000000..d88586e5bd
--- /dev/null
+++ b/types/elliptic/tslint.json
@@ -0,0 +1,3 @@
+{
+ "extends": "dtslint/dt.json"
+}
diff --git a/types/ember-resolver/ember-resolver-tests.ts b/types/ember-resolver/ember-resolver-tests.ts
index d22a0d31be..6973daeda0 100644
--- a/types/ember-resolver/ember-resolver-tests.ts
+++ b/types/ember-resolver/ember-resolver-tests.ts
@@ -1,5 +1,5 @@
-import Application from '@ember/application';
import EmberResolver from 'ember-resolver';
+import { Ember } from 'ember';
const MyResolver = EmberResolver.extend({
pluralizedTypes: {
@@ -7,6 +7,6 @@ const MyResolver = EmberResolver.extend({
}
});
-const App = Application.extend({
+const App = Ember.Application.extend({
Resolver: MyResolver
});
diff --git a/types/ember-resolver/index.d.ts b/types/ember-resolver/index.d.ts
index 4fe466ae13..f2ede7fe32 100644
--- a/types/ember-resolver/index.d.ts
+++ b/types/ember-resolver/index.d.ts
@@ -5,11 +5,9 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
-///
-
-import Resolver from '@ember/application/resolver';
+import Ember from 'ember';
/**
* An Ember `Resolver` implementation used by ember-cli.
*/
-export default class EmberResolver extends Resolver {}
+export default class EmberResolver extends Ember.Resolver {}
diff --git a/types/ember-resolver/v4/ember-resolver-tests.ts b/types/ember-resolver/v4/ember-resolver-tests.ts
index d22a0d31be..db834b1985 100644
--- a/types/ember-resolver/v4/ember-resolver-tests.ts
+++ b/types/ember-resolver/v4/ember-resolver-tests.ts
@@ -1,4 +1,4 @@
-import Application from '@ember/application';
+import Ember from 'ember';
import EmberResolver from 'ember-resolver';
const MyResolver = EmberResolver.extend({
@@ -7,6 +7,6 @@ const MyResolver = EmberResolver.extend({
}
});
-const App = Application.extend({
+const App = Ember.Application.extend({
Resolver: MyResolver
});
diff --git a/types/ember-resolver/v4/index.d.ts b/types/ember-resolver/v4/index.d.ts
index 8047dc1bc2..fd5359cff4 100644
--- a/types/ember-resolver/v4/index.d.ts
+++ b/types/ember-resolver/v4/index.d.ts
@@ -5,11 +5,9 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
-///
-
-import Resolver from '@ember/application/resolver';
+import Ember from 'ember';
/**
* An Ember `Resolver` implementation used by ember-cli.
*/
-export default class EmberResolver extends Resolver {}
+export default class EmberResolver extends Ember.Resolver {}
diff --git a/types/ember/-private-types/mixin.d.ts b/types/ember/-private-types/mixin.d.ts
new file mode 100644
index 0000000000..30e81493ca
--- /dev/null
+++ b/types/ember/-private-types/mixin.d.ts
@@ -0,0 +1,5 @@
+import Ember from 'ember';
+/**
+ * Ember.Object.extend(...) accepts any number of mixins or literals.
+ */
+declare type MixinOrLiteral = Ember.Mixin | T;
diff --git a/types/ember/-private-types/object.d.ts b/types/ember/-private-types/object.d.ts
new file mode 100644
index 0000000000..be7be68dee
--- /dev/null
+++ b/types/ember/-private-types/object.d.ts
@@ -0,0 +1,28 @@
+/**
+ * Used to infer the type of ember classes of type `T`.
+ *
+ * Generally you would use `EmberClass.create()` instead of `new EmberClass()`.
+ *
+ * The single-arg constructor is required by the typescript compiler.
+ * The multi-arg constructor is included for better ergonomics.
+ *
+ * Implementation is carefully chosen for the reasons described in
+ * https://github.com/typed-ember/ember-typings/pull/29
+ */
+export type EmberClassConstructor = (new (properties?: object) => T) & (new (...args: any[]) => T);
+
+/**
+ * Check that any arguments to `create()` match the type's properties.
+ *
+ * Accept any additional properties and add merge them into the instance.
+ */
+export type EmberInstanceArguments = Partial & {
+ [key: string]: any;
+};
+
+/**
+ * Accept any additional properties and add merge them into the prototype.
+ */
+export interface EmberClassArguments {
+ [key: string]: any;
+}
diff --git a/types/ember/-private-types/object/computed.d.ts b/types/ember/-private-types/object/computed.d.ts
new file mode 100644
index 0000000000..2c540db04b
--- /dev/null
+++ b/types/ember/-private-types/object/computed.d.ts
@@ -0,0 +1,34 @@
+import ComputedProperty from '@ember/object/computed';
+/**
+ * Deconstructs computed properties into the types which would be returned by `.get()`.
+ */
+export type UnwrapComputedPropertyGetter =
+ T extends ComputedProperty ? U :
+ T;
+export type UnwrapComputedPropertyGetters = {
+ [P in keyof T]: UnwrapComputedPropertyGetter;
+};
+
+export type UnwrapComputedPropertySetter =
+ T extends ComputedProperty ? V :
+ T;
+export type UnwrapComputedPropertySetters = {
+ [P in keyof T]: UnwrapComputedPropertySetter;
+};
+
+export type ComputedPropertyGetterFunction = (this: any, key: string) => T;
+export type ComputedPropertySetterFunction = (this: any, key: string, newVal: T, oldVal: T) => T;
+
+export interface ComputedPropertyGetterObj {
+ get(this: any, key: string): T;
+}
+
+export interface ComputedPropertySetterObj {
+ set(this: any, key: string, value: T): T;
+}
+export type ComputedPropertyObj = ComputedPropertyGetterObj | ComputedPropertySetterObj | (ComputedPropertyGetterObj & ComputedPropertySetterObj);
+
+export type ComputedPropertyGetter = ComputedPropertyGetterFunction | ComputedPropertyGetterObj;
+export type ComputedPropertySetter = ComputedPropertySetterFunction | ComputedPropertySetterObj;
+
+export type ComputedPropertyCallback = ComputedPropertyGetterFunction | ComputedPropertyObj;
diff --git a/types/ember/-private-types/utils.d.ts b/types/ember/-private-types/utils.d.ts
new file mode 100644
index 0000000000..a9902c7a1d
--- /dev/null
+++ b/types/ember/-private-types/utils.d.ts
@@ -0,0 +1,36 @@
+import { Ember } from "ember";
+
+/**
+ * Map type `T` to a plain object hash with the identity mapping.
+ *
+ * Discards any additional object identity like the ability to `new()` up the class.
+ * The `new()` capability is added back later by merging `EmberClassConstructor`
+ *
+ * Implementation is carefully chosen for the reasons described in
+ * https://github.com/typed-ember/ember-typings/pull/29
+ */
+export type Objectify = Readonly;
+export type ExtractPropertyNamesOfType = {
+ [K in keyof T]: T[K] extends S ? K : never
+}[keyof T];
+export type Fix = { [K in keyof T]: T[K] };
+
+export type KeysOfType = keyof Pick;
+
+export interface TypeLookup {
+ string: string;
+ number: number;
+ boolean: boolean;
+ regexp: RegExp;
+ function: (...args: any[]) => any;
+ array: any[];
+ error: Error;
+ filelist: FileList;
+ class: typeof Ember.Object;
+ instance: Ember.Object;
+ date: Date;
+ null: null;
+ undefined: undefined;
+}
diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts
index cee4ebc780..5b059a0ee4 100755
--- a/types/ember/index.d.ts
+++ b/types/ember/index.d.ts
@@ -16,6 +16,16 @@
///
declare module 'ember' {
+ import {
+ UnwrapComputedPropertySetters,
+ UnwrapComputedPropertySetter,
+ UnwrapComputedPropertyGetters,
+ UnwrapComputedPropertyGetter,
+ ComputedPropertyCallback
+ } from 'ember/-private-types/object/computed';
+ import { Objectify, Fix, KeysOfType, TypeLookup } from 'ember/-private-types/utils';
+ import { EmberClassArguments, EmberClassConstructor, EmberInstanceArguments } from 'ember/-private-types/object';
+
// Capitalization is intentional: this makes it much easier to re-export RSVP on
// the Ember namespace.
import Rsvp from 'rsvp';
@@ -42,51 +52,11 @@ declare module 'ember' {
: F extends (a: infer A, b: infer B, c: infer C, d: infer D, e: infer E) => any
? [A, B, C, D, E]
: never;
- /**
- * Deconstructs computed properties into the types which would be returned by `.get()`.
- */
- type UnwrapComputedPropertyGetter =
- T extends Ember.ComputedProperty ? U :
- T;
- type UnwrapComputedPropertyGetters = {
- [P in keyof T]: UnwrapComputedPropertyGetter;
- };
- type UnwrapComputedPropertySetter =
- T extends Ember.ComputedProperty ? U :
- T;
- type UnwrapComputedPropertySetters = {
- [P in keyof T]: UnwrapComputedPropertySetter;
- };
-
- /**
- * Check that any arguments to `create()` match the type's properties.
- *
- * Accept any additional properties and add merge them into the instance.
- */
- type EmberInstanceArguments = Partial & {
- [key: string]: any;
- };
-
- /**
- * Accept any additional properties and add merge them into the prototype.
- */
- interface EmberClassArguments {
- [key: string]: any;
- }
-
- /**
- * Map type `T` to a plain object hash with the identity mapping.
- *
- * Discards any additional object identity like the ability to `new()` up the class.
- * The `new()` capability is added back later by merging `EmberClassConstructor`
- *
- * Implementation is carefully chosen for the reasons described in
- * https://github.com/typed-ember/ember-typings/pull/29
- */
- type Objectify = Readonly;
-
- type Fix = { [K in keyof T]: T[K] };
+ type Mix = B & Pick>;
+ type Mix3 = Mix, C>;
+ type Mix4 = Mix3, C, D>;
+ type Mix5 = Mix4, C, D, E>;
/**
* Ember.Object.extend(...) accepts any number of mixins or literals.
@@ -104,23 +74,6 @@ declare module 'ember' {
* Implementation is carefully chosen for the reasons described in
* https://github.com/typed-ember/ember-typings/pull/29
*/
- type EmberClassConstructor = (new (properties?: object) => T) & (new (...args: any[]) => T);
-
- type ComputedPropertyGetterFunction = (this: any, key: string) => T;
-
- interface ComputedPropertyGet {
- get(this: any, key: string): T;
- }
-
- interface ComputedPropertySet {
- set(this: any, key: string, value: T): T;
- }
-
- type ComputedPropertyCallback =
- | ComputedPropertyGetterFunction
- | ComputedPropertyGet
- | ComputedPropertySet
- | (ComputedPropertyGet & ComputedPropertySet);
interface ActionsHash {
[index: string]: (...params: any[]) => any;
@@ -143,7 +96,7 @@ declare module 'ember' {
type ObserverMethod =
| (keyof Target)
- | ((this: Target, sender: Sender, key: keyof Sender, value: any, rev: number) => void);
+ | ((this: Target, sender: Sender, key: string, value: any, rev: number) => void);
interface RenderOptions {
into?: string;
@@ -786,7 +739,7 @@ declare module 'ember' {
class ContainerDebugAdapter extends Object {
resolver: Resolver;
canCatalogEntriesByType(type: string): boolean;
- catalogEntriesByType(type: string): any[];
+ catalogEntriesByType(type: string): string[];
}
/**
* Additional methods for the Controller.
@@ -1051,32 +1004,54 @@ declare module 'ember' {
* The container-debug-adapter which is used
* to list all models.
*/
- containerDebugAdapter: any;
+ containerDebugAdapter: ContainerDebugAdapter;
/**
* Ember Data > v1.0.0-beta.18
* requires string model names to be passed
* around instead of the actual factories.
*/
- acceptsModelName: any;
+ acceptsModelName: boolean;
/**
* Specifies how records can be filtered.
* Records returned will need to have a `filterValues`
* property with a key for every name in the returned array.
*/
- getFilters(): any[];
+ getFilters(): DataAdapter.Column[];
/**
* Fetch the model types and observe them for changes.
*/
- watchModelTypes(typesAdded: Function, typesUpdated: Function): Function;
+ watchModelTypes(
+ typesAdded: (types: DataAdapter.WrappedType[]) => void,
+ typesUpdated: (types: DataAdapter.WrappedType[]) => void
+ ): () => void;
/**
* Fetch the records of a given type and observe them for changes.
*/
watchRecords(
modelName: string,
- recordsAdded: Function,
- recordsUpdated: Function,
- recordsRemoved: Function
- ): Function;
+ recordsAdded: (records: DataAdapter.WrappedRecord[]) => void,
+ recordsUpdated: (records: DataAdapter.WrappedRecord[]) => void,
+ recordsRemoved: (idx: number, count: number) => void
+ ): () => void;
+ }
+ namespace DataAdapter {
+ interface Column {
+ name: string;
+ desc: string;
+ }
+ interface WrappedRecord {
+ columnValues: object;
+ object: object;
+ }
+ interface WrappedType {
+ type: {
+ name: string;
+ count: number;
+ columns: Column[];
+ object: typeof Object;
+ };
+ release: () => void;
+ }
}
const Debug: {
/**
@@ -1085,14 +1060,14 @@ declare module 'ember' {
* The following example demonstrates its usage by registering a handler that throws an error if the
* message contains the word "should", otherwise defers to the default handler.
*/
- registerDeprecationHandler(handler: Function): any;
+ registerDeprecationHandler(handler: (message: string, options: { id: string, until: string }, next: () => void) => void): void;
/**
* Allows for runtime registration of handler functions that override the default warning behavior.
* Warnings are invoked by calls made to [Ember.warn](http://emberjs.com/api/classes/Ember.html#method_warn).
* The following example demonstrates its usage by registering a handler that does nothing overriding Ember's
* default warning behavior.
*/
- registerWarnHandler(handler: Function): any;
+ registerWarnHandler(handler: (message: string, options: { id: string }, next: () => void) => void): void;
};
/**
* The DefaultResolver defines the default lookup rules to resolve
@@ -3064,20 +3039,20 @@ declare module 'ember' {
/**
* Run a function meant for debugging.
*/
- function runInDebug(func: () => void): any;
+ function runInDebug(func: () => any): void;
/**
* Display a warning with the provided message.
*/
- function warn(message: string, test: boolean, options: { id: string }): any;
- function warn(message: string, options: { id: string }): any;
+ function warn(message: string, test: boolean, options: { id: string }): void;
+ function warn(message: string, options: { id: string }): void;
/**
* @deprecated Missing deprecation options: https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options
*/
- function warn(message: string, test: boolean, options?: { id?: string }): any;
+ function warn(message: string, test: boolean, options?: { id?: string }): void;
/**
* @deprecated Missing deprecation options: https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options
*/
- function warn(message: string, options?: { id?: string }): any;
+ function warn(message: string, options?: { id?: string }): void;
/**
* Global helper method to create a new binding. Just pass the root object
* along with a `to` and `from` path to create and connect the binding.
@@ -3167,7 +3142,7 @@ declare module 'ember' {
* Merge the contents of two objects together into the first object.
* @deprecated Use Object.assign
*/
- function merge(original: T, updates: U): T & U;
+ function merge(original: T, updates: U): Mix;
/**
* Makes a method available via an additional name.
*/
@@ -3311,14 +3286,17 @@ declare module 'ember' {
/**
* Returns a consistent type for the passed object.
*/
- function typeOf(item?: any): string;
+ function typeOf(value: T): KeysOfType;
+ function typeOf(): 'undefined';
+ function typeOf(item: any): string;
/**
* Copy properties from a source object to a target object.
* @deprecated Use Object.assign
*/
- function assign(target: T, source: U): T & U;
- function assign(target: T, source1: U, source2: V): T & U & V;
- function assign(target: T, source1: U, source2: V, source3: W): T & U & V & W;
+ function assign(target: T, source: U): Mix;
+ function assign(target: T, source1: U, source2: V): Mix3;
+ function assign(target: T, source1: U, source2: V, source3: W): Mix4;
+
/**
* Polyfill for Object.create
* @deprecated Use Object.create
diff --git a/types/ember/test/access-modifier.ts b/types/ember/test/access-modifier.ts
index 5e998f72d3..38f5bd4602 100644
--- a/types/ember/test/access-modifier.ts
+++ b/types/ember/test/access-modifier.ts
@@ -1,3 +1,7 @@
+/**
+ * Tests to ensure that access modifier keywords are appropriately
+ * respected and supported
+ */
import Ember from 'ember';
import { assertType } from './lib/assert';
@@ -8,13 +12,16 @@ class Foo extends Ember.Object {
}
const f = new Foo();
assertType(f.hello());
+// protected property should not be visible from outside of Foo
assertType(f.bar()); // $ExpectError
+// private property should not be visible from outside of Foo
assertType(f.baz()); // $ExpectError
class Foo2 extends Ember.Object.extend({
bar: ''
}) {
hello() { return 'world'; }
+ // Cannot override with a mis-matched property type
protected bar() { return 'bar'; } // $ExpectError
private baz() { return 'baz'; }
}
diff --git a/types/ember/test/component.ts b/types/ember/test/component.ts
index bcc314300d..13ab88cbbd 100755
--- a/types/ember/test/component.ts
+++ b/types/ember/test/component.ts
@@ -3,6 +3,9 @@ import Component from '@ember/component';
import Object, { computed } from '@ember/object';
import hbs from 'htmlbars-inline-precompile';
import { assertType } from "./lib/assert";
+import ComputedProperty from '@ember/object/computed';
+import { ExtractPropertyNamesOfType } from 'ember/-private-types/utils';
+import { UnwrapComputedPropertySetter } from 'ember/-private-types/object/computed';
Component.extend({
layout: hbs`
diff --git a/types/ember/test/core-object.ts b/types/ember/test/core-object.ts
new file mode 100644
index 0000000000..984f5eec12
--- /dev/null
+++ b/types/ember/test/core-object.ts
@@ -0,0 +1,198 @@
+import Ember from 'ember';
+import { assertType } from './lib/assert';
+
+/** Newable tests */
+const co1 = new Ember.CoreObject();
+
+// TODO: Enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
+// co1.concatenatedProperties; // $ExpectType string[]
+co1.isDestroyed; // $ExpectType boolean
+co1.isDestroying; // $ExpectType boolean
+co1.destroy(); // $ExpectType CoreObject
+co1.toString(); // $ExpectType string
+
+/** .create tests */
+const co2 = Ember.CoreObject.create();
+// TODO: Enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
+// co2.concatenatedProperties; // $ExpectType string[]
+co2.isDestroyed; // $ExpectType boolean
+co2.isDestroying; // $ExpectType boolean
+co2.destroy(); // $ExpectType CoreObject
+co2.toString(); // $ExpectType string
+
+/** .create tests w/ initial instance data passed in */
+const co3 = Ember.CoreObject.create({ foo: '123', bar: 456 });
+
+co3.foo; // $ExpectType string
+co3.bar; // $ExpectType number
+
+/** .extend with a zero-argument .create() */
+const co4 = Ember.CoreObject.extend({
+ foo: '123',
+ bar: 456,
+ baz(): [string, number] {
+ return [this.foo, this.bar];
+ }
+}).create();
+
+co4.foo; // $ExpectType string
+co4.bar; // $ExpectType number
+co4.baz; // $ExpectType () => [string, number]
+
+/** .extend with inconsistent arguments passed into .create() */
+const class05 = Ember.CoreObject.extend({
+ foo: '123' as (string | boolean),
+ bar: 456,
+ baz() {
+ return [this.foo, this.bar];
+ }
+});
+const c05 = class05.create({ foo: 99 }); // $ExpectError
+const c05b = class05.create({ foo: true });
+const c05c = class05.create({ foo: 'abc' });
+assertType(c05b.foo); // $ExpectError
+assertType(c05c.foo); // $ExpectError
+
+/** two .extend arguments with a zero-argument .create() */
+const co6 = Ember.CoreObject.extend({
+ foo: '123',
+ bar: 456,
+ baz() {
+ return [this.foo, this.bar];
+ },
+ func1() {
+ // this includes stuff from CoreObject
+ this.init; // $ExpectType () => void
+ // this includes stuff from this extend-arg
+ this.foo; // $ExpectType string
+ // this does not include stuff from later extend args
+ this.bee; // $ExpectError
+ }
+}, {
+ foo: 99,
+ bee: 'honey',
+ func2() {
+ // this includes stuff from CoreObject
+ this.init; // $ExpectType () => void
+ // this includes stuff from this extend-arg
+ // TODO: switch to "$ExpectType number" in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
+ this.foo; // $ExpectType string & number
+ // this includes stuff from earlier extend-args
+ this.bar; // $ExpectType number
+ }
+}).create();
+
+// TODO: enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
+// assertType(co6.foo); // $ExpectError
+assertType(co6.bar); // $ExpectType number
+assertType<() => Array>(co6.baz); // $ExpectType () => (string | number)[]
+
+/** three .extend arguments with a zero-argument .create() */
+const co7 = Ember.CoreObject.extend({
+ foo: '123',
+ bar: 456,
+ baz() {
+ return [this.foo, this.bar];
+ },
+ func1() {
+ // this includes stuff from CoreObject
+ this.init; // $ExpectType () => void
+ // this includes stuff from this extend-arg
+ this.foo; // $ExpectType string
+ // this does not include stuff from later extend args
+ this.bee; // $ExpectError
+ }
+}, {
+ foo: 99,
+ bee: 'honey',
+ func2() {
+ // this includes stuff from CoreObject
+ this.init; // $ExpectType () => void
+ // this includes stuff from this extend-arg
+ // TODO: switch to "$ExpectType number" in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
+ this.foo; // $ExpectType string & number
+ // this includes stuff from earlier extend-args
+ this.bar; // $ExpectType number
+ }
+}, {
+ foo: '99',
+ money: 'in the banana stand',
+ func3() {
+ // this includes stuff from CoreObject
+ this.init; // $ExpectType () => void
+ // this includes stuff from this extend-arg
+ this.money; // $ExpectType string
+ // this includes stuff from earlier extend-args
+ this.bee; // $ExpectType string
+ this.bar; // $ExpectType number
+ }
+}).create();
+// TODO: enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
+// assertType(co7.foo); // $ExpectError
+assertType(co7.bar); // $ExpectType number
+assertType(co7.money); // $ExpectType string
+assertType<() => Array>(co7.baz); // $ExpectType () => (string | number)[]
+
+/** four .extend arguments with a zero-argument .create() */
+const co8 = Ember.CoreObject.extend({
+ foo: '123',
+ bar: 456,
+ baz() {
+ return [this.foo, this.bar];
+ },
+ func1() {
+ // this includes stuff from CoreObject
+ this.init; // $ExpectType () => void
+ // this includes stuff from this extend-arg
+ this.foo; // $ExpectType string
+ // this does not include stuff from later extend args
+ this.bee; // $ExpectError
+ }
+}, {
+ foo: 99,
+ bee: 'honey',
+ func2() {
+ // this includes stuff from CoreObject
+ this.init; // $ExpectType () => void
+ // this includes stuff from this extend-arg
+ // TODO: switch to "$ExpectType number" in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
+ this.foo; // $ExpectType string & number
+ // this includes stuff from earlier extend-args
+ this.bar; // $ExpectType number
+ // this does not include stuff from later extend args
+ this.money; // $ExpectError
+ }
+}, {
+ foo: '99',
+ money: 'in the banana stand',
+ func3() {
+ // this includes stuff from CoreObject
+ this.init; // $ExpectType () => void
+ // this includes stuff from this extend-arg
+ this.money; // $ExpectType string
+ // this includes stuff from earlier extend-args
+ this.bee; // $ExpectType string
+ this.bar; // $ExpectType number
+ // this does not include stuff from later extend args
+ this.neighborhood; // $ExpectError
+ }
+}, {
+ foo: '99',
+ neighborhood: 'sudden valley',
+ func4() {
+ // this includes stuff from CoreObject
+ this.init; // $ExpectType () => void
+ // this includes stuff from this extend-arg
+ this.neighborhood; // $ExpectType string
+ // this includes stuff from earlier extend-args
+ this.bee; // $ExpectType string
+ this.bar; // $ExpectType number
+ this.money; // $ExpectType string
+ }
+}).create();
+
+// TODO: enable in TS 3.0 see: https://github.com/typed-ember/ember-cli-typescript/issues/291
+// assertType(co8.foo); // $ExpectError
+assertType(co8.bar); // $ExpectType number
+assertType(co8.money); // $ExpectType string
+assertType<() => Array>(co8.baz); // $ExpectType () => (string | number)[]
diff --git a/types/ember/test/data-adapter.ts b/types/ember/test/data-adapter.ts
new file mode 100644
index 0000000000..ea77b27e70
--- /dev/null
+++ b/types/ember/test/data-adapter.ts
@@ -0,0 +1,53 @@
+import Ember from 'ember';
+
+const da = Ember.DataAdapter.create();
+
+const filters = da.getFilters();
+filters.includes({ name: 'foo', desc: 'bar'}); // $ExpectType boolean
+filters.includes({}); // $ExpectError
+
+filters[0].name; // $ExpectType string
+filters[0].desc; // $ExpectType string
+
+da.watchModelTypes(// $ExpectType () => void
+ function added(wrappedTypes) {
+ wrappedTypes;
+ wrappedTypes[0].release; // $ExpectType () => void
+ wrappedTypes[0].type.columns[0].desc; // $ExpectType string
+ wrappedTypes[0].type.columns[0].name; // $ExpectType string
+ wrappedTypes[0].type.count; // $ExpectType number
+ wrappedTypes[0].type.name; // $ExpectType string
+ },
+ function updated(wrappedTypes) {
+ wrappedTypes;
+ wrappedTypes[0].release; // $ExpectType () => void
+ wrappedTypes[0].type.columns[0].desc; // $ExpectType string
+ wrappedTypes[0].type.columns[0].name; // $ExpectType string
+ wrappedTypes[0].type.count; // $ExpectType number
+ wrappedTypes[0].type.name; // $ExpectType string
+ }
+);
+da.watchModelTypes(() => void); // $ExpectError
+
+da.watchRecords('house', // $ExpectType () => void
+ function added(records) {
+ records[0].object; // $ExpectType object
+ records[0].columnValues; // $ExpectType object
+ },
+ function updated(records) {
+ records[0].object; // $ExpectType object
+ records[0].columnValues; // $ExpectType object
+ },
+ function removed(idx, count) {
+ idx; // $ExpectType number
+ count; // $ExpectType number
+ }
+);
+da.watchRecords(() => void); // $ExpectError
+
+da.acceptsModelName; // $ExpectType boolean
+da.containerDebugAdapter; // $ExpectType ContainerDebugAdapter
+
+const ca: Ember.ContainerDebugAdapter = da.containerDebugAdapter;
+ca.canCatalogEntriesByType('controller'); // $ExpectType boolean
+ca.catalogEntriesByType('controller'); // $ExpectType string[]
diff --git a/types/ember/test/debug.ts b/types/ember/test/debug.ts
new file mode 100644
index 0000000000..b3f4bb5f17
--- /dev/null
+++ b/types/ember/test/debug.ts
@@ -0,0 +1,53 @@
+import Ember from 'ember';
+
+const {
+ runInDebug,
+ warn,
+ debug,
+ assert,
+ Debug: { registerDeprecationHandler, registerWarnHandler }
+} = Ember;
+
+/**
+ * @ember/debug tests
+ */
+runInDebug(); // $ExpectError
+let x = runInDebug(() => console.log('Should not show up in prod')); // $ExpectType void
+
+// Log a warning if we have more than 3 tomsters
+const tomsterCount = 2;
+warn('Too many tomsters!'); // $ExpectType void
+warn('Too many tomsters!', tomsterCount <= 3); // $ExpectType void
+warn('Too many tomsters!', tomsterCount <= 3, { // $ExpectType void
+ id: 'ember-debug.too-many-tomsters'
+});
+
+debug(); // $ExpectError
+debug('Too many tomsters!'); // $ExpectType void
+debug('Too many tomsters!', 'foo'); // $ExpectError
+
+// Test for truthiness
+const str = 'hello';
+assert('Must pass a string', typeof str === 'string'); // $ExpectType void
+
+// Fail unconditionally
+assert('This code path should never be run'); // $ExpectType void
+
+// next is not called, so no warnings get the default behavior
+registerWarnHandler(); // $ExpectError
+registerWarnHandler(() => {}); // $ExpectType void
+registerWarnHandler((message, { id }, next) => { // $ExpectType void
+ message; // $ExpectType string
+ id; // $ExpectType string
+ next; // $ExpectType () => void
+});
+
+// next is not called, so no warnings get the default behavior
+registerDeprecationHandler(); // $ExpectError
+registerDeprecationHandler(() => {}); // $ExpectType void
+registerDeprecationHandler((message, { id, until }, next) => { // $ExpectType void
+ message; // $ExpectType string
+ id; // $ExpectType string
+ until; // $ExpectType string
+ next; // $ExpectType () => void
+});
diff --git a/types/ember/test/lib/assert.ts b/types/ember/test/lib/assert.ts
index d6748cd5bc..262d18bc2c 100755
--- a/types/ember/test/lib/assert.ts
+++ b/types/ember/test/lib/assert.ts
@@ -2,4 +2,4 @@
// Disable tslint here b/c the generic is used to let us do a type coercion and
// validate that coercion works for the type value "passed into" the function.
// tslint:disable-next-line:no-unnecessary-generics
-export declare function assertType(value: T): void;
+export declare function assertType(value: T): T;
diff --git a/types/ember/test/private/computed-tests.ts b/types/ember/test/private/computed-tests.ts
new file mode 100644
index 0000000000..a4c3e819f6
--- /dev/null
+++ b/types/ember/test/private/computed-tests.ts
@@ -0,0 +1,82 @@
+import { Ember } from "ember";
+import { computed } from "@ember/object";
+import { UnwrapComputedPropertySetters, UnwrapComputedPropertyGetters, UnwrapComputedPropertySetter, UnwrapComputedPropertyGetter } from "ember/-private-types/object/computed";
+import ComputedProperty from "@ember/object/computed";
+import { assertType } from "../lib/assert";
+
+class Example1 extends Ember.Object.extend({
+ firstName: '',
+ lastName: '',
+ allNames: computed('fullName', function() {
+ return [this.fullName];
+ }),
+ fullName: computed('firstName', 'lastName', function() {
+ return `${this.firstName} ${this.lastName}`;
+ })
+}) {
+ allNames!: ComputedProperty;
+ fullName!: ComputedProperty;
+}
+
+let unwrappedGetters1: UnwrapComputedPropertyGetters = {} as any;
+unwrappedGetters1.firstName; // $ExpectType string
+unwrappedGetters1.lastName; // $ExpectType string
+unwrappedGetters1.fullName; // $ExpectType string
+unwrappedGetters1.allNames; // $ExpectType string[]
+
+let unwrappedSetters1: UnwrapComputedPropertySetters = {} as any;
+unwrappedSetters1.firstName; // $ExpectType string
+unwrappedSetters1.lastName; // $ExpectType string
+unwrappedSetters1.fullName; // $ExpectType string
+unwrappedSetters1.allNames; // $ExpectType string[]
+
+class Example2 extends Ember.Object.extend({
+ allNames: computed('fullName', function() {
+ return [this.fullName + ''];
+ }) ,
+ fullName: computed('firstName', 'lastName', function() {
+ return `${this.firstName} ${this.lastName}`;
+ })
+}) {
+ firstName = '';
+ lastName = '';
+ foo() {
+ this.fullName; // $ExpectType ComputedProperty
+ this.allNames; // $ExpectType ComputedProperty
+ this.firstName; // $ExpectType string
+ this.lastName; // $ExpectType string
+
+ this.get('fullName').split(','); // $ExpectType string[]
+ this.get('allNames')[0]; // $ExpectType string
+ this.get('firstName').split(','); // $ExpectType string[]
+ this.get('lastName').split(','); // $ExpectType string[]
+ }
+}
+let ex2 = new Example2();
+
+let unwrappedGetters2: UnwrapComputedPropertyGetters = (ex2 as any) as UnwrapComputedPropertyGetters;
+assertType(unwrappedGetters2.firstName); // $ExpectType string
+assertType(unwrappedGetters2.lastName); // $ExpectType string
+assertType(unwrappedGetters2.fullName); // $ExpectType string
+assertType(unwrappedGetters2.allNames); // $ExpectType string[]
+
+let unwrappedSetters2: UnwrapComputedPropertySetters = null as any;
+assertType(unwrappedSetters2.firstName); // $ExpectType string
+assertType(unwrappedSetters2.lastName); // $ExpectType string
+assertType(unwrappedSetters2.fullName); // $ExpectType string
+assertType(unwrappedSetters2.allNames); // $ExpectType string[]
+
+ex2.fullName; // $ExpectType ComputedProperty
+ex2.allNames; // $ExpectType ComputedProperty
+ex2.firstName; // $ExpectType string
+
+type UnwStringSet = UnwrapComputedPropertySetter; // $ExpectType string
+type UnwStringGet = UnwrapComputedPropertyGetter; // $ExpectType string
+type UnwCpStringSet1 = UnwrapComputedPropertySetter>; // $ExpectType string
+type UnwCpStringGet1 = UnwrapComputedPropertyGetter>; // $ExpectType string
+type UnwCpStringSet2 = UnwrapComputedPropertySetter>; // $ExpectType string
+type UnwCpStringGet2 = UnwrapComputedPropertyGetter>; // $ExpectType string
+type UnwCpStringSet3 = UnwrapComputedPropertySetter>; // $ExpectType string
+type UnwCpStringGet3 = UnwrapComputedPropertyGetter>; // $ExpectType number
+type UnwCpStringSet4 = UnwrapComputedPropertySetter>; // $ExpectType number
+type UnwCpStringGet4 = UnwrapComputedPropertyGetter>; // $ExpectType string
diff --git a/types/ember/test/private/observable-tests.ts b/types/ember/test/private/observable-tests.ts
new file mode 100644
index 0000000000..be3d4bd69f
--- /dev/null
+++ b/types/ember/test/private/observable-tests.ts
@@ -0,0 +1,175 @@
+import Observable from "@ember/object/observable";
+import { UnwrapComputedPropertyGetter, UnwrapComputedPropertyGetters, UnwrapComputedPropertySetters, UnwrapComputedPropertySetter } from "ember/-private-types/object/computed";
+// tslint-disable-next-line
+import { assertType } from "../lib/assert";
+import { Ember } from "ember";
+import { ExtractPropertyNamesOfType } from "ember/-private-types/utils";
+
+class OtherThing {
+ observerOfDemo(target: DemoObservable, key: 'foo') {}
+}
+
+class DemoObservable implements Observable {
+ foo: string;
+ isFoo = true;
+ bar: [boolean, boolean];
+ baz?: number;
+ constructor() {
+ this.foo = 'hello';
+ this.bar = [false, true];
+ this.baz = 9;
+ this.addObserver('foo', this, 'fooDidChange');
+ this.addObserver('foo', this, 'fooDidChangeProtected'); // $ExpectError
+ this.addObserver('foo', this, this.fooDidChange);
+ this.addObserver('foo', this, this.fooDidChangeProtected);
+ const ot = new OtherThing();
+ this.addObserver('foo', ot, ot.observerOfDemo);
+ Ember.addObserver(this, 'foo', this, 'fooDidChange');
+ Ember.addObserver(this, 'foo', this, 'fooDidChangeProtected'); // $ExpectError
+ Ember.addObserver(this, 'foo', this, this.fooDidChange);
+ Ember.addObserver(this, 'foo', this, this.fooDidChangeProtected);
+ this.removeObserver('foo', this, 'fooDidChange');
+ this.removeObserver('foo', this, 'fooDidChangeProtected'); // $ExpectError
+ this.removeObserver('foo', this, this.fooDidChange);
+ this.removeObserver('foo', this, this.fooDidChangeProtected);
+ Ember.removeObserver(this, 'foo', this, 'fooDidChange');
+ Ember.removeObserver(this, 'foo', this, 'fooDidChangeProtected'); // $ExpectError
+ Ember.removeObserver(this, 'foo', this, this.fooDidChange);
+ const lambda = () => {
+ this.fooDidChange(this, 'foo');
+ };
+ this.addObserver('foo', lambda);
+ this.addObserver('foo', (sender, key, value, rev) => {
+ assertType(sender);
+ assertType<'foo'>(key);
+ assertType(value);
+ assertType(rev);
+ });
+ this.removeObserver('foo', lambda);
+ Ember.addObserver(this, 'foo', lambda);
+ Ember.removeObserver(this, 'foo', lambda);
+ }
+
+ fooDidChange(obj: this, propName: 'foo') {}
+ protected fooDidChangeProtected(obj: this, propName: 'foo') {}
+ get(key: K): UnwrapComputedPropertyGetter {
+ throw new Error("Method not implemented.");
+ }
+ getProperties(list: K[]): Pick, K>;
+ getProperties(...list: K[]): Pick, K>;
+ getProperties(...rest: any[]): any {
+ throw new Error("Method not implemented.");
+ }
+ set(key: K, value: this[K]): this[K] {
+ throw new Error("Method not implemented.");
+ }
+ setProperties(hash: Pick): Pick< UnwrapComputedPropertySetters, K> {
+ throw new Error("Method not implemented.");
+ }
+ notifyPropertyChange(keyName: string): this {
+ throw new Error("Method not implemented.");
+ }
+ addObserver(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: string, value: any, rev: number) => void)): void;
+ addObserver(key: K, method: keyof this | ((this: this, sender: this, key: K, value: this[K], rev: number) => void)): void;
+ addObserver(key: any, target: any, method?: any) {
+ throw new Error("Method not implemented.");
+ }
+ removeObserver(key: keyof this, target: Target, method: keyof Target | ((this: Target, sender: this, key: string, value: any, rev: number) => void)): void;
+ removeObserver(key: keyof this, method: keyof this | ((this: this, sender: this, key: string, value: any, rev: number) => void)): void;
+ removeObserver(key: any, target: any, method?: any): void {
+ throw new Error("Method not implemented.");
+ }
+ getWithDefault(key: K, defaultValue: UnwrapComputedPropertyGetter): UnwrapComputedPropertyGetter {
+ throw new Error("Method not implemented.");
+ }
+ incrementProperty(keyName: ExtractPropertyNamesOfType, increment?: number): number {
+ throw new Error("Method not implemented.");
+ }
+ decrementProperty(keyName: ExtractPropertyNamesOfType, decrement?: number): number {
+ throw new Error("Method not implemented.");
+ }
+ toggleProperty(keyName: ExtractPropertyNamesOfType): boolean {
+ throw new Error("Method not implemented.");
+ }
+ cacheFor(key: K): UnwrapComputedPropertyGetter | undefined {
+ throw new Error("Method not implemented.");
+ }
+}
+const o = new DemoObservable();
+
+/**
+ * get
+ */
+assertType(o.get('foo')); // $ExpectType string
+assertType<[boolean, boolean]>(o.get('bar')); // $ExpectType [boolean, boolean]
+assertType(o.get('baz')); // $ExpectType number | undefined
+
+/**
+ * incrementProperty, decrementProperty
+ */
+assertType(o.incrementProperty('baz')); // $ExpectType number
+assertType(o.decrementProperty('baz')); // $ExpectType number
+assertType(o.incrementProperty('baz', 3)); // $ExpectType number
+assertType(o.decrementProperty('baz', 12)); // $ExpectType number
+// non-numeric property case
+assertType(o.incrementProperty('bar')); // $ExpectError
+assertType(o.decrementProperty('bar')); // $ExpectError
+// empty case
+assertType(o.incrementProperty()); // $ExpectError
+assertType(o.decrementProperty()); // $ExpectError
+
+/**
+ * toggleProperty
+ */
+o.toggleProperty('isFoo'); // $ExpectType boolean
+o.toggleProperty(); // $ExpectError
+
+/**
+ * getWithDefault
+ */
+assertType(o.getWithDefault('foo', 'zzz')); // $ExpectType string
+assertType<[boolean, boolean]>(o.getWithDefault('bar', [false, false])); // $ExpectType [boolean, boolean]
+assertType(o.getWithDefault('baz', 10)); // $ExpectType number | undefined
+// improper arguments cases
+assertType(o.getWithDefault('baz', '10')); // $ExpectError
+assertType(o.getWithDefault('baz')); // $ExpectError
+assertType(o.getWithDefault()); // $ExpectError
+
+/**
+ * getProperties
+ */
+// ('foo', 'bar')
+assertType<{ foo: string, bar: [boolean, boolean] }>(o.getProperties('foo', 'bar')); // $ExpectType { foo: string; bar: [boolean, boolean]; }
+// ['foo', 'bar']
+assertType<{ foo: string, bar: [boolean, boolean] }>(o.getProperties(['foo', 'bar'])); // $ExpectType { foo: string; bar: [boolean, boolean]; }
+// empty cases
+assertType<{}>(o.getProperties()); // $ExpectType {}
+assertType<{}>(o.getProperties([])); // $ExpectType {}
+// property that doesn't exist
+assertType(o.getProperties('jeanShorts', 'foo')); // $ExpectError
+assertType(o.getProperties(['foo', 'jeanShorts'])); // $ExpectError
+
+/**
+ * set
+ */
+assertType(o.set('foo', 'abc')); // $ExpectType string
+assertType<[boolean, boolean]>(o.set('bar', [false, false])); // $ExpectType [boolean, boolean]
+assertType(o.set('baz', undefined)); // $ExpectType number | undefined
+assertType(o.set('baz', 10)); // $ExpectType number | undefined
+// property that doesn't exist
+assertType(o.set('jeanShorts', 10)); // $ExpectError
+
+/**
+ * setProperties
+ */
+assertType<{ foo: string, bar: [boolean, boolean] }>(o.setProperties({ foo: 'abc', bar: [true, true] })); // $ExpectType { foo: string; bar: [boolean, boolean]; }
+// empty case
+assertType<{}>(o.setProperties({})); // $ExpectType {}
+// property that doesn't exist
+assertType(o.setProperties({ jeanShorts: 'under the pants' })); // $ExpectError
+
+/**
+ * notifyPropertyChange
+ */
+assertType(o.notifyPropertyChange('foo')); // $ExpectType DemoObservable
+assertType(o.notifyPropertyChange('jeanShorts')); // $ExpectError
diff --git a/types/ember/test/techniques/properties-from-this.ts b/types/ember/test/techniques/properties-from-this.ts
new file mode 100644
index 0000000000..eef58009c3
--- /dev/null
+++ b/types/ember/test/techniques/properties-from-this.ts
@@ -0,0 +1,62 @@
+/**
+ * These tests validate that the method of pulling property types off of this
+ * continues to work. We use this technique in the critical Observable interface
+ * that serves to implement a lot of Ember.CoreObject's functionality
+ */
+
+class BoxedProperty {
+ __getType: Get;
+ __setType: Set;
+}
+
+type UnboxGetProperty = T extends BoxedProperty