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/bip32/bip32-tests.ts b/types/bip32/bip32-tests.ts
new file mode 100644
index 0000000000..4256ca6366
--- /dev/null
+++ b/types/bip32/bip32-tests.ts
@@ -0,0 +1,9 @@
+import { fromBase58 } from 'bip32';
+
+const node = fromBase58("xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi");
+
+const child = node.derivePath('m/0');
+
+const grandchild = child.derive(2);
+
+grandchild.toWIF() === 'Kxtby4wzfHeCaRXma16dBNLgUE7Ct3Xkb6sRs3aZ56Bmtf1rcNWs';
diff --git a/types/bip32/index.d.ts b/types/bip32/index.d.ts
new file mode 100644
index 0000000000..99a1b8dffd
--- /dev/null
+++ b/types/bip32/index.d.ts
@@ -0,0 +1,67 @@
+// Type definitions for bip32 1.0
+// Project: https://github.com/bitcoinjs/bip32#readme
+// Definitions by: My Self
+// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
+///
+
+export interface NetworkType {
+ wif: number; // UInt8
+ bip32: {
+ public: number; // UInt32
+ private: number; // UInt32
+ };
+}
+
+export class BIP32 {
+ private constructor(d: Buffer, Q: Buffer, chainCode: Buffer, network: NetworkType);
+
+ identifier: Buffer;
+ fingerprint: Buffer;
+ privateKey: Buffer;
+ publicKey: Buffer;
+
+ private depth: number;
+ private index: number;
+ private parentFingerprint: number;
+ private network: NetworkType;
+
+ isNeutered(): boolean;
+ neutered(): BIP32;
+ toBase58(): string;
+ toWIF(): string;
+ derive(index: number): BIP32;
+ deriveHardened(index: number): BIP32;
+ derivePath(path: string): BIP32;
+ sign(hash: Buffer): Buffer;
+ verify(hash: Buffer, signature: Buffer): boolean;
+}
+
+/**
+ * Returns a node
+ * @param string base58 encoded string
+ * @param network network type of the node
+ */
+export function fromBase58(string: string, network?: NetworkType): BIP32;
+
+/**
+ * Returns a hardened node
+ * @param privateKey node private key
+ * @param chainCode 256-bits entropy extension
+ * @param network network type of the node
+ */
+export function fromPrivateKey(privateKey: Buffer, chainCode: Buffer, network?: NetworkType): BIP32;
+
+/**
+ * Returns a non-hardened node
+ * @param publicKey node public key
+ * @param chainCode 256-bits entropy extension
+ * @param network network type of the node
+ */
+export function fromPublicKey(publicKey: Buffer, chainCode: Buffer, network?: NetworkType): BIP32;
+
+/**
+ * Returns a hardened node
+ * @param seed seed encoding node info
+ * @param network network type of the node
+ */
+export function fromSeed(seed: Buffer, network?: NetworkType): BIP32;
diff --git a/types/bip32/tsconfig.json b/types/bip32/tsconfig.json
new file mode 100644
index 0000000000..ca18bb2a82
--- /dev/null
+++ b/types/bip32/tsconfig.json
@@ -0,0 +1,23 @@
+{
+ "compilerOptions": {
+ "module": "commonjs",
+ "lib": [
+ "es6"
+ ],
+ "noImplicitAny": true,
+ "noImplicitThis": true,
+ "strictNullChecks": true,
+ "baseUrl": "../",
+ "typeRoots": [
+ "../"
+ ],
+ "types": [],
+ "noEmit": true,
+ "forceConsistentCasingInFileNames": true,
+ "strictFunctionTypes": true
+ },
+ "files": [
+ "index.d.ts",
+ "bip32-tests.ts"
+ ]
+}
diff --git a/types/bip32/tslint.json b/types/bip32/tslint.json
new file mode 100644
index 0000000000..3db14f85ea
--- /dev/null
+++ b/types/bip32/tslint.json
@@ -0,0 +1 @@
+{ "extends": "dtslint/dt.json" }
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/cookie-session/index.d.ts b/types/cookie-session/index.d.ts
index a0b7a2e6b0..af48860396 100644
--- a/types/cookie-session/index.d.ts
+++ b/types/cookie-session/index.d.ts
@@ -15,7 +15,7 @@ declare namespace CookieSessionInterfaces {
/**
* The name of the cookie to set, defaults to session.
*/
- name: string;
+ name?: string;
/**
* The list of keys to use to sign & verify cookie values. Set cookies are always signed with keys[0], while the other keys are valid for verification, allowing for key rotation.
@@ -47,6 +47,11 @@ declare namespace CookieSessionInterfaces {
*/
domain?: string;
+ /**
+ * a boolean or string indicating whether the cookie is a "same site" cookie (false by default). This can be set to 'strict', 'lax', or true (which maps to 'strict').
+ */
+ sameSite?: "strict" | "lax" | boolean;
+
/**
* a boolean indicating whether the cookie is only to be sent over HTTPS (false by default for HTTP, true by default for HTTPS).
*/
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/d3.cloud.layout/d3.cloud.layout-tests.ts b/types/d3-cloud/d3-cloud-tests.ts
similarity index 100%
rename from types/d3.cloud.layout/d3.cloud.layout-tests.ts
rename to types/d3-cloud/d3-cloud-tests.ts
diff --git a/types/d3.cloud.layout/index.d.ts b/types/d3-cloud/index.d.ts
similarity index 100%
rename from types/d3.cloud.layout/index.d.ts
rename to types/d3-cloud/index.d.ts
diff --git a/types/d3.cloud.layout/tsconfig.json b/types/d3-cloud/tsconfig.json
similarity index 94%
rename from types/d3.cloud.layout/tsconfig.json
rename to types/d3-cloud/tsconfig.json
index ffb26214cc..d5f3d151b7 100644
--- a/types/d3.cloud.layout/tsconfig.json
+++ b/types/d3-cloud/tsconfig.json
@@ -24,6 +24,6 @@
},
"files": [
"index.d.ts",
- "d3.cloud.layout-tests.ts"
+ "d3-cloud-tests.ts"
]
}
\ No newline at end of file
diff --git a/types/d3.cloud.layout/tslint.json b/types/d3-cloud/tslint.json
similarity index 100%
rename from types/d3.cloud.layout/tslint.json
rename to types/d3-cloud/tslint.json
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 fe784dae8b..6d79e1df8b 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';
@@ -28,51 +38,25 @@ declare module 'ember' {
// Get an alias to the global Array type to use in inner scope below.
type GlobalArray = T[];
- /**
- * 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;
- };
+ // TODO: TypeScript 3.0
+ // type FunctionArgs any> = F extends (...args: infer ARGS) => any ? ARGS : never;
+ type FunctionArgs =
+ F extends (a: infer A) => any
+ ? [A]
+ : F extends (a: infer A, b: infer B) => any
+ ? [A, B]
+ : F extends (a: infer A, b: infer B, c: infer C) => any
+ ? [A, B, C]
+ : F extends (a: infer A, b: infer B, c: infer C, d: infer D) => any
+ ? [A, B, C, D]
+ : F extends (a: infer A, b: infer B, c: infer C, d: infer D, e: infer E) => any
+ ? [A, B, C, D, E]
+ : never;
- 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.
@@ -90,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;
@@ -129,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;
@@ -310,6 +277,17 @@ declare module 'ember' {
interface ArrayPrototypeExtensions extends MutableArray, Observable, Copyable {}
+ interface StringPrototypeExtensions {
+ camelize(): string;
+ decamelize(): string;
+ classify(): string;
+ capitalize(): string;
+ loc(values?: string[]): string;
+ dasherize(): string;
+ underscore(): string;
+ w(): string[];
+ }
+
/**
* Given a fullName return a factory manager.
*/
@@ -2439,7 +2417,7 @@ declare module 'ember' {
function fmt(...args: string[]): string;
function htmlSafe(str: string): Handlebars.SafeString;
function isHTMLSafe(str: string): boolean;
- function loc(...args: string[]): string;
+ function loc(template: string, args?: string[]): string;
function underscore(str: string): string;
function w(str: string): string[];
}
@@ -3142,7 +3120,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.
*/
@@ -3286,14 +3264,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
@@ -3320,7 +3301,14 @@ declare module 'ember' {
* Checks to see if the `methodName` exists on the `obj`,
* and if it does, invokes it with the arguments passed.
*/
- function tryInvoke(obj: any, methodName: string, args?: any[]): any;
+ function tryInvoke(
+ obj: T,
+ methodName: FNAME,
+ args: FunctionArgs): T[FNAME] extends ((...args: any[]) => any)
+ ? ReturnType
+ : undefined;
+ function tryInvoke(obj: T, methodName: FNAME): T[FNAME] extends (() => any) ? ReturnType : undefined;
+ function tryInvoke(obj: object, methodName: string, args?: any[]): undefined;
/**
* Forces the passed object to be part of an array. If the object is already
* an array, it will return the object. Otherwise, it will add the object to
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/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..015be1057b
--- /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: keyof this, 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: keyof this, 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